slop 3.3.0 → 3.3.1

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 CHANGED
@@ -1,3 +1,8 @@
1
+ 3.3.1 (2012-05-31)
2
+ ------------------
3
+
4
+ * Stop multiple switches from trashing arguments (Conrad Irwin, #66)
5
+
1
6
  3.3.0 (2012-05-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.3.0'
7
+ VERSION = '3.3.1'
8
8
 
9
9
  # The main Error class, all Exception classes inherit from this class.
10
10
  class Error < StandardError; end
@@ -466,8 +466,12 @@ class Slop
466
466
  return
467
467
  end
468
468
 
469
- @trash << index + 1 unless item && item.end_with?("=#{argument}")
470
- option.value = argument
469
+ if argument
470
+ @trash << index + 1 unless item && item.end_with?("=#{argument}")
471
+ option.value = argument
472
+ else
473
+ option.value = option.count > 0
474
+ end
471
475
 
472
476
  if option.match? && !argument.match(option.config[:match])
473
477
  raise InvalidArgumentError, "#{argument} is an invalid argument"
@@ -485,11 +489,11 @@ class Slop
485
489
  #
486
490
  # Returns nothing.
487
491
  def execute_multiple_switches(option, argument, index)
488
- execute_option(option, argument, index)
492
+ execute_option(option, nil, index)
489
493
  argument.split('').each do |key|
490
494
  opt = fetch_option(key)
491
495
  opt.count += 1
492
- execute_option(opt, argument, index, key)
496
+ execute_option(opt, nil, index, key)
493
497
  end
494
498
  end
495
499
 
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'slop'
3
- s.version = '3.3.0'
3
+ s.version = '3.3.1'
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'
@@ -218,6 +218,12 @@ class SlopTest < TestCase
218
218
  assert_equal 'abc123', opts[:f]
219
219
  end
220
220
 
221
+ test "muiltiple_switches should not trash arguments" do
222
+ opts = Slop.new{ on :f; on :b }
223
+ args = opts.parse!(%w'-fb foo')
224
+ assert_equal %w'foo', args
225
+ end
226
+
221
227
  test "setting/getting the banner" do
222
228
  opts = Slop.new :banner => 'foo'
223
229
  assert_equal 'foo', opts.banner
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.3.0
4
+ version: 3.3.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-05-30 00:00:00.000000000 Z
12
+ date: 2012-05-31 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rake
16
- requirement: &70279515453400 !ruby/object:Gem::Requirement
16
+ requirement: &70351938520120 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '0'
22
22
  type: :development
23
23
  prerelease: false
24
- version_requirements: *70279515453400
24
+ version_requirements: *70351938520120
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: minitest
27
- requirement: &70279515450800 !ruby/object:Gem::Requirement
27
+ requirement: &70351938541500 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,7 +32,7 @@ dependencies:
32
32
  version: '0'
33
33
  type: :development
34
34
  prerelease: false
35
- version_requirements: *70279515450800
35
+ version_requirements: *70351938541500
36
36
  description: A simple DSL for gathering options and parsing the command line
37
37
  email: lee@jarvis.co
38
38
  executables: []
@@ -68,7 +68,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
68
68
  version: '0'
69
69
  segments:
70
70
  - 0
71
- hash: -452403334270182101
71
+ hash: 4605818326398820360
72
72
  required_rubygems_version: !ruby/object:Gem::Requirement
73
73
  none: false
74
74
  requirements:
@@ -77,7 +77,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
77
77
  version: '0'
78
78
  segments:
79
79
  - 0
80
- hash: -452403334270182101
80
+ hash: 4605818326398820360
81
81
  requirements: []
82
82
  rubyforge_project:
83
83
  rubygems_version: 1.8.11