Sha256: 7f10164afb360b6428eff74b1c4d8611999da6f8388c75549535e501fa216c4a

Contents?: true

Size: 1.58 KB

Versions: 1

Compression:

Stored size: 1.58 KB

Contents

require File.expand_path(File.join(File.dirname(__FILE__), '..', 'lib', 'configr'))

# Standalone (without YAML)

configuration = Configr::Configuration.configure do |config|
  config.example_one = "One"
  config.example_two = "Two"
end

puts configuration.example_one
puts configuration.example_two
puts configuration.doesnt_exist


# With YAML (inline)

yaml = <<YAML

example_one: "Oooooo"
example_two: "It loads from YAML too!"

YAML

configuration = Configr::Configuration.configure(yaml)

puts configuration.example_one
puts configuration.example_two


# With YAML (file)

configuration = Configr::Configuration.configure(File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec', 'fixtures', 'configuration.yml')))

puts configuration.first_name
puts configuration.location


# Or go nuts (inline yaml and block)

yaml = <<YAML

example_three: "Oooooo"
example_four: "It loads from YAML too!"

YAML

configuration = Configr::Configuration.configure(yaml) do |config|
  config.example_one = "One"
  config.example_two = "Two"
end

puts configuration.example_one
puts configuration.example_two
puts configuration.example_three
puts configuration.example_four

# Good for things like this

Config = Configr::Configuration.configure do |config|
  config.support_email    = "goaway@example.com"
  config.google_analytics = "UA-x343x-SDS"
  
  config.twitter.screen_name = "someone"
  config.twitter.password    = "somepass"
end

puts Config.support_email
puts Config.google_analytics
puts Config.twitter[:screen_name]
puts Config.twitter[:password]

puts Config.twitter.screen_name
puts Config.twitter.password

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
configr-0.2.0 examples/all.rb