Navigation Menu

Skip to content

Commit

Permalink
Added support for setting config path(s) programmtically.\nAdded supp…
Browse files Browse the repository at this point in the history
…ort for using multiple file types at once.\nCleaned up STDERR statements.
  • Loading branch information
rahmal committed Nov 16, 2009
1 parent 9fb6ca6 commit 8a12699
Show file tree
Hide file tree
Showing 8 changed files with 1,071 additions and 320 deletions.
2 changes: 1 addition & 1 deletion Credits
Expand Up @@ -4,5 +4,5 @@ Mike Sandler, Kurt Stephens, CashNetUSA (CNU):
- The core of logic of RConfig is based on a stand-alone class called CnuConfig, that resided in the CNU codebase.
- It was originally created by Mike Sandler as a config solution for CNU's internal web apps.
- It only supported yaml files, but it boatsed a dottable notation not seen in any other ruby config libraries.
- It was later enhanced by Kurt Stephens to support indifferent access, and callbacks.
- It was later enhanced by Kurt Stephens to support indifferent access, reload support, and callbacks.
- I have made some signifcant enhancements to RConfig since that original debut, all of which are in this gem.
22 changes: 16 additions & 6 deletions README.rdoc
Expand Up @@ -10,29 +10,40 @@ The complete solution for Ruby Configuration Management. RConfig is a Ruby libra
* Yaml and xml files supprt infinite level of configuration grouping.
* Intuitive dot-notation 'key chaining' argument access.
* Simple well-known hash/array based argument access.
* Implements multilevel caching to reduce disk accesses
* Implements multilevel caching to reduce disk access.
* Short-hand access to 'global' application configuration, and shell environment.
* Overlays multiple configuration files to support environment and host-specific configuration.

== Example

shell/console =>
export LANG=en

demo.yml =>
server:
address: host.domain.com
port: 81
...

application.properties =>
debug_level = verbose
...

demo.rb =>
require 'rubygems'
require 'rconfig'
RConfig.config_paths = ['$HOME/config', '#{APP_ROOT}/config', '/demo/conf']
RConfig.demo[:server][:port] => 81
RConfig.demo.server.address => 'host.domain.com'

RConfig[:debug_level] => 'verbose'
RConfig[:lang] => 'en'
...

== Requirements

* Ruby (Developed on 1.8.6)
* RubyGems
* active_support
* Ruby (Developed on 1.8.7)
* RubyGems (Developed on 1.3.5)
* active_support (2.2.2+)

== Install

Expand All @@ -43,7 +54,6 @@ The complete solution for Ruby Configuration Management. RConfig is a Ruby libra
* Finish gemspec; build gem
* Fix tests; convert to RSpec and Cucumber
* Finish Documentation, including RDoc
* Support multiple file types at once?

== Known Issues

Expand Down
63 changes: 2 additions & 61 deletions demo/demo.rb
@@ -1,66 +1,7 @@
#!/usr/bin/env ruby

require('rubygems')
require('rconfig')
#require('./lib/parseconfig.rb')
$LOAD_PATH << File.join(File.dirname(__FILE__),"..","lib")

begin
c = ParseConfig.new('demo.conf')
rescue Errno::ENOENT
puts "The config file you specified was not found"
exit
rescue Errno::EACCES
puts "The config file you specified is not readable"
exit
end
require 'rconfig'

puts
puts 'Reading main config section and groups...'
puts '-' * 77
puts
c.write()
puts
puts 'Available params are...'
puts '-' * 77
puts
puts c.get_params()
puts
puts

puts 'Available sub-groups are...'
puts '-' * 77
puts
puts c.get_groups()
puts
puts

puts 'Accessing sub-group params...'
puts '-' * 77
puts
puts "group1 user name value is: #{c.params['group1']['user_name']}"
puts
puts

puts "Using params hash..."
puts '-' * 77
puts
puts "The admin email address is #{c.params['admin_email']}"
puts
puts

puts "Using get_value (kind of deprecated)..."
puts '-' * 77
puts
puts "The listen address is #{c.get_value('listen_ip')} and the user name " +
"is #{c.get_value('group1')['user_name']}"
puts
puts

puts "Writing the config out to a file"
puts '-' * 77
puts
f = open('/tmp/parseconfig_sample_config', 'w')
c.write(f)
f.close()
puts "Config written to /tmp/parseconfig_sample_config"
puts
Binary file added lib/rconfig/.rconfig.rb.bak.swp
Binary file not shown.

0 comments on commit 8a12699

Please sign in to comment.