🚀 DAY 5 OF LAUNCH WEEK:Introducing Webhook Events for Alert Changes.Learn more →
Socket
Book a DemoInstallSign in
Socket

dotconfig

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

dotconfig

bundlerRubygems
Version
0.0.5
Version published
Maintainers
1
Created
Source

DotConfig Build Status

This gem is only compatible with Ruby 1.9.

The DotConfig gem give you access to your configuration via the dot syntax. You instantiate DotConfig::Configuration with a Hash and you will retrieve the values in calling the key as method name.

Installation

Add this line to your application's Gemfile:

gem 'dot_config'

And then execute:

$ bundle

Or install it yourself as:

$ gem install dot_config

Usage

# Instantiate the configuration with the shortcut:
app_config = DotConfig.new(language: 'Ruby', framework: 'Ruby on Rails')

app_config.language  #=> 'Ruby'
app_config.framework #=> 'Ruby on Rails'
app_config.version   #=> NoMethodError: undefined method `version' for #<DotConfig::Configuration:0x007fb1fed55dd8>

# Instantiate the configuration without the shortcut:
app_config = DotConfig::Configuration.new(config: { language: 'Ruby', framework: 'Ruby on Rails' })

# Instantiate the configuration with an instance of DotConfig::Configuration:
app_config = DotConfig::Configuration.new
app_config.config = { language: 'Ruby', framework: 'Ruby on Rails' }

# Instantiate the configuration with a YAML file:
app_config = DotConfig.new('PATH/TO/YOUR/FILE.yml')

# Use a nested Hash:
app_config = DotConfig.new(language: { ruby: 'Ruby on Rails' })

app_config.language      #=> #<DotConfig::Configuration:0x007fb1fed55dd8>
app_config.language.ruby #=> 'Ruby on Rails'

# Enable the modification:
app_config = DotConfig.new({ language: 'Ruby', framework: 'Ruby on Rails' }, true)
# or
app_config = DotConfig.new(true)
app_config.config = { language: 'Ruby', framework: 'Ruby on Rails' }

app_config.language  #=> 'Ruby'
app_config.language = 'Python'
app_config.language  #=> 'Python'

# Export the configuration:
app_config = DotConfig.new(language: { ruby: 'Ruby on Rails' })

app_config.to_hash #=> { language: { ruby: 'Ruby on Rails' } }

Documentation

To get more information about this gem, please visit RubyDoc.

Contributing

  • Fork it
  • Create your feature branch (git checkout -b my-new-feature)
  • Commit your changes (git commit -am 'Add some feature')
  • Push to the branch (git push origin my-new-feature)
  • Create new Pull Request

FAQs

Package last updated on 30 Dec 2012

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts