slop 3.0.3 → 3.0.4

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGES.md CHANGED
@@ -1,3 +1,8 @@
1
+ 3.0.4 (2012-01-31)
2
+ ------------------
3
+
4
+ * Ensure `option=argument` syntax does not consume following arguments (#55).
5
+
1
6
  3.0.3 (2012-01-30)
2
7
  ------------------
3
8
 
@@ -4,7 +4,7 @@ require 'slop/commands'
4
4
  class Slop
5
5
  include Enumerable
6
6
 
7
- VERSION = '3.0.3'
7
+ VERSION = '3.0.4'
8
8
 
9
9
  # The main Error class, all Exception classes inherit from this class.
10
10
  class Error < StandardError; end
@@ -411,12 +411,12 @@ class Slop
411
411
  raise MissingArgumentError, "#{option.key} expects an argument"
412
412
  end
413
413
 
414
- execute_option(option, argument, index)
414
+ execute_option(option, argument, index, item)
415
415
  elsif option.accepts_optional_argument?
416
416
  argument ||= items.at(index + 1)
417
417
 
418
418
  if argument && argument !~ /\A--?/
419
- execute_option(option, argument, index)
419
+ execute_option(option, argument, index, item)
420
420
  else
421
421
  option.call(nil)
422
422
  end
@@ -447,7 +447,7 @@ class Slop
447
447
  return
448
448
  end
449
449
 
450
- @trash << index + 1
450
+ @trash << index + 1 unless item && item.end_with?("=#{argument}")
451
451
  option.value = argument
452
452
 
453
453
  if option.match? && !argument.match(option.config[:match])
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'slop'
3
- s.version = '3.0.3'
3
+ s.version = '3.0.4'
4
4
  s.summary = 'Option gathering made easy'
5
5
  s.description = 'A simple DSL for gathering options and parsing the command line'
6
6
  s.author = 'Lee Jarvis'
@@ -297,4 +297,11 @@ class SlopTest < TestCase
297
297
  end
298
298
  end
299
299
 
300
+ test "option=value syntax does NOT consume following argument" do
301
+ opts = Slop.new { on :foo=; on 'bar=?' }
302
+ args = %w' --foo=bar baz --bar=zing hello '
303
+ opts.parse!(args)
304
+ assert_equal %w' baz hello ', args
305
+ end
306
+
300
307
  end
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: 3.0.3
4
+ version: 3.0.4
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-01-30 00:00:00.000000000 Z
12
+ date: 2012-01-31 00:00:00.000000000 Z
13
13
  dependencies: []
14
14
  description: A simple DSL for gathering options and parsing the command line
15
15
  email: lee@jarvis.co