Sha256: 4e0ec231877757158464933bfd8ffcec80bce4f160ea4d0b6c1cc4669a1a9c66

Contents?: true

Size: 963 Bytes

Versions: 14

Compression:

Stored size: 963 Bytes

Contents

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

Settings.use :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.definition_of(: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

14 entries across 14 versions & 1 rubygems

Version Path
configliere-0.4.22 examples/env_var_script.rb
configliere-0.4.18 examples/env_var_script.rb
configliere-0.4.17 examples/env_var_script.rb
configliere-0.4.16 examples/env_var_script.rb
configliere-0.4.14 examples/env_var_script.rb
configliere-0.4.13 examples/env_var_script.rb
configliere-0.4.12 examples/env_var_script.rb
configliere-0.4.11 examples/env_var_script.rb
configliere-0.4.10 examples/env_var_script.rb
configliere-0.4.8 examples/env_var_script.rb
configliere-0.4.7 examples/env_var_script.rb
configliere-0.4.6 examples/env_var_script.rb
configliere-0.4.5 examples/env_var_script.rb
configliere-0.4.4 examples/env_var_script.rb