Sha256: 9c002e3b2325875d224ea5b3a533a06c4af7dcc0b5c7f23c7a22b5b365ff2039

Contents?: true

Size: 1.04 KB

Versions: 1

Compression:

Stored size: 1.04 KB

Contents

$: << "../lib"
require 'configdsl'

# Read external data
ConfigDSL.read("test.cdsl.rb")

# Execute inline data
ConfigDSL.execute do
  inline_loading_example "here goes"
  value "awesome"
  code "great"
  block_test "config option" do |preset|
    block_val preset
  end
end

# Another inline data
ConfigDSL.execute do
  value "awesome"
end

require "pp" # for pretty print

# Here is how you get all the config
pp ConfigDSL.data

# To read data from your app you can do this:

puts ; puts "Value of :value is: "
p ConfigDSL.data[:value]

# or this

puts ; puts "Another way to get it is: "
p ConfigDSL[:value]

# Access block values

puts "Block values: "

puts ; puts "-- [:list][:one]"
p ConfigDSL[:list][:one]

puts ; puts "-- [:list][:two]"
p ConfigDSL[:list][:two]

puts ; puts "-- [:list][:three]"
p ConfigDSL[:list][:three]

puts ; puts "-- [:list][:three][:three_two]"
p ConfigDSL[:list][:three][:three_two]

# Get something complex
puts ; puts "Program was stared at: "
p ConfigDSL[:starting_time]

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
configdsl-1.0.0 examples/example.rb