Sha256: bfc7a0dd2830402805a4b06d81f63a3412777cd0e436b36a2367d8bf50da0852

Contents?: true

Size: 976 Bytes

Versions: 16

Compression:

Stored size: 976 Bytes

Contents

#!/usr/bin/env ruby
$: << File.dirname(__FILE__)+'/../lib'
require 'configliere'

Settings.use :define, :env_var, :commandline
Settings.define :underpants, :env_var => 'UNDERPANTS', :default => "boxers"
Settings.resolve!

puts %Q{
Configliere can take parameter values from its defaults, from the commandline, or from the environment.
Compare:

./env_var_script.rb                                           # value from default
./env_var_script.rb --underpants=briefs                       # value from commandline
UNDERPANTS="commando" ./env_var_script.rb                     # value from environment variable
UNDERPANTS="commando" ./env_var_script.rb --underpants=briefs # commandline wins

}

puts %Q{Using
* the default setting of:   #{Settings.param_definitions[:underpants][:default].inspect}
* the environment variable: #{ENV['UNDERPANTS'].inspect}
* the commandline setting:  #{ARGV.grep(/^--underpants/).inspect}
your configliere advises that
  #{Settings.inspect}
}

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
configliere-0.3.4 examples/env_var_script.rb
configliere-0.3.3 examples/env_var_script.rb
configliere-0.2.3 examples/env_var_script.rb
configliere-0.3.2 examples/env_var_script.rb
configliere-0.3.1 examples/env_var_script.rb
configliere-0.3.0 examples/env_var_script.rb
configliere-0.2.2 examples/env_var_script.rb
configliere-0.2.1 examples/env_var_script.rb
configliere-0.1.1 examples/env_var_script.rb
configliere-0.1.0 examples/env_var_script.rb
configliere-0.0.9 examples/env_var_script.rb
configliere-0.0.8 examples/env_var_script.rb
configliere-0.0.7 examples/env_var_script.rb
configliere-0.0.6 examples/env_var_script.rb
configliere-0.0.5 examples/env_var_script.rb
configliere-0.0.4 examples/env_var_script.rb