argh 0.0.3 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/argh/collector.rb +1 -6
- data/lib/argh/version.rb +1 -1
- data/spec/examples/basic_spec.rb +2 -6
- metadata +1 -1
data/lib/argh/collector.rb
CHANGED
@@ -10,15 +10,10 @@ module Argh
|
|
10
10
|
end
|
11
11
|
|
12
12
|
def attribute(name, value = nil, &block)
|
13
|
-
attribute = nil
|
14
|
-
if value.is_a?(Symbol)
|
15
|
-
attribute = value
|
16
|
-
value = nil
|
17
|
-
end
|
18
13
|
@attributes << {
|
19
14
|
:name => name,
|
20
15
|
:value => value,
|
21
|
-
:lambda => block || lambda { |i| i.send(
|
16
|
+
:lambda => block || lambda { |i| i.send(name) }
|
22
17
|
}
|
23
18
|
end
|
24
19
|
|
data/lib/argh/version.rb
CHANGED
data/spec/examples/basic_spec.rb
CHANGED
@@ -20,7 +20,7 @@ class BasicExample
|
|
20
20
|
end
|
21
21
|
|
22
22
|
argh 'straight' do
|
23
|
-
attribute :name,
|
23
|
+
attribute :name, :john
|
24
24
|
end
|
25
25
|
|
26
26
|
argh 'lambs' do
|
@@ -28,7 +28,7 @@ class BasicExample
|
|
28
28
|
end
|
29
29
|
|
30
30
|
argh 'symb' do
|
31
|
-
attribute(:the_name,
|
31
|
+
attribute(:the_name, &:name)
|
32
32
|
end
|
33
33
|
|
34
34
|
private
|
@@ -77,8 +77,4 @@ describe Argh::Attributable do
|
|
77
77
|
example.straight.should == '-name \'john\''
|
78
78
|
end
|
79
79
|
|
80
|
-
it 'should be able to specify a symbol instead of a lambda' do
|
81
|
-
example.symb.should == '-the_name \'John Crepezzi\''
|
82
|
-
end
|
83
|
-
|
84
80
|
end
|