slop 3.0.1 → 3.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/CHANGES.md +7 -2
- data/lib/slop.rb +4 -4
- data/slop.gemspec +1 -1
- data/test/slop_test.rb +6 -0
- metadata +1 -1
data/CHANGES.md
CHANGED
@@ -1,5 +1,10 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
3.0.2 (2012-01-27)
|
2
|
+
------------------
|
3
|
+
|
4
|
+
* Ensure `--option=value` is being evaluated before multiple switches (#52)
|
5
|
+
|
6
|
+
3.0.1 (2012-01-27)
|
7
|
+
------------------
|
3
8
|
|
4
9
|
* Ensure tests run green on 1.8.7
|
5
10
|
* Ensure `:argument => :optional` works with `:option=` format.
|
data/lib/slop.rb
CHANGED
@@ -4,7 +4,7 @@ require 'slop/commands'
|
|
4
4
|
class Slop
|
5
5
|
include Enumerable
|
6
6
|
|
7
|
-
VERSION = '3.0.
|
7
|
+
VERSION = '3.0.2'
|
8
8
|
|
9
9
|
# The main Error class, all Exception classes inherit from this class.
|
10
10
|
class Error < StandardError; end
|
@@ -403,9 +403,7 @@ class Slop
|
|
403
403
|
@trash << index
|
404
404
|
@triggered_options << option
|
405
405
|
|
406
|
-
if
|
407
|
-
execute_multiple_switches(option, argument, index)
|
408
|
-
elsif option.expects_argument?
|
406
|
+
if option.expects_argument?
|
409
407
|
argument ||= items.at(index + 1)
|
410
408
|
|
411
409
|
if !argument || argument =~ /\A--?[a-zA-Z][a-zA-Z0-9_-]*\z/
|
@@ -421,6 +419,8 @@ class Slop
|
|
421
419
|
else
|
422
420
|
option.call(nil)
|
423
421
|
end
|
422
|
+
elsif config[:multiple_switches] && argument
|
423
|
+
execute_multiple_switches(option, argument, index)
|
424
424
|
else
|
425
425
|
option.call(nil)
|
426
426
|
end
|
data/slop.gemspec
CHANGED
data/test/slop_test.rb
CHANGED
@@ -43,6 +43,12 @@ class SlopTest < TestCase
|
|
43
43
|
assert_equal [nil, 'foo', nil, {:optional_argument=>true}], build_option('foo=?')
|
44
44
|
end
|
45
45
|
|
46
|
+
test "parsing option=value" do
|
47
|
+
slop = Slop.new { on :foo= }
|
48
|
+
slop.parse %w' --foo=bar '
|
49
|
+
assert_equal 'bar', slop[:foo]
|
50
|
+
end
|
51
|
+
|
46
52
|
test "fetch_option" do
|
47
53
|
slop = Slop.new
|
48
54
|
opt1 = slop.on :f, :foo
|