<commit_before># RsyncConfig

This is a little utility gem to help manage the rsyncd config files on GNU/Linux systems.
It is still in infancy but is usable as is.

[![Code Climate](https://codeclimate.com/github/kuma-giyomu/rsync_config.png)](https://codeclimate.com/github/kuma-giyomu/rsync_config)

## Installation

Add this line to your application's Gemfile:

    gem 'rsync_config'

And then execute:

    $ bundle

Or install it yourself as:

    $ gem install rsync_config

## Usage

You can load a config file using `RsyncConfig::load_config <file_path>` or create a config from scratch with `RsyncConfig::Config.new`.
Alternatively, you can use `RsyncConfig::parse <content>` if you prefer to provide the input from a random source.

### Properties

The `RsyncConfig::Config` instance provides access to properties via the `#[]` and `#[]=` methods. So for instance 

    config = RsyncConfig::Config.new
    config['uid'] = 'alice' # setter
    puts config['uid']      # getter

Note that the class accepts symbols as alternative `config[:uid]` is valid too.
But I felt it was best to keep as strings for the config options with spaces such as `secrets file`.

### Modules

The `RsyncConfig::Config` instance provides access to modules via the `#module` method

    config = RsyncConfig::Config.new
    foo_module = config.module :foo
    bar_module = config.module 'bar'

Here again, symbols are converted to strings (rsync allows modules with spaces and whatnot)

Properties can be assigned to modules in the same way they are added to the `RsyncConfig::Config` object.

    foo_module['uid'] = 'alice'

`RsyncConfig::Module` instances do not have modules themselves.

### Users

Both `RsyncConfig::Config` and `RsyncConfig::Module` instances can define a list of users that have access to the modules.
They are defined using the `#users` hash accessor method.
Additionally a test method `#user?` can be used to probe for a give user's existence.

    config = RsyncConfig::Config.new
    config.users = {'alice' => 'wonder'}
    puts config.user?('alice') # true
    config.users['bob'] = 'march'

### Writing to disk

Use `RsyncConfig::Config#write_to <main_output_file>`.
The gem assumes that you have write permissions on the file and a `RuntimeError` will be raised otherwise.<commit_msg>Add syntax highlighting hints<commit_after># RsyncConfig

This is a little utility gem to help manage the rsyncd config files on GNU/Linux systems.
It is still in infancy but is usable as is.

[![Code Climate](https://codeclimate.com/github/kuma-giyomu/rsync_config.png)](https://codeclimate.com/github/kuma-giyomu/rsync_config)

## Installation

Add this line to your application's Gemfile:

    gem 'rsync_config'

And then execute:

    $ bundle

Or install it yourself as:

    $ gem install rsync_config

## Usage

You can load a config file using `RsyncConfig::load_config <file_path>` or create a config from scratch with `RsyncConfig::Config.new`.
Alternatively, you can use `RsyncConfig::parse <content>` if you prefer to provide the input from a random source.

### Properties

The `RsyncConfig::Config` instance provides access to properties via the `#[]` and `#[]=` methods. So for instance 

```ruby
config = RsyncConfig::Config.new
config['uid'] = 'alice' # setter
puts config['uid']      # getter
```

Note that the class accepts symbols as alternative `config[:uid]` is valid too.
But I felt it was best to keep as strings for the config options with spaces such as `secrets file`.

### Modules

The `RsyncConfig::Config` instance provides access to modules via the `#module` method

```ruby
config = RsyncConfig::Config.new
foo_module = config.module :foo
bar_module = config.module 'bar'
```

Here again, symbols are converted to strings (rsync allows modules with spaces and whatnot)

Properties can be assigned to modules in the same way they are added to the `RsyncConfig::Config` object.

```ruby
foo_module['uid'] = 'alice'
```

`RsyncConfig::Module` instances do not have modules themselves.

### Users

Both `RsyncConfig::Config` and `RsyncConfig::Module` instances can define a list of users that have access to the modules.
They are defined using the `#users` hash accessor method.
Additionally a test method `#user?` can be used to probe for a give user's existence.

```ruby
config = RsyncConfig::Config.new
config.users = {'alice' => 'wonder'}
puts config.user?('alice') # true
config.users['bob'] = 'march'
```

### Writing to disk

Use `RsyncConfig::Config#write_to <main_output_file>`.
The gem assumes that you have write permissions on the file and a `RuntimeError` will be raised otherwise.
{'fraction_non_alphanumeric': 0.09848812095032397, 'fraction_numerical': 0.0, 'mean_word_length': 4.620145631067961, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 11, 'https://': 4, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4274503', 'n_tokens_mistral': 1380, 'n_tokens_neox': 1321, 'n_words': 562}