slop 2.4.0 → 2.4.1
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGES.md +5 -0
- data/Rakefile +6 -0
- data/lib/slop.rb +19 -7
- data/slop.gemspec +1 -1
- data/test/option_test.rb +3 -0
- metadata +3 -5
- data/.gemtest +0 -0
- data/.yardopts +0 -6
data/CHANGES.md
CHANGED
data/Rakefile
CHANGED
data/lib/slop.rb
CHANGED
@@ -2,7 +2,7 @@ class Slop
|
|
2
2
|
include Enumerable
|
3
3
|
|
4
4
|
# @return [String] The current version string
|
5
|
-
VERSION = '2.4.
|
5
|
+
VERSION = '2.4.1'
|
6
6
|
|
7
7
|
# Slops standard Error class. All exception classes should
|
8
8
|
# inherit from this class
|
@@ -151,12 +151,18 @@ class Slop
|
|
151
151
|
return if value.nil?
|
152
152
|
|
153
153
|
case @argument_type
|
154
|
-
when 'array'
|
155
|
-
|
156
|
-
when '
|
157
|
-
|
158
|
-
when '
|
159
|
-
|
154
|
+
when 'array'
|
155
|
+
arg_value(@argument_value)
|
156
|
+
when 'range'
|
157
|
+
arg_value(value_to_range(value))
|
158
|
+
when 'float'
|
159
|
+
arg_value(value.to_s.to_f)
|
160
|
+
when 'string', 'str'
|
161
|
+
arg_value(value.to_s)
|
162
|
+
when 'symbol', 'sym'
|
163
|
+
arg_value(value.to_s.to_sym)
|
164
|
+
when 'integer', 'int'
|
165
|
+
arg_value(value.to_s.to_i)
|
160
166
|
else
|
161
167
|
value
|
162
168
|
end
|
@@ -222,6 +228,12 @@ class Slop
|
|
222
228
|
|
223
229
|
private
|
224
230
|
|
231
|
+
def arg_value(value)
|
232
|
+
if accepts_optional_argument? || expects_argument?
|
233
|
+
value
|
234
|
+
end
|
235
|
+
end
|
236
|
+
|
225
237
|
def value_to_range(value)
|
226
238
|
case value.to_s
|
227
239
|
when /\A(-?\d+?)(\.\.\.?|-|,)(-?\d+)\z/
|
data/slop.gemspec
CHANGED
data/test/option_test.rb
CHANGED
@@ -94,6 +94,9 @@ class OptionTest < TestCase
|
|
94
94
|
assert_equal nil, option_value(%w/-i/, :i, :as => :float)
|
95
95
|
assert_equal nil, option_value(%w/-i/, :i, :as => :array)
|
96
96
|
assert_equal nil, option_value(%w/-i/, :i, :as => :range)
|
97
|
+
|
98
|
+
assert_equal 1, option_value(%w/-i 1/, :i, :optional => true, :as => :range)
|
99
|
+
assert_equal nil, option_value(%w/-i/, :i, :optional => true, :as => :range)
|
97
100
|
end
|
98
101
|
|
99
102
|
test 'ranges' do
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: slop
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.4.
|
4
|
+
version: 2.4.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: 2011-
|
12
|
+
date: 2011-12-08 00:00:00.000000000Z
|
13
13
|
dependencies: []
|
14
14
|
description: A simple DSL for gathering options and parsing the command line
|
15
15
|
email: lee@jarvis.co
|
@@ -17,9 +17,7 @@ executables: []
|
|
17
17
|
extensions: []
|
18
18
|
extra_rdoc_files: []
|
19
19
|
files:
|
20
|
-
- .gemtest
|
21
20
|
- .gitignore
|
22
|
-
- .yardopts
|
23
21
|
- CHANGES.md
|
24
22
|
- LICENSE
|
25
23
|
- README.md
|
@@ -50,7 +48,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
50
48
|
version: '0'
|
51
49
|
requirements: []
|
52
50
|
rubyforge_project:
|
53
|
-
rubygems_version: 1.8.
|
51
|
+
rubygems_version: 1.8.10
|
54
52
|
signing_key:
|
55
53
|
specification_version: 3
|
56
54
|
summary: Option gathering made easy
|
data/.gemtest
DELETED
File without changes
|