main 5.1.0 → 5.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/main.rb +1 -1
- data/lib/main/parameter.rb +12 -0
- data/main.gemspec +1 -1
- data/test/main_test.rb +30 -0
- metadata +2 -2
data/lib/main.rb
CHANGED
data/lib/main/parameter.rb
CHANGED
@@ -128,10 +128,22 @@ module Main
|
|
128
128
|
values << value
|
129
129
|
end
|
130
130
|
|
131
|
+
def set(*values)
|
132
|
+
self.values.replace(values)
|
133
|
+
end
|
134
|
+
|
135
|
+
def get
|
136
|
+
self.values.first
|
137
|
+
end
|
138
|
+
|
131
139
|
def value
|
132
140
|
values.first
|
133
141
|
end
|
134
142
|
|
143
|
+
def value=(value)
|
144
|
+
set(value)
|
145
|
+
end
|
146
|
+
|
135
147
|
def argument_none?
|
136
148
|
argument.nil?
|
137
149
|
end
|
data/main.gemspec
CHANGED
data/test/main_test.rb
CHANGED
@@ -456,6 +456,36 @@ class T < Test::Unit::TestCase
|
|
456
456
|
}
|
457
457
|
}
|
458
458
|
end
|
459
|
+
|
460
|
+
# manual parmeter setting
|
461
|
+
#
|
462
|
+
def test_0272
|
463
|
+
assert_nothing_raised{
|
464
|
+
h = {}
|
465
|
+
|
466
|
+
main(){
|
467
|
+
argument(:foo){ optional }
|
468
|
+
run do
|
469
|
+
o = param['foo']
|
470
|
+
h[nil] = o.value
|
471
|
+
|
472
|
+
o.set 'bar'
|
473
|
+
h['bar'] = o.value
|
474
|
+
|
475
|
+
o.set ['bar']
|
476
|
+
h[['bar']] = o.value
|
477
|
+
|
478
|
+
o.set 'foo', 'bar'
|
479
|
+
h['foo'] = o.value
|
480
|
+
h[['foo', 'bar']] = o.values
|
481
|
+
end
|
482
|
+
}
|
483
|
+
|
484
|
+
h.each do |expected, actual|
|
485
|
+
assert_equal expected, actual
|
486
|
+
end
|
487
|
+
}
|
488
|
+
end
|
459
489
|
|
460
490
|
# usage
|
461
491
|
#
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: main
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 5.1.
|
4
|
+
version: 5.1.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-11-06 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: chronic
|