ruby-conf 2.2.1 → 2.3.0
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/lib/ruby-conf.rb +16 -5
- data/ruby-conf.gemspec +1 -1
- data/spec/lib/ruby-conf_spec.rb +13 -7
- metadata +2 -2
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.
|
1
|
+
2.3.0
|
data/lib/ruby-conf.rb
CHANGED
@@ -28,7 +28,7 @@ class RubyConf < BasicObject
|
|
28
28
|
self
|
29
29
|
end
|
30
30
|
|
31
|
-
def [](name, args
|
31
|
+
def [](name, *args)
|
32
32
|
value = @__rc_attributes[name.to_sym]
|
33
33
|
if value.is_a?(Proc)
|
34
34
|
args += [nil] * (value.arity.abs - args.size) if value.arity.abs > args.size
|
@@ -67,8 +67,10 @@ class RubyConf < BasicObject
|
|
67
67
|
end
|
68
68
|
end
|
69
69
|
|
70
|
-
def method_missing(
|
70
|
+
def method_missing(method_name, *args, &block)
|
71
|
+
name, modifier = method_name.to_s.match(/^(?<name>.*?)(?<modifier>[?!])?$/).captures
|
71
72
|
name = name.to_sym
|
73
|
+
|
72
74
|
options = args.last.is_a?(Hash) ? args.last : {}
|
73
75
|
|
74
76
|
if block_given?
|
@@ -92,7 +94,16 @@ class RubyConf < BasicObject
|
|
92
94
|
|
93
95
|
else
|
94
96
|
|
95
|
-
|
97
|
+
if @__rc_locked && args.size == 0 && !@__rc_attributes.key?(name)
|
98
|
+
return case modifier
|
99
|
+
when '!'
|
100
|
+
super
|
101
|
+
when '?'
|
102
|
+
false
|
103
|
+
else
|
104
|
+
nil
|
105
|
+
end
|
106
|
+
end
|
96
107
|
|
97
108
|
if !@__rc_attributes.key?(name) && (args.size == 0 || args.first.is_a?(Magic))
|
98
109
|
str = name.to_s
|
@@ -106,10 +117,10 @@ class RubyConf < BasicObject
|
|
106
117
|
end
|
107
118
|
|
108
119
|
if args.empty?
|
109
|
-
self[name]
|
120
|
+
modifier == '?' ? !!self[name] : self[name]
|
110
121
|
else
|
111
122
|
args = args.size == 1 ? args.first : args
|
112
|
-
(@__rc_locked && __rc_attributes[name.to_sym].is_a?(Proc)) ? self[name, args] : self[name] = args
|
123
|
+
(@__rc_locked && __rc_attributes[name.to_sym].is_a?(Proc)) ? self[name, *args] : self[name] = args
|
113
124
|
end
|
114
125
|
end
|
115
126
|
end
|
data/ruby-conf.gemspec
CHANGED
@@ -5,7 +5,7 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = "ruby-conf"
|
8
|
-
s.version = "2.
|
8
|
+
s.version = "2.3.0"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Curtis Schofield & Hollin Wilkins & Mason"]
|
data/spec/lib/ruby-conf_spec.rb
CHANGED
@@ -106,7 +106,7 @@ describe RubyConf do
|
|
106
106
|
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 }
|
107
107
|
}
|
108
108
|
|
109
|
-
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
|
109
|
+
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 } }'
|
110
110
|
Shapes.to_s.should == <<-TEXT
|
111
111
|
[some shapes]
|
112
112
|
|
@@ -125,9 +125,9 @@ circle:
|
|
125
125
|
height: 200
|
126
126
|
width: 100
|
127
127
|
|
128
|
-
dafuq
|
129
|
-
holy: fuck this is some god damn evil fucking black sorcery
|
130
|
-
how: the hell did he make this happen
|
128
|
+
dafuq:
|
129
|
+
holy: fuck this is some god damn evil fucking black sorcery
|
130
|
+
how: the hell did he make this happen
|
131
131
|
mason: is some kind of sorcerer
|
132
132
|
srsly: dude
|
133
133
|
this: is freaking me out man
|
@@ -149,7 +149,7 @@ polygon:
|
|
149
149
|
details:
|
150
150
|
actual_sides: 100
|
151
151
|
discussion:
|
152
|
-
seems
|
152
|
+
seems: like a lot of damn sides
|
153
153
|
named: somename
|
154
154
|
sides: many
|
155
155
|
|
@@ -346,11 +346,17 @@ TEXT
|
|
346
346
|
it "responds to skim_milk" do
|
347
347
|
subject.cake.should respond_to(:skim_milk)
|
348
348
|
end
|
349
|
-
it "
|
349
|
+
it "can indicate the presence of an attribute when ending in ? and raises error for !" do
|
350
|
+
subject.cake.bees.should == nil
|
351
|
+
subject.cake.flour?.should be_true
|
352
|
+
subject.cake.bees?.should be_false
|
353
|
+
|
350
354
|
lambda do
|
351
|
-
subject.cake.bees
|
355
|
+
subject.cake.bees!
|
352
356
|
end.should raise_error NameError
|
357
|
+
|
353
358
|
end
|
359
|
+
|
354
360
|
end
|
355
361
|
end
|
356
362
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ruby-conf
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.3.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -112,7 +112,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
112
112
|
version: '0'
|
113
113
|
segments:
|
114
114
|
- 0
|
115
|
-
hash:
|
115
|
+
hash: -3375656081623008669
|
116
116
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
117
117
|
none: false
|
118
118
|
requirements:
|