<commit_before># UriConfig

[![Build Status](https://travis-ci.org/JonathonMA/uri_config.svg?branch=master)](https://travis-ci.org/JonathonMA/uri_config)

Configure services via URI.

## Installation

Add this line to your application's Gemfile:

```ruby
gem 'uri_config'
```

And then execute:

    $ bundle

Or install it yourself as:

    $ gem install uri_config

## Usage

Extract credentials from generic URIs:

```ruby
    config = URIConfig::Config.new("https://my_user:my_pass@s3.amazonaws.com/a_path")

    config.username # => "my_user"
    config.password # => "<PASSWORD>"
    config.path # => "/bucket_name"
```

Build wrapper classes for more specific configuration hashes:

```ruby
  class S3Config < Config
    alias_method :access_key_id, :username
    alias_method :secret_access_key, :password

    def bucket
      path[1..-1]
    end

    config :access_key_id, :secret_access_key, :bucket
  end

  config = S3Config.new("https://AKIAJUSERNAME:abcd12345678@s3.amazonaws.com/bucket_name")

  config.access_key_id # => "AKIAJUSERNAME"
  config.secret_access_key # => "<KEY>"
  config.bucket # => "bucket_name"

  config.config # => {access_key_id: "AKIAJUSERNAME, secret_access_key: "<KEY>", bucket: "bucket_name" }
```

## Contributing

1. Fork it ( https://github.com/JonathonMA/uri_config/fork )
2. Create your feature branch (`git checkout -b my-new-feature`)
3. Commit your changes (`git commit -am 'Add some feature'`)
4. Push to the branch (`git push origin my-new-feature`)
5. Create a new Pull Request<commit_msg>Outdent example ruby code<commit_after># UriConfig

[![Build Status](https://travis-ci.org/JonathonMA/uri_config.svg?branch=master)](https://travis-ci.org/JonathonMA/uri_config)

Configure services via URI.

## Installation

Add this line to your application's Gemfile:

```ruby
gem 'uri_config'
```

And then execute:

    $ bundle

Or install it yourself as:

    $ gem install uri_config

## Usage

Extract credentials from generic URIs:

```ruby
config = URIConfig::Config.new("https://my_user:my_pass@s3.amazonaws.com/a_path")

config.username # => "my_user"
config.password # => "<PASSWORD>"
config.path # => "/bucket_name"
```

Build wrapper classes for more specific configuration hashes:

```ruby
class S3Config < Config
  alias_method :access_key_id, :username
  alias_method :secret_access_key, :password

  def bucket
    path[1..-1]
  end

  config :access_key_id, :secret_access_key, :bucket
end

config = S3Config.new("https://AKIAJUSERNAME:abcd12345678@s3.amazonaws.com/bucket_name")

config.access_key_id # => "AKIAJUSERNAME"
config.secret_access_key # => "<KEY>"
config.bucket # => "bucket_name"

config.config # => {access_key_id: "AKIAJUSERNAME, secret_access_key: "<KEY>", bucket: "bucket_name" }
```

## Contributing

1. Fork it ( https://github.com/JonathonMA/uri_config/fork )
2. Create your feature branch (`git checkout -b my-new-feature`)
3. Commit your changes (`git commit -am 'Add some feature'`)
4. Push to the branch (`git push origin my-new-feature`)
5. Create a new Pull Request
{'fraction_non_alphanumeric': 0.13425016371971185, 'fraction_numerical': 0.012442698100851343, 'mean_word_length': 4.554545454545455, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 23, 'https://': 10, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 4, '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': '1105701', 'n_tokens_mistral': 1080, 'n_tokens_neox': 1019, 'n_words': 256}