slop 2.4.3 → 2.4.4

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGES.md CHANGED
@@ -1,5 +1,13 @@
1
- HEAD
2
- ----
1
+ 2.4.4 (2012-02-07)
2
+ ------------------
3
+
4
+ * Ensure options taking arguments to not parsing an argument which
5
+ is an option (#56)
6
+ * Ensure `:as => Range` returns a type of Range even if the value looks
7
+ like an Integer (#48)
8
+
9
+ 2.4.3 (2012-01-16)
10
+ ------------------
3
11
 
4
12
  * Allow the `:as` option to accept an object responding to :call for
5
13
  custom type conversions (#45)
data/LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2011 Lee Jarvis
1
+ Copyright (c) 2012 Lee Jarvis
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining
4
4
  a copy of this software and associated documentation files (the
data/README.md CHANGED
@@ -3,6 +3,9 @@ Slop
3
3
 
4
4
  Slop is a simple, lightweight option parser with an easy to remember syntax and friendly API.
5
5
 
6
+ Note that this is the `v2` branch. If you are looking for version 3 of Slop
7
+ please check out the [master branch](https://github.com/injekt/slop).
8
+
6
9
  Installation
7
10
  ------------
8
11
 
@@ -38,7 +41,7 @@ opts[:age] #=> nil
38
41
  ```
39
42
 
40
43
  For more information about creating options, see the
41
- [Creating Options](https://github.com/injekt/slop/wiki/Creating-Options)
44
+ [Creating Options](https://github.com/injekt/slop/wiki/Creating-Options---v2)
42
45
  wiki page.
43
46
 
44
47
  You can also return your options as a Hash
@@ -228,7 +231,7 @@ opts[:people] #=> ['lee', 'john', 'bill']
228
231
  ```
229
232
 
230
233
  Slop supports a few styles of list parsing. Check out
231
- [this wiki page](https://github.com/injekt/slop/wiki/Lists) for more info.
234
+ [this wiki page](https://github.com/injekt/slop/wiki/Lists---v2) for more info.
232
235
 
233
236
  Strict Mode
234
237
  -----------
@@ -248,7 +251,7 @@ Check out the following wiki pages for more features:
248
251
 
249
252
  * [Ranges](https://github.com/injekt/slop/wiki/Ranges)
250
253
  * [Auto Create](https://github.com/injekt/slop/wiki/Auto-Create)
251
- * [Commands](https://github.com/injekt/slop/wiki/Commands)
254
+ * [Commands](https://github.com/injekt/slop/wiki/Commands---v2)
252
255
 
253
256
  Woah woah, why you hating on OptionParser?
254
257
  ------------------------------------------
data/Rakefile CHANGED
@@ -3,10 +3,11 @@ begin
3
3
  rescue LoadError
4
4
  end
5
5
 
6
- desc 'Run the test suite'
7
- task :test do
8
- $:.unshift './test'
9
- Dir.glob("test/*_test.rb").each { |test| require "./#{test}" }
6
+ require 'rake/testtask'
7
+
8
+ Rake::TestTask.new do |t|
9
+ t.libs << 'test'
10
+ t.test_files = Dir['test/*_test.rb']
10
11
  end
11
12
 
12
13
  task :default => :test
@@ -2,7 +2,7 @@ class Slop
2
2
  include Enumerable
3
3
 
4
4
  # @return [String] The current version string
5
- VERSION = '2.4.3'
5
+ VERSION = '2.4.4'
6
6
 
7
7
  # Slops standard Error class. All exception classes should
8
8
  # inherit from this class
@@ -243,7 +243,7 @@ class Slop
243
243
  when /\A(-?\d+?)(\.\.\.?|-|,)(-?\d+)\z/
244
244
  Range.new($1.to_i, $3.to_i, $2 == '...')
245
245
  when /\A-?\d+\z/
246
- value.to_i
246
+ Range.new(value.to_i, value.to_i)
247
247
  else
248
248
  value
249
249
  end
@@ -840,7 +840,7 @@ class Slop
840
840
  raise MissingArgumentError, "'#{option.key}' expects an argument, none given"
841
841
  end
842
842
 
843
- if argument
843
+ if argument && argument !~ /^--?[a-zA-Z_-]+/
844
844
  if option.match and not argument.match(option.match)
845
845
  raise InvalidArgumentError, "'#{argument}' does not match #{option.match.inspect}"
846
846
  end
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'slop'
3
- s.version = '2.4.3'
3
+ s.version = '2.4.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'
@@ -98,7 +98,6 @@ class OptionTest < TestCase
98
98
  assert_equal nil, option_value(%w/-i/, :i, :as => :array)
99
99
  assert_equal nil, option_value(%w/-i/, :i, :as => :range)
100
100
 
101
- assert_equal 1, option_value(%w/-i 1/, :i, :optional => true, :as => :range)
102
101
  assert_equal nil, option_value(%w/-i/, :i, :optional => true, :as => :range)
103
102
  end
104
103
 
@@ -114,7 +113,8 @@ class OptionTest < TestCase
114
113
  # return value.to_i if the value is /\A\d+\z/
115
114
  # maybe this should raise if Slop#strict?
116
115
  assert_equal "1abc10", option_value(%w/-r 1abc10/, :r, true, :as => Range)
117
- assert_equal 1, option_value(%w/-r 1/, :r, true, :as => Range)
116
+ assert_equal (1..1), option_value(%w/-r 1/, :r, true, :as => Range)
117
+ assert_equal (2..2), option_value(%w/-r 2/, :r, true, :as => Range)
118
118
  end
119
119
 
120
120
  test 'printing options' do
@@ -593,4 +593,10 @@ class SlopTest < TestCase
593
593
  Slop.parse!(items)
594
594
  assert_equal %w(-1), items
595
595
  end
596
+
597
+ test "options taking arguments should ignore argument that look like options (wut?)" do
598
+ opts = Slop.new { on :v; on :foo, :optional => true, :default => 5, :as => Integer }
599
+ opts.parse %w[ -c -v ]
600
+ assert_equal 5, opts[:foo]
601
+ end
596
602
  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: 2.4.3
4
+ version: 2.4.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-16 00:00:00.000000000 Z
12
+ date: 2012-02-07 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