Confstruct is a versatile config object for Ruby
Exposing configuration options to API consumers is a common programming scenario. In Ruby, configuration via block is a popular approach:
Gowalla.configure do |config|
config.api_key = 'your_api_key'
config.username = 'pengwynn'
config.password = 'somepassword'
end
gowalla = Gowalla::Client.new
Confstruct from Michael B. Klein makes it easy to expose this sort of API configuration as well as hash-based and dot notation styles.
config.github[:url] = 'http://www.github.com/somefork/other-project'
config[:github].branch = 'pre-1.0'
Confstruct also supports a number of !
methods to add temporary overrides, safe lookups, and array appending. Check the README for advanced usage.
Discussion
Sign in or Join to comment or subscribe