ruby-conf 1.4.4 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.rvmrc +1 -1
- data/README.rdoc +10 -0
- data/Rakefile +1 -1
- data/VERSION +1 -1
- data/lib/ruby-conf.rb +115 -105
- data/ruby-conf.gemspec +9 -9
- data/spec/lib/ruby-conf_spec.rb +163 -14
- metadata +111 -122
data/.rvmrc
CHANGED
@@ -1 +1 @@
|
|
1
|
-
rvm use ruby-1.8.7-
|
1
|
+
rvm use ruby-1.8.7-p370@rubyconf --create
|
data/README.rdoc
CHANGED
@@ -2,6 +2,13 @@
|
|
2
2
|
|
3
3
|
Simple way to do ruby config DSL
|
4
4
|
|
5
|
+
== Install
|
6
|
+
gem install ruby-conf
|
7
|
+
|
8
|
+
== Gemfile
|
9
|
+
|
10
|
+
gem "ruby-conf"
|
11
|
+
|
5
12
|
== Examples
|
6
13
|
|
7
14
|
RubyConf.define :godzilla do
|
@@ -85,6 +92,9 @@
|
|
85
92
|
RailsConfig.production.username # "godzilla"
|
86
93
|
RailsConfig.production.password # "ilovemothra"
|
87
94
|
|
95
|
+
=== Using ruby-conf with Rails
|
96
|
+
Ruby-conf can be used with Rails. Restart the server after setting up config values.
|
97
|
+
|
88
98
|
== Contributing to ruby-conf
|
89
99
|
|
90
100
|
* Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet.
|
data/Rakefile
CHANGED
@@ -20,7 +20,7 @@ Jeweler::Tasks.new do |gem|
|
|
20
20
|
gem.summary = %Q{dsl (domain specific language) for config files in ruby}
|
21
21
|
gem.description = %Q{rubyconf is a ruby configuration dsl that aims to make it simple to write and read configurations for ruby apps without a yaml or xml file}
|
22
22
|
gem.email = "blazingpair@blazingcloud.net"
|
23
|
-
gem.authors = ["Curtis Schofield & Hollin Wilkins"]
|
23
|
+
gem.authors = ["Curtis Schofield & Hollin Wilkins & Mason"]
|
24
24
|
# dependencies defined in Gemfile
|
25
25
|
end
|
26
26
|
Jeweler::RubygemsDotOrgTasks.new
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
2.0.0
|
data/lib/ruby-conf.rb
CHANGED
@@ -1,144 +1,154 @@
|
|
1
1
|
#
|
2
2
|
#
|
3
|
-
# @author Hollin Wilkins & Curtis Schofield
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
attr_reader :attributes
|
3
|
+
# @author Hollin Wilkins & Curtis Schofield & Mason Bo-bay-son
|
4
|
+
module Magic
|
5
|
+
attr_accessor :__rc_chain
|
6
|
+
def __rc_gather() "#{to_s}#{__rc_chain.nil? ? "" : " #{__rc_chain.__rc_gather}"}" end
|
7
|
+
end
|
9
8
|
|
10
|
-
|
11
|
-
|
12
|
-
end
|
9
|
+
class RubyConf < Object
|
10
|
+
@@__rc_configs = {}
|
13
11
|
|
14
|
-
|
15
|
-
|
12
|
+
class Config
|
13
|
+
attr_reader :__rc_attributes, :__rc_parent, :__rc_name, :__rc_chains, :__rc_locked
|
16
14
|
|
17
|
-
|
18
|
-
value.call
|
19
|
-
else
|
20
|
-
value
|
21
|
-
end
|
22
|
-
end
|
15
|
+
def __rc_root() __rc_parent ? __rc_parent.__rc_root : self end
|
23
16
|
|
24
|
-
def
|
25
|
-
@
|
17
|
+
def initialize(name = nil, parent = nil, &block)
|
18
|
+
@__rc_locked, @__rc_attributes, @__rc_chains, @__rc_parent = false, {}, [], parent
|
19
|
+
@__rc_name = name.to_sym if name
|
20
|
+
instance_eval(&block) if block_given?
|
21
|
+
__rc_lock
|
26
22
|
end
|
27
23
|
|
28
|
-
def
|
29
|
-
|
30
|
-
|
24
|
+
def __rc_lock
|
25
|
+
@__rc_locked = true
|
26
|
+
@__rc_attributes.each_value { |value| value.__rc_lock if value.is_a?(Config) }
|
27
|
+
self
|
31
28
|
end
|
32
29
|
|
33
|
-
def []
|
34
|
-
@
|
30
|
+
def [](name, args = nil)
|
31
|
+
value = @__rc_attributes[name.to_sym]
|
32
|
+
value.is_a?(Proc) ? __rc_root.instance_exec(*args, &value) : value
|
35
33
|
end
|
36
34
|
|
37
|
-
def
|
38
|
-
if
|
39
|
-
|
40
|
-
|
41
|
-
|
35
|
+
def __rc_copy(o)
|
36
|
+
if o.is_a?(Hash)
|
37
|
+
o.inject({}) { |copy, (key, val)| copy[key] = __rc_copy(val); copy }
|
38
|
+
elsif o.is_a?(Array)
|
39
|
+
o.inject([]) { |copy, i| copy << __rc_copy(i); copy }
|
40
|
+
else
|
41
|
+
o
|
42
42
|
end
|
43
|
+
end
|
43
44
|
|
44
|
-
|
45
|
+
def to_a() [self] end
|
45
46
|
|
46
|
-
|
47
|
+
def []=(name, value)
|
48
|
+
@__rc_attributes[name.to_sym] = value
|
47
49
|
end
|
48
50
|
|
49
|
-
def
|
50
|
-
if
|
51
|
-
|
52
|
-
|
53
|
-
|
51
|
+
def __rc_set_default(conf, key, value)
|
52
|
+
if conf.__rc_attributes.key?(key)
|
53
|
+
if value.is_a?(Config)
|
54
|
+
sub = conf.__rc_attributes[key]
|
55
|
+
value.__rc_attributes.each do |k, v|
|
56
|
+
__rc_set_default(sub, k, v)
|
57
|
+
end
|
58
|
+
end
|
54
59
|
else
|
55
|
-
|
60
|
+
conf.__rc_attributes[key] = value
|
56
61
|
end
|
57
62
|
end
|
58
63
|
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
64
|
+
def method_missing(name, *args, &block)
|
65
|
+
name = name.to_sym
|
66
|
+
options = args.last.is_a?(Hash) ? args.last : {}
|
67
|
+
|
68
|
+
if block_given?
|
69
|
+
if options.key?(:inherits)
|
70
|
+
self[name] = [*options[:inherits]].inject(Config.new(name, self, &block)) do |conf, inherited|
|
71
|
+
inherited = self[inherited.to_sym] unless inherited.is_a?(Config)
|
72
|
+
__rc_copy(inherited.__rc_attributes).each do |key, value|
|
73
|
+
__rc_set_default(conf, key, value)
|
74
|
+
end
|
75
|
+
conf
|
76
|
+
end
|
77
|
+
elsif self[name].is_a?(Config)
|
78
|
+
self[name].instance_eval(&block)
|
79
|
+
else
|
80
|
+
self[name] = Config.new(name, self, &block)
|
81
|
+
end
|
82
|
+
|
83
|
+
while (chain = self[name].__rc_chains.pop)
|
84
|
+
self[name][chain] = chain.__rc_chain.nil? ? "" : chain.__rc_chain.__rc_gather
|
85
|
+
end
|
86
|
+
|
70
87
|
else
|
71
|
-
|
72
|
-
|
88
|
+
|
89
|
+
super if @__rc_locked && args.size == 0 && !@__rc_attributes.key?(name)
|
90
|
+
|
91
|
+
if !@__rc_attributes.key?(name) && (args.size == 0 || args.first.is_a?(Magic))
|
92
|
+
str = name.to_s
|
93
|
+
str.extend(Magic)
|
94
|
+
if args.first.is_a?(Magic)
|
95
|
+
str.__rc_chain = args.first
|
96
|
+
@__rc_chains.delete_if { |a| a.equal? args.first }
|
97
|
+
end
|
98
|
+
@__rc_chains << str
|
99
|
+
return str
|
100
|
+
end
|
101
|
+
|
102
|
+
if args.empty?
|
103
|
+
self[name]
|
104
|
+
else
|
105
|
+
args = args.size == 1 ? args.first : args
|
106
|
+
(@__rc_locked && __rc_attributes[name.to_sym].is_a?(Proc)) ? self[name, args] : self[name] = args
|
107
|
+
end
|
108
|
+
|
73
109
|
end
|
74
|
-
end
|
75
110
|
|
76
|
-
def _update_config_with_block(name,block)
|
77
|
-
self[name].instance_eval(&block)
|
78
111
|
end
|
79
112
|
|
80
|
-
def
|
81
|
-
|
113
|
+
def respond_to?(name)
|
114
|
+
super || @__rc_attributes.key?(name) || @__rc_parent.respond_to?(name)
|
82
115
|
end
|
83
116
|
|
84
|
-
def
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
117
|
+
def __rc_build_string(depth = 0)
|
118
|
+
str = ""
|
119
|
+
str += "[#@__rc_name]\n" unless @__rc_parent
|
120
|
+
str += "\n"
|
121
|
+
@__rc_attributes.keys.map{|k| k.to_s }.sort.each do |key|
|
122
|
+
value = self[key]
|
123
|
+
str += " " * depth
|
124
|
+
str += "#{key}:"
|
125
|
+
str += value.is_a?(Config) ? value.__rc_build_string(depth+1) : " #{value}\n"
|
126
|
+
str += "\n" unless depth > 0
|
89
127
|
end
|
128
|
+
str
|
90
129
|
end
|
130
|
+
def to_s() __rc_build_string end
|
131
|
+
def to_str() to_s end
|
91
132
|
|
92
|
-
def
|
93
|
-
|
94
|
-
inherit name, args.first[:inherits]
|
95
|
-
end
|
96
|
-
end
|
133
|
+
def __rc_build_inspect() "#{"[#@__rc_name] " unless @__rc_parent}#{@__rc_attributes.keys.map {|k| k.to_s }.sort.map { |key| "#{key}: #{self[key].is_a?(Config) ? "{ #{self[key].__rc_build_inspect} }" : self[key].inspect}" }.join(", ")}" end
|
134
|
+
def inspect() __rc_build_inspect end
|
97
135
|
end
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
# BanannaChomper.lookup("nancy.bananas").count
|
108
|
-
# }
|
109
|
-
# end
|
110
|
-
#
|
111
|
-
#
|
112
|
-
# @param [Symbol] namespace of the config
|
113
|
-
# @param [Hash] list of options. e.g. :as => ConstantName
|
114
|
-
def self.define(name = nil , options = {}, &block)
|
115
|
-
config = Config.new
|
116
|
-
config.instance_eval &block
|
117
|
-
|
118
|
-
@@configs[name.to_sym] = config unless name.nil?
|
119
|
-
if options.has_key? :as
|
120
|
-
Object.const_set(options[:as].to_s.to_sym, config)
|
136
|
+
|
137
|
+
def self.define(name = nil, options = {}, &block)
|
138
|
+
config = Config.new(name, &block)
|
139
|
+
@@__rc_configs[name.to_sym] = config unless name.nil?
|
140
|
+
|
141
|
+
const = options.fetch(:as, name)
|
142
|
+
if const && const.to_s[/^[A-Z]/]
|
143
|
+
const = const.to_sym
|
144
|
+
Object.const_set(const, config) if !Object.const_defined?(const) || Object.const_get(const).is_a?(Config)
|
121
145
|
end
|
122
146
|
config
|
123
147
|
end
|
124
148
|
|
125
|
-
def self.[](name)
|
126
|
-
@@configs[name.to_sym]
|
127
|
-
end
|
149
|
+
def self.[](name) @@__rc_configs[name.to_sym] end
|
128
150
|
|
129
|
-
def self.method_missing(name, *args
|
130
|
-
if @@configs.has_key? name.to_sym
|
131
|
-
@@configs[name.to_sym]
|
132
|
-
else
|
133
|
-
super
|
134
|
-
end
|
135
|
-
end
|
151
|
+
def self.method_missing(name, *args) @@__rc_configs[name.to_sym] end
|
136
152
|
|
137
|
-
def self.respond_to?(name)
|
138
|
-
if @@configs.has_key? name.to_sym
|
139
|
-
true
|
140
|
-
else
|
141
|
-
super
|
142
|
-
end
|
143
|
-
end
|
153
|
+
def self.respond_to?(name) @@__rc_configs.key?(name.to_sym) end
|
144
154
|
end
|
data/ruby-conf.gemspec
CHANGED
@@ -4,14 +4,14 @@
|
|
4
4
|
# -*- encoding: utf-8 -*-
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
|
-
s.name =
|
8
|
-
s.version = "
|
7
|
+
s.name = "ruby-conf"
|
8
|
+
s.version = "2.0.0"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
-
s.authors = ["Curtis Schofield & Hollin Wilkins"]
|
12
|
-
s.date =
|
13
|
-
s.description =
|
14
|
-
s.email =
|
11
|
+
s.authors = ["Curtis Schofield & Hollin Wilkins & Mason"]
|
12
|
+
s.date = "2012-12-20"
|
13
|
+
s.description = "rubyconf is a ruby configuration dsl that aims to make it simple to write and read configurations for ruby apps without a yaml or xml file"
|
14
|
+
s.email = "blazingpair@blazingcloud.net"
|
15
15
|
s.extra_rdoc_files = [
|
16
16
|
"LICENSE.txt",
|
17
17
|
"README.rdoc"
|
@@ -31,11 +31,11 @@ Gem::Specification.new do |s|
|
|
31
31
|
"spec/lib/ruby-conf_spec.rb",
|
32
32
|
"spec/spec_helper.rb"
|
33
33
|
]
|
34
|
-
s.homepage =
|
34
|
+
s.homepage = "http://github.com/blazingpair/ruby-conf"
|
35
35
|
s.licenses = ["MIT"]
|
36
36
|
s.require_paths = ["lib"]
|
37
|
-
s.rubygems_version =
|
38
|
-
s.summary =
|
37
|
+
s.rubygems_version = "1.8.24"
|
38
|
+
s.summary = "dsl (domain specific language) for config files in ruby"
|
39
39
|
|
40
40
|
if s.respond_to? :specification_version then
|
41
41
|
s.specification_version = 3
|
data/spec/lib/ruby-conf_spec.rb
CHANGED
@@ -1,19 +1,162 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
require 'ruby-conf'
|
3
3
|
|
4
|
-
# write it
|
5
|
-
#
|
6
|
-
#RubyConf.define "namespace" do
|
7
|
-
# thingy 'aoeuaoe'
|
8
|
-
#end
|
9
|
-
#
|
10
|
-
## read it
|
11
|
-
#
|
12
|
-
#RubyConf.namespace.thingy
|
13
|
-
|
14
|
-
|
15
4
|
describe RubyConf do
|
16
5
|
subject { RubyConf }
|
6
|
+
|
7
|
+
describe "lambda arguments" do
|
8
|
+
it "accepts arguments for lambdas" do
|
9
|
+
RubyConf.define("lambda args", :as => :Hannibal) do
|
10
|
+
silence_of_the lambda { |clarise, fava, chianti|
|
11
|
+
"Hello #{clarise}. I'd like to eat your liver with #{fava} beans, and a nice #{chianti}."
|
12
|
+
}
|
13
|
+
end
|
14
|
+
|
15
|
+
Hannibal.silence_of_the('Cow', 'refried', 'glass of milk').should == "Hello Cow. I'd like to eat your liver with refried beans, and a nice glass of milk."
|
16
|
+
|
17
|
+
RubyConf.define("single lambda arg", :as => :Argue) do
|
18
|
+
you_are_a lambda { |meanie|
|
19
|
+
"Why are you such a jerk, #{meanie}"
|
20
|
+
}
|
21
|
+
end
|
22
|
+
|
23
|
+
Argue.you_are_a('My Love?').should == "Why are you such a jerk, My Love?"
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
describe ".root" do
|
28
|
+
|
29
|
+
it "has a heirarchy" do
|
30
|
+
RubyConf.define "RootTest" do
|
31
|
+
outer do
|
32
|
+
middle do
|
33
|
+
inner do
|
34
|
+
val value
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
RootTest.outer.middle.inner.val.should == "value"
|
41
|
+
|
42
|
+
RootTest.__rc_parent.should be_nil
|
43
|
+
RootTest.outer.__rc_parent.should == RootTest
|
44
|
+
RootTest.outer.middle.__rc_parent.should == RootTest.outer
|
45
|
+
RootTest.outer.middle.inner.__rc_parent.should == RootTest.outer.middle
|
46
|
+
|
47
|
+
RootTest.__rc_root.should == RootTest
|
48
|
+
RootTest.outer.__rc_root.should == RootTest
|
49
|
+
RootTest.outer.middle.__rc_root == RootTest
|
50
|
+
RootTest.outer.middle.inner.__rc_root.should == RootTest
|
51
|
+
|
52
|
+
end
|
53
|
+
|
54
|
+
it "sets self properly in nested procs" do
|
55
|
+
RubyConf.define "SelfSetTest" do
|
56
|
+
val proc { self }
|
57
|
+
outer do
|
58
|
+
val proc { self }
|
59
|
+
middle do
|
60
|
+
val proc { self }
|
61
|
+
inner do
|
62
|
+
val proc { self }
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
SelfSetTest.val.should == SelfSetTest
|
69
|
+
SelfSetTest.outer.val.should == SelfSetTest
|
70
|
+
SelfSetTest.outer.middle.val.should == SelfSetTest
|
71
|
+
SelfSetTest.outer.middle.inner.val.should == SelfSetTest
|
72
|
+
|
73
|
+
end
|
74
|
+
|
75
|
+
end
|
76
|
+
|
77
|
+
describe ".to_s" do
|
78
|
+
it "prints out the config in a human readable way" do
|
79
|
+
RubyConf.define("some shapes", :as => :Shapes) {
|
80
|
+
defaults { position { px 10; py 20 }; size { width 100; height 200 }; rotation lambda { '90 degrees' } }
|
81
|
+
other { sides 4; color blue like the color of the sea before a storm }
|
82
|
+
triangle(:inherits => 'defaults') { named :rectangle; size { width 5 }; rotation '180 degrees' }
|
83
|
+
square(:inherits => defaults) { named :rectangle; size { width 50 } }
|
84
|
+
circle(:inherits => [:defaults, :other]) { sides 0; rotation lambda { 'who could possibly tell?' }; fits { pegs { round lambda { "yes" }; square lambda { "no" } } } }
|
85
|
+
polygon { sides 'many'; details { named 'somename'; actual_sides 100; discussion { seems? 'like a lot of damn sides' } } }
|
86
|
+
dafuq? { holy fuck this is some god damn evil fucking black sorcery!; how the hell did he make this happen?; mason is some kind of sorcerer; this is freaking me out man; srsly dude }
|
87
|
+
}
|
88
|
+
|
89
|
+
Shapes.inspect.should == '[some shapes] circle: { color: "blue like the color of the sea before a storm", fits: { pegs: { round: "yes", square: "no" } }, position: { px: 10, py: 20 }, rotation: "who could possibly tell?", sides: 0, size: { height: 200, width: 100 } }, dafuq?: { holy: "fuck this is some god damn evil fucking black sorcery!", how: "the hell did he make this happen?", mason: "is some kind of sorcerer", srsly: "dude", this: "is freaking me out man" }, defaults: { position: { px: 10, py: 20 }, rotation: "90 degrees", size: { height: 200, width: 100 } }, other: { color: "blue like the color of the sea before a storm", sides: 4 }, polygon: { details: { actual_sides: 100, discussion: { seems?: "like a lot of damn sides" }, named: "somename" }, sides: "many" }, square: { named: :rectangle, position: { px: 10, py: 20 }, rotation: "90 degrees", size: { height: 200, width: 50 } }, triangle: { named: :rectangle, position: { px: 10, py: 20 }, rotation: "180 degrees", size: { height: 200, width: 5 } }'
|
90
|
+
Shapes.to_s.should == <<-TEXT
|
91
|
+
[some shapes]
|
92
|
+
|
93
|
+
circle:
|
94
|
+
color: blue like the color of the sea before a storm
|
95
|
+
fits:
|
96
|
+
pegs:
|
97
|
+
round: yes
|
98
|
+
square: no
|
99
|
+
position:
|
100
|
+
px: 10
|
101
|
+
py: 20
|
102
|
+
rotation: who could possibly tell?
|
103
|
+
sides: 0
|
104
|
+
size:
|
105
|
+
height: 200
|
106
|
+
width: 100
|
107
|
+
|
108
|
+
dafuq?:
|
109
|
+
holy: fuck this is some god damn evil fucking black sorcery!
|
110
|
+
how: the hell did he make this happen?
|
111
|
+
mason: is some kind of sorcerer
|
112
|
+
srsly: dude
|
113
|
+
this: is freaking me out man
|
114
|
+
|
115
|
+
defaults:
|
116
|
+
position:
|
117
|
+
px: 10
|
118
|
+
py: 20
|
119
|
+
rotation: 90 degrees
|
120
|
+
size:
|
121
|
+
height: 200
|
122
|
+
width: 100
|
123
|
+
|
124
|
+
other:
|
125
|
+
color: blue like the color of the sea before a storm
|
126
|
+
sides: 4
|
127
|
+
|
128
|
+
polygon:
|
129
|
+
details:
|
130
|
+
actual_sides: 100
|
131
|
+
discussion:
|
132
|
+
seems?: like a lot of damn sides
|
133
|
+
named: somename
|
134
|
+
sides: many
|
135
|
+
|
136
|
+
square:
|
137
|
+
named: rectangle
|
138
|
+
position:
|
139
|
+
px: 10
|
140
|
+
py: 20
|
141
|
+
rotation: 90 degrees
|
142
|
+
size:
|
143
|
+
height: 200
|
144
|
+
width: 50
|
145
|
+
|
146
|
+
triangle:
|
147
|
+
named: rectangle
|
148
|
+
position:
|
149
|
+
px: 10
|
150
|
+
py: 20
|
151
|
+
rotation: 180 degrees
|
152
|
+
size:
|
153
|
+
height: 200
|
154
|
+
width: 5
|
155
|
+
|
156
|
+
TEXT
|
157
|
+
end
|
158
|
+
|
159
|
+
end
|
17
160
|
|
18
161
|
describe ".define" do
|
19
162
|
context "no arguments" do
|
@@ -54,6 +197,7 @@ describe RubyConf do
|
|
54
197
|
inherited_config.city.thing.origin.should == "ocean"
|
55
198
|
end
|
56
199
|
end
|
200
|
+
|
57
201
|
context ":as" do
|
58
202
|
it "creates a global Constant" do
|
59
203
|
subject.define "rails_database", :as => :RailsDatabase do
|
@@ -64,6 +208,7 @@ describe RubyConf do
|
|
64
208
|
::RailsDatabase.production[:password].should_not be_nil
|
65
209
|
end
|
66
210
|
end
|
211
|
+
|
67
212
|
it "can reopen configs" do
|
68
213
|
config = subject.define do
|
69
214
|
godzilla do
|
@@ -77,6 +222,7 @@ describe RubyConf do
|
|
77
222
|
config.godzilla.spines.should == true
|
78
223
|
config.godzilla.awesome.should == true
|
79
224
|
end
|
225
|
+
|
80
226
|
it "returns a named config" do
|
81
227
|
config = subject.define "a_name" do
|
82
228
|
something "hi"
|
@@ -84,14 +230,16 @@ describe RubyConf do
|
|
84
230
|
config.something.should == "hi"
|
85
231
|
subject.a_name.something.should == 'hi'
|
86
232
|
end
|
233
|
+
|
87
234
|
it "can be chained" do
|
88
|
-
subject.define "config", :as => :
|
235
|
+
subject.define "config", :as => :ChainedConfig do
|
89
236
|
love_song (RubyConf.define "love_song" do
|
90
237
|
title "in me all along"
|
91
238
|
end)
|
92
239
|
end
|
93
|
-
|
240
|
+
ChainedConfig.love_song.title.should == 'in me all along'
|
94
241
|
end
|
242
|
+
|
95
243
|
it "can be chained using do blocks instead of RubyConf.define" do
|
96
244
|
subject.define "config", :as => :MyConfig do
|
97
245
|
turtles do
|
@@ -107,6 +255,7 @@ describe RubyConf do
|
|
107
255
|
MyConfig.turtles.mutant.should == true
|
108
256
|
MyConfig.turtles.raphael.mask.should == "red"
|
109
257
|
end
|
258
|
+
|
110
259
|
describe "RubyConf" do
|
111
260
|
it "can access configs using square brackets" do
|
112
261
|
subject.define "config" do
|
@@ -178,7 +327,7 @@ describe RubyConf do
|
|
178
327
|
subject.cake.should respond_to(:skim_milk)
|
179
328
|
end
|
180
329
|
it "our cake has no bees and raises NameError" do
|
181
|
-
lambda do
|
330
|
+
lambda do
|
182
331
|
subject.cake.bees
|
183
332
|
end.should raise_error NameError
|
184
333
|
end
|
metadata
CHANGED
@@ -1,141 +1,137 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: ruby-conf
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 2.0.0
|
5
5
|
prerelease:
|
6
|
-
segments:
|
7
|
-
- 1
|
8
|
-
- 4
|
9
|
-
- 4
|
10
|
-
version: 1.4.4
|
11
6
|
platform: ruby
|
12
|
-
authors:
|
13
|
-
- Curtis Schofield & Hollin Wilkins
|
7
|
+
authors:
|
8
|
+
- Curtis Schofield & Hollin Wilkins & Mason
|
14
9
|
autorequire:
|
15
10
|
bindir: bin
|
16
11
|
cert_chain: []
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
type: :development
|
23
|
-
requirement: &id001 !ruby/object:Gem::Requirement
|
12
|
+
date: 2012-12-20 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: rspec
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
24
17
|
none: false
|
25
|
-
requirements:
|
18
|
+
requirements:
|
26
19
|
- - ~>
|
27
|
-
- !ruby/object:Gem::Version
|
28
|
-
hash: 47
|
29
|
-
segments:
|
30
|
-
- 2
|
31
|
-
- 8
|
32
|
-
- 0
|
20
|
+
- !ruby/object:Gem::Version
|
33
21
|
version: 2.8.0
|
34
|
-
name: rspec
|
35
|
-
version_requirements: *id001
|
36
|
-
prerelease: false
|
37
|
-
- !ruby/object:Gem::Dependency
|
38
22
|
type: :development
|
39
|
-
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
40
25
|
none: false
|
41
|
-
requirements:
|
26
|
+
requirements:
|
42
27
|
- - ~>
|
43
|
-
- !ruby/object:Gem::Version
|
44
|
-
|
45
|
-
|
46
|
-
- 1
|
47
|
-
- 0
|
48
|
-
- 4
|
49
|
-
version: 1.0.4
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: 2.8.0
|
30
|
+
- !ruby/object:Gem::Dependency
|
50
31
|
name: rr
|
51
|
-
|
52
|
-
|
53
|
-
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ~>
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: 1.0.4
|
54
38
|
type: :development
|
55
|
-
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
56
41
|
none: false
|
57
|
-
requirements:
|
42
|
+
requirements:
|
58
43
|
- - ~>
|
59
|
-
- !ruby/object:Gem::Version
|
60
|
-
|
61
|
-
|
62
|
-
- 0
|
63
|
-
- 7
|
64
|
-
version: "0.7"
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: 1.0.4
|
46
|
+
- !ruby/object:Gem::Dependency
|
65
47
|
name: yard
|
66
|
-
|
67
|
-
|
68
|
-
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - ~>
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '0.7'
|
69
54
|
type: :development
|
70
|
-
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
71
57
|
none: false
|
72
|
-
requirements:
|
58
|
+
requirements:
|
73
59
|
- - ~>
|
74
|
-
- !ruby/object:Gem::Version
|
75
|
-
|
76
|
-
|
77
|
-
- 3
|
78
|
-
- 12
|
79
|
-
version: "3.12"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0.7'
|
62
|
+
- !ruby/object:Gem::Dependency
|
80
63
|
name: rdoc
|
81
|
-
|
82
|
-
|
83
|
-
|
64
|
+
requirement: !ruby/object:Gem::Requirement
|
65
|
+
none: false
|
66
|
+
requirements:
|
67
|
+
- - ~>
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '3.12'
|
84
70
|
type: :development
|
85
|
-
|
71
|
+
prerelease: false
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
86
73
|
none: false
|
87
|
-
requirements:
|
74
|
+
requirements:
|
88
75
|
- - ~>
|
89
|
-
- !ruby/object:Gem::Version
|
90
|
-
|
91
|
-
|
92
|
-
- 1
|
93
|
-
- 0
|
94
|
-
- 0
|
95
|
-
version: 1.0.0
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '3.12'
|
78
|
+
- !ruby/object:Gem::Dependency
|
96
79
|
name: bundler
|
97
|
-
|
98
|
-
|
99
|
-
|
80
|
+
requirement: !ruby/object:Gem::Requirement
|
81
|
+
none: false
|
82
|
+
requirements:
|
83
|
+
- - ~>
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
version: 1.0.0
|
100
86
|
type: :development
|
101
|
-
|
87
|
+
prerelease: false
|
88
|
+
version_requirements: !ruby/object:Gem::Requirement
|
102
89
|
none: false
|
103
|
-
requirements:
|
90
|
+
requirements:
|
104
91
|
- - ~>
|
105
|
-
- !ruby/object:Gem::Version
|
106
|
-
|
107
|
-
|
108
|
-
- 1
|
109
|
-
- 8
|
110
|
-
- 3
|
111
|
-
version: 1.8.3
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
version: 1.0.0
|
94
|
+
- !ruby/object:Gem::Dependency
|
112
95
|
name: jeweler
|
113
|
-
|
114
|
-
|
115
|
-
|
96
|
+
requirement: !ruby/object:Gem::Requirement
|
97
|
+
none: false
|
98
|
+
requirements:
|
99
|
+
- - ~>
|
100
|
+
- !ruby/object:Gem::Version
|
101
|
+
version: 1.8.3
|
116
102
|
type: :development
|
117
|
-
|
103
|
+
prerelease: false
|
104
|
+
version_requirements: !ruby/object:Gem::Requirement
|
118
105
|
none: false
|
119
|
-
requirements:
|
120
|
-
- -
|
121
|
-
- !ruby/object:Gem::Version
|
122
|
-
|
123
|
-
|
124
|
-
- 0
|
125
|
-
version: "0"
|
106
|
+
requirements:
|
107
|
+
- - ~>
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: 1.8.3
|
110
|
+
- !ruby/object:Gem::Dependency
|
126
111
|
name: rcov
|
127
|
-
|
112
|
+
requirement: !ruby/object:Gem::Requirement
|
113
|
+
none: false
|
114
|
+
requirements:
|
115
|
+
- - ! '>='
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
type: :development
|
128
119
|
prerelease: false
|
129
|
-
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
none: false
|
122
|
+
requirements:
|
123
|
+
- - ! '>='
|
124
|
+
- !ruby/object:Gem::Version
|
125
|
+
version: '0'
|
126
|
+
description: rubyconf is a ruby configuration dsl that aims to make it simple to write
|
127
|
+
and read configurations for ruby apps without a yaml or xml file
|
130
128
|
email: blazingpair@blazingcloud.net
|
131
129
|
executables: []
|
132
|
-
|
133
130
|
extensions: []
|
134
|
-
|
135
|
-
extra_rdoc_files:
|
131
|
+
extra_rdoc_files:
|
136
132
|
- LICENSE.txt
|
137
133
|
- README.rdoc
|
138
|
-
files:
|
134
|
+
files:
|
139
135
|
- .document
|
140
136
|
- .rspec
|
141
137
|
- .rvmrc
|
@@ -149,39 +145,32 @@ files:
|
|
149
145
|
- ruby-conf.gemspec
|
150
146
|
- spec/lib/ruby-conf_spec.rb
|
151
147
|
- spec/spec_helper.rb
|
152
|
-
has_rdoc: true
|
153
148
|
homepage: http://github.com/blazingpair/ruby-conf
|
154
|
-
licenses:
|
149
|
+
licenses:
|
155
150
|
- MIT
|
156
151
|
post_install_message:
|
157
152
|
rdoc_options: []
|
158
|
-
|
159
|
-
require_paths:
|
153
|
+
require_paths:
|
160
154
|
- lib
|
161
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
155
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
162
156
|
none: false
|
163
|
-
requirements:
|
164
|
-
- -
|
165
|
-
- !ruby/object:Gem::Version
|
166
|
-
|
167
|
-
segments:
|
157
|
+
requirements:
|
158
|
+
- - ! '>='
|
159
|
+
- !ruby/object:Gem::Version
|
160
|
+
version: '0'
|
161
|
+
segments:
|
168
162
|
- 0
|
169
|
-
|
170
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
163
|
+
hash: -2251850668776804598
|
164
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
171
165
|
none: false
|
172
|
-
requirements:
|
173
|
-
- -
|
174
|
-
- !ruby/object:Gem::Version
|
175
|
-
|
176
|
-
segments:
|
177
|
-
- 0
|
178
|
-
version: "0"
|
166
|
+
requirements:
|
167
|
+
- - ! '>='
|
168
|
+
- !ruby/object:Gem::Version
|
169
|
+
version: '0'
|
179
170
|
requirements: []
|
180
|
-
|
181
171
|
rubyforge_project:
|
182
|
-
rubygems_version: 1.
|
172
|
+
rubygems_version: 1.8.24
|
183
173
|
signing_key:
|
184
174
|
specification_version: 3
|
185
175
|
summary: dsl (domain specific language) for config files in ruby
|
186
176
|
test_files: []
|
187
|
-
|