simpleconf 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/simpleconf/conf.rb +6 -1
- data/lib/simpleconf/version.rb +1 -1
- data/spec/simpleconf_spec.rb +34 -0
- metadata +8 -8
data/lib/simpleconf/conf.rb
CHANGED
@@ -35,7 +35,12 @@ module SimpleConf
|
|
35
35
|
fail "Other needs to be a SimpleConf::Conf" unless other.is_a? Conf
|
36
36
|
check_and_change_overrides(other)
|
37
37
|
self.__init_only__ = other.__init_only__
|
38
|
-
|
38
|
+
if other.__instance_block__.is_a?(Proc)
|
39
|
+
self.instance_eval(&other.__instance_block__)
|
40
|
+
else
|
41
|
+
self.instance_eval(other.__instance_block__)
|
42
|
+
end
|
43
|
+
|
39
44
|
__vars__.rmerge!(other.__vars__)
|
40
45
|
nil
|
41
46
|
end
|
data/lib/simpleconf/version.rb
CHANGED
data/spec/simpleconf_spec.rb
CHANGED
@@ -394,6 +394,40 @@ describe SimpleConf do
|
|
394
394
|
@default.tree.ants.home.sq_feet.should == 5000
|
395
395
|
end
|
396
396
|
|
397
|
+
it "should merge! a SimpleConf::Conf generated from a string" do
|
398
|
+
str = <<-EOS
|
399
|
+
port 90
|
400
|
+
socket "haha"
|
401
|
+
tree {
|
402
|
+
leafs 60, :override => false
|
403
|
+
bugs true
|
404
|
+
ants {
|
405
|
+
fast false
|
406
|
+
home {
|
407
|
+
big true
|
408
|
+
sq_feet 5000
|
409
|
+
}
|
410
|
+
}
|
411
|
+
}
|
412
|
+
|
413
|
+
EOS
|
414
|
+
@new = SimpleConf.build_from_string(str)
|
415
|
+
|
416
|
+
@default.merge!(@new)
|
417
|
+
|
418
|
+
@default.should be_an_instance_of(SimpleConf::Conf)
|
419
|
+
|
420
|
+
@default.server.should == "localhost"
|
421
|
+
@default.port.should == 90
|
422
|
+
@default.socket.should == "haha"
|
423
|
+
@default.tree.bugs.should == true
|
424
|
+
@default.tree.leafs.should == 60
|
425
|
+
@default.tree.height.should == 50
|
426
|
+
@default.tree.ants.big.should == false
|
427
|
+
@default.tree.ants.home.sq_feet.should == 5000
|
428
|
+
|
429
|
+
end
|
430
|
+
|
397
431
|
it "should merge a SimpleConf::Conf" do
|
398
432
|
|
399
433
|
new_conf = @default.merge(@new)
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: simpleconf
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2011-07-
|
12
|
+
date: 2011-07-30 00:00:00.000000000Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: blankslate
|
16
|
-
requirement: &
|
16
|
+
requirement: &2154712360 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *2154712360
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: rake
|
27
|
-
requirement: &
|
27
|
+
requirement: &2154711940 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: '0'
|
33
33
|
type: :development
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *2154711940
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: rspec
|
38
|
-
requirement: &
|
38
|
+
requirement: &2154711520 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ! '>='
|
@@ -43,7 +43,7 @@ dependencies:
|
|
43
43
|
version: '0'
|
44
44
|
type: :development
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *2154711520
|
47
47
|
description: Simple Configuration DSL that supports merging, locking and more.
|
48
48
|
email:
|
49
49
|
- ft.mikelewis@gmail.com
|