slop 4.7.0 → 4.9.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.
- checksums.yaml +4 -4
- data/.travis.yml +9 -4
- data/CHANGELOG.md +44 -0
- data/README.md +9 -90
- data/lib/slop.rb +2 -2
- data/lib/slop/options.rb +8 -8
- data/lib/slop/parser.rb +1 -2
- data/lib/slop/types.rb +11 -3
- data/test/option_test.rb +2 -2
- data/test/options_test.rb +13 -2
- data/test/parser_test.rb +10 -0
- data/test/slop_test.rb +10 -0
- data/test/types_test.rb +60 -2
- metadata +6 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c7b0c61e7c1636499757933c40267cb03c8762eeddc928ed49859de31eae21ab
|
4
|
+
data.tar.gz: a3dcbf06cb7af2ab4edac0664de185553781a59137fdf8602986ef92cb86d3a9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a4a7a0c057d34ef83972cf56ccda260af5b349adc0c91922898cee4d2b7841d6e5bc8a31b1a83477a2b0404853de053250a34de2e27a4a8d07657bd157faa703
|
7
|
+
data.tar.gz: 96d2291b6b6504aceb7485f79ae3f035fdfa3b8a0aa8a7c84fb41e620b30f6ff5e8903b6c1c57e00cd855ea1fe1c54fac0629fde8a56cde5c816927637d4fa20
|
data/.travis.yml
CHANGED
@@ -13,12 +13,17 @@ rvm:
|
|
13
13
|
- 2.1
|
14
14
|
- 2.2
|
15
15
|
- 2.3.4
|
16
|
-
- 2.4.
|
17
|
-
- 2.5.
|
18
|
-
- 2.6.
|
19
|
-
-
|
16
|
+
- 2.4.10
|
17
|
+
- 2.5.9
|
18
|
+
- 2.6.7
|
19
|
+
- 2.7.3
|
20
|
+
- 3.0.1
|
21
|
+
- jruby-9.2.17.0
|
20
22
|
- jruby-head
|
21
23
|
- ruby-head
|
24
|
+
- truffleruby-head
|
25
|
+
jdk:
|
26
|
+
- openjdk8
|
22
27
|
notifications:
|
23
28
|
email:
|
24
29
|
on_success: change
|
data/CHANGELOG.md
CHANGED
@@ -1,12 +1,56 @@
|
|
1
1
|
Changelog
|
2
2
|
=========
|
3
3
|
|
4
|
+
v4.9.1 (2021-05-28)
|
5
|
+
-------------------
|
6
|
+
|
7
|
+
Bug fixes:
|
8
|
+
* Fixed a bug where `flag=arg` syntax would raise an error when an
|
9
|
+
empty value was passed. [#266](https://github.com/leejarvis/slop/issues/266)
|
10
|
+
|
11
|
+
v4.9.0 (2021-05-11)
|
12
|
+
-------------------
|
13
|
+
|
14
|
+
Features:
|
15
|
+
* Add SymbolOption [#263](https://github.com/leejarvis/slop/pull/263)
|
16
|
+
|
17
|
+
Bug fixes:
|
18
|
+
* Use `+=` over `<<` to handle frozen string literals. [255](https://github.com/leejarvis/slop/pull/255)
|
19
|
+
|
20
|
+
v4.8.2 (2020-07-10)
|
21
|
+
-------------------
|
22
|
+
|
23
|
+
Bug fixes:
|
24
|
+
* Fix bug where separator position was messed up if using `help: false`
|
25
|
+
[#253](https://github.com/leejarvis/slop/issues/253)
|
26
|
+
|
27
|
+
v4.8.1 (2020-03-31)
|
28
|
+
-------------------
|
29
|
+
|
30
|
+
Bug fixes:
|
31
|
+
* Fix keyword argument warning. [#251](https://github.com/leejarvis/slop/pull/251)
|
32
|
+
|
33
|
+
|
34
|
+
v4.8.0 (2020-01-17)
|
35
|
+
-------------------
|
36
|
+
|
37
|
+
Features:
|
38
|
+
* Add support for prefixing integer values with `+` character
|
39
|
+
[#243](https://github.com/leejarvis/slop/pull/243) (Juha Ylitalo)
|
40
|
+
* Add support for parsing floats with scientific notation
|
41
|
+
[#250](https://github.com/leejarvis/slop/pull/250) (Hansuk Hong)
|
42
|
+
|
43
|
+
Maintenance:
|
44
|
+
* Add 2.7.0 to CI and fix warnings
|
45
|
+
[#248](https://github.com/leejarvis/slop/pull/248) (Juha Ylitalo, Andrew Kane)
|
46
|
+
|
4
47
|
v4.7.0 (2019-06-29)
|
5
48
|
-------------------
|
6
49
|
|
7
50
|
Features:
|
8
51
|
* Add `Slop::Result#fetch`. It returns the value of given option, or raises an error if given option is not present. [#232](https://github.com/leejarvis/slop/pull/232) ([Giovanni Benussi](https://github.com/giovannibenussi))
|
9
52
|
* Adding a separator without passing any arguments now creates a separator with the empty string. [#238](https://github.com/leejarvis/slop/pull/238) ([Teemu Matilainen](https://github.com/tmatilai))
|
53
|
+
|
10
54
|
Bug fixes
|
11
55
|
* Ensure non-string option types have their flags consumed properly [#241] (Sutou Kouhei)
|
12
56
|
|
data/README.md
CHANGED
@@ -3,9 +3,6 @@ Slop
|
|
3
3
|
|
4
4
|
Slop is a simple option parser with an easy to remember syntax and friendly API.
|
5
5
|
|
6
|
-
Version 4 of Slop is aimed at Ruby 2.0 or later. Please use
|
7
|
-
[Version 3](https://github.com/leejarvis/slop/tree/v3) for Ruby 1.9 support.
|
8
|
-
|
9
6
|
[](http://travis-ci.org/leejarvis/slop)
|
10
7
|
|
11
8
|
Installation
|
@@ -21,6 +18,7 @@ opts = Slop.parse do |o|
|
|
21
18
|
o.string '-h', '--host', 'a hostname'
|
22
19
|
o.integer '--port', 'custom port', default: 80
|
23
20
|
o.string '-l', '--login', required: true
|
21
|
+
o.symbol '-m', '--method', default: :get
|
24
22
|
o.bool '-v', '--verbose', 'enable verbose mode'
|
25
23
|
o.bool '-q', '--quiet', 'suppress output (quiet mode)'
|
26
24
|
o.bool '-c', '--check-ssl-certificate', 'check SSL certificate for host'
|
@@ -30,15 +28,16 @@ opts = Slop.parse do |o|
|
|
30
28
|
end
|
31
29
|
end
|
32
30
|
|
33
|
-
ARGV #=> -v --login alice --host 192.168.0.1 --check-ssl-certificate
|
31
|
+
ARGV #=> -v --login alice --host 192.168.0.1 -m post --check-ssl-certificate
|
34
32
|
|
35
33
|
opts[:host] #=> 192.168.0.1
|
36
34
|
opts[:login] #=> alice
|
35
|
+
opts[:method] #=> :post
|
37
36
|
opts.verbose? #=> true
|
38
37
|
opts.quiet? #=> false
|
39
38
|
opts.check_ssl_certificate? #=> true
|
40
39
|
|
41
|
-
opts.to_hash #=> { host: "192.168.0.1", login: "alice",
|
40
|
+
opts.to_hash #=> { host: "192.168.0.1", port: 80, login: "alice", method: :post, verbose: true, quiet: false, check_ssl_certificate: true }
|
42
41
|
```
|
43
42
|
|
44
43
|
Note that the block we've added to the `--version` flag will be executed
|
@@ -59,6 +58,7 @@ o.integer #=> Slop::IntegerOption, expects an argument, aliased to IntOption
|
|
59
58
|
o.float #=> Slop::FloatOption, expects an argument
|
60
59
|
o.array #=> Slop::ArrayOption, expects an argument
|
61
60
|
o.regexp #=> Slop::RegexpOption, expects an argument
|
61
|
+
o.symbol #=> Slop::SymbolOption, expects an argument
|
62
62
|
o.null #=> Slop::NullOption, no argument and ignored from `to_hash`
|
63
63
|
o.on #=> alias for o.null
|
64
64
|
```
|
@@ -135,9 +135,11 @@ opts = Slop.parse do |o|
|
|
135
135
|
o.array '--files', 'a list of files', delimiter: ','
|
136
136
|
end
|
137
137
|
|
138
|
-
#
|
138
|
+
# Both of these will return o[:files] as ["foo.txt", "bar.rb"]:
|
139
139
|
# --files foo.txt,bar.rb
|
140
140
|
# --files foo.txt --files bar.rb
|
141
|
+
# This will return o[:files] as []:
|
142
|
+
# --files ""
|
141
143
|
```
|
142
144
|
|
143
145
|
If you want to disable the built-in string-splitting, set the delimiter to
|
@@ -275,87 +277,4 @@ end
|
|
275
277
|
Commands
|
276
278
|
--------
|
277
279
|
|
278
|
-
|
279
|
-
You can use version 3 of Slop (see `v3` branch).
|
280
|
-
|
281
|
-
Upgrading from version 3
|
282
|
-
------------------------
|
283
|
-
|
284
|
-
Slop v4 is not backwards compatible. The code has been completely rewritten.
|
285
|
-
If you're already using version 3 you *have* to update your code to use version 4.
|
286
|
-
Here's an overview of the large changes:
|
287
|
-
|
288
|
-
#### No more `instance_eval`
|
289
|
-
|
290
|
-
Before:
|
291
|
-
|
292
|
-
```ruby
|
293
|
-
Slop.parse do
|
294
|
-
on 'v', 'version' do
|
295
|
-
puts VERSION
|
296
|
-
end
|
297
|
-
end
|
298
|
-
```
|
299
|
-
|
300
|
-
After:
|
301
|
-
|
302
|
-
```ruby
|
303
|
-
Slop.parse do |o|
|
304
|
-
o.on '-v', '--version' do
|
305
|
-
puts VERSION
|
306
|
-
end
|
307
|
-
end
|
308
|
-
```
|
309
|
-
|
310
|
-
#### No more `as` for option types
|
311
|
-
|
312
|
-
Instead, the type is declared in the method call. Before:
|
313
|
-
|
314
|
-
```ruby
|
315
|
-
on 'port=', as: Integer
|
316
|
-
```
|
317
|
-
|
318
|
-
After:
|
319
|
-
|
320
|
-
```ruby
|
321
|
-
o.int '--port' # or integer
|
322
|
-
```
|
323
|
-
|
324
|
-
See the custom types section of the document.
|
325
|
-
|
326
|
-
#### No more trailing `=`
|
327
|
-
|
328
|
-
Instead, the "does this option expect an argument?" question is answered by
|
329
|
-
the option type (i.e `on` and `bool` options do not expect arguments, all
|
330
|
-
others do). They handle type conversion, too.
|
331
|
-
|
332
|
-
#### Hyphens are required
|
333
|
-
|
334
|
-
This was a hard decision to make, but you must provide prefixed hyphens when
|
335
|
-
declaring your flags. This improves the implementation nicer and makes things
|
336
|
-
much less ambiguous, which leads to less error prone code. It also means you
|
337
|
-
can easily support single hyphen prefix for a long flag, i.e `-hostname` which
|
338
|
-
you could not do before. It also means you can provide infinite flag aliases:
|
339
|
-
`o.string '-f', '-x', '--foo', '--bar', 'this is insane'`
|
340
|
-
|
341
|
-
#### Strict is now on by default
|
342
|
-
|
343
|
-
v3 had a `strict` option. v4 has no such option. To suppress errors you can
|
344
|
-
instead provide the `suppress_errors: true` option to Slop.
|
345
|
-
|
346
|
-
#### No more parse!
|
347
|
-
|
348
|
-
Where v3 has both `Slop.parse` and `Slop.parse!`, v4 only has `parse`. The
|
349
|
-
former was used to decide whether Slop should or should not mutate the
|
350
|
-
original args (usually ARGV). This is almost never what you want, and it
|
351
|
-
can lead to confusion. Instead, `Slop::Result` provides an `arguments`
|
352
|
-
methods:
|
353
|
-
|
354
|
-
```ruby
|
355
|
-
opts = Slop.parse do |o|
|
356
|
-
o.string '--hostname', '...'
|
357
|
-
end
|
358
|
-
|
359
|
-
# ARGV is "hello --hostname foo bar"
|
360
|
-
p opts.arguments #=> ["hello", "bar"]
|
361
|
-
```
|
280
|
+
Slop not longer has built in support for git-style subcommands.
|
data/lib/slop.rb
CHANGED
@@ -6,7 +6,7 @@ require 'slop/types'
|
|
6
6
|
require 'slop/error'
|
7
7
|
|
8
8
|
module Slop
|
9
|
-
VERSION = '4.
|
9
|
+
VERSION = '4.9.1'
|
10
10
|
|
11
11
|
# Parse an array of options (defaults to ARGV). Accepts an
|
12
12
|
# optional hash of configuration options and block.
|
@@ -20,7 +20,7 @@ module Slop
|
|
20
20
|
#
|
21
21
|
# Returns a Slop::Result.
|
22
22
|
def self.parse(items = ARGV, **config, &block)
|
23
|
-
Options.new(config, &block).parse(items)
|
23
|
+
Options.new(**config, &block).parse(items)
|
24
24
|
end
|
25
25
|
|
26
26
|
# Example:
|
data/lib/slop/options.rb
CHANGED
@@ -24,12 +24,12 @@ module Slop
|
|
24
24
|
# The String banner prefixed to the help string.
|
25
25
|
attr_accessor :banner
|
26
26
|
|
27
|
-
def initialize(**config)
|
27
|
+
def initialize(**config, &block)
|
28
28
|
@options = []
|
29
29
|
@separators = []
|
30
30
|
@banner = config[:banner].is_a?(String) ? config[:banner] : config.fetch(:banner, "usage: #{$0} [options]")
|
31
31
|
@config = DEFAULT_CONFIG.merge(config)
|
32
|
-
@parser = Parser.new(self,
|
32
|
+
@parser = Parser.new(self, **@config)
|
33
33
|
|
34
34
|
yield self if block_given?
|
35
35
|
end
|
@@ -52,7 +52,7 @@ module Slop
|
|
52
52
|
desc = flags.pop unless flags.last.start_with?('-')
|
53
53
|
config = self.config.merge(config)
|
54
54
|
klass = Slop.string_to_option_class(config[:type].to_s)
|
55
|
-
option = klass.new(flags, desc, config, &block)
|
55
|
+
option = klass.new(flags, desc, **config, &block)
|
56
56
|
|
57
57
|
add_option option
|
58
58
|
end
|
@@ -82,7 +82,7 @@ module Slop
|
|
82
82
|
def method_missing(name, *args, **config, &block)
|
83
83
|
if respond_to_missing?(name)
|
84
84
|
config[:type] = name
|
85
|
-
on(*args, config, &block)
|
85
|
+
on(*args, **config, &block)
|
86
86
|
else
|
87
87
|
super
|
88
88
|
end
|
@@ -102,17 +102,17 @@ module Slop
|
|
102
102
|
str = config[:banner] ? "#{banner}\n" : ""
|
103
103
|
len = longest_flag_length
|
104
104
|
|
105
|
-
options.select
|
105
|
+
options.select.each_with_index.sort_by{ |o,i| [o.tail, i] }.each do |opt, i|
|
106
106
|
# use the index to fetch an associated separator
|
107
107
|
if sep = separators[i]
|
108
|
-
str
|
108
|
+
str += "#{sep}\n"
|
109
109
|
end
|
110
110
|
|
111
|
-
str
|
111
|
+
str += "#{prefix}#{opt.to_s(offset: len)}\n" if opt.help?
|
112
112
|
end
|
113
113
|
|
114
114
|
if sep = separators[options.size]
|
115
|
-
str
|
115
|
+
str += "#{sep}\n"
|
116
116
|
end
|
117
117
|
|
118
118
|
str
|
data/lib/slop/parser.rb
CHANGED
data/lib/slop/types.rb
CHANGED
@@ -6,6 +6,13 @@ module Slop
|
|
6
6
|
end
|
7
7
|
end
|
8
8
|
|
9
|
+
# Cast the option argument to a symbol.
|
10
|
+
class SymbolOption < Option
|
11
|
+
def call(value)
|
12
|
+
value.to_sym
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
9
16
|
# Cast the option argument to true or false.
|
10
17
|
# Override default_value to default to false instead of nil.
|
11
18
|
# This option type does not expect an argument. However, the API
|
@@ -44,16 +51,17 @@ module Slop
|
|
44
51
|
# Cast the option argument to an Integer.
|
45
52
|
class IntegerOption < Option
|
46
53
|
def call(value)
|
47
|
-
value =~ /\A
|
54
|
+
value =~ /\A[+-]?\d+\z/ && value.to_i
|
48
55
|
end
|
49
56
|
end
|
50
57
|
IntOption = IntegerOption
|
51
58
|
|
52
59
|
# Cast the option argument to a Float.
|
53
60
|
class FloatOption < Option
|
61
|
+
FLOAT_STRING_REGEXP = /\A[+-]?(?:0|[1-9]\d*)(?:\.\d*)?(?:[eE][+-]?\d+)?\z/.freeze
|
62
|
+
|
54
63
|
def call(value)
|
55
|
-
|
56
|
-
value =~ /\A-?\d*\.*\d+\z/ && value.to_f
|
64
|
+
value =~ FLOAT_STRING_REGEXP && value.to_f
|
57
65
|
end
|
58
66
|
end
|
59
67
|
|
data/test/option_test.rb
CHANGED
data/test/options_test.rb
CHANGED
@@ -70,6 +70,17 @@ describe Slop::Options do
|
|
70
70
|
|
71
71
|
assert_equal [""], @options.separators
|
72
72
|
end
|
73
|
+
|
74
|
+
it "correctly handles options with `help: false`" do
|
75
|
+
@options.boolean "--opt1"
|
76
|
+
@options.boolean "--opt2", help: false
|
77
|
+
@options.separator "other options"
|
78
|
+
@options.boolean "--opt3", help: false
|
79
|
+
@options.boolean "--opt4"
|
80
|
+
|
81
|
+
_usage, help = @options.to_s.squeeze(" ").split("\n", 2)
|
82
|
+
assert_equal "--opt1 \nother options\n --opt4", help.strip
|
83
|
+
end
|
73
84
|
end
|
74
85
|
|
75
86
|
describe "#method_missing" do
|
@@ -121,11 +132,11 @@ describe Slop::Options do
|
|
121
132
|
|
122
133
|
describe "custom banner" do
|
123
134
|
it "is prefixed with defined banner" do
|
124
|
-
@options_config = Slop::Options.new({banner: "custom banner"})
|
135
|
+
@options_config = Slop::Options.new(**{banner: "custom banner"})
|
125
136
|
assert_match(/^custom banner/, @options_config.to_s)
|
126
137
|
end
|
127
138
|
it "banner is disabled" do
|
128
|
-
@options_config = Slop::Options.new({banner: false})
|
139
|
+
@options_config = Slop::Options.new(**{banner: false})
|
129
140
|
assert_match("", @options_config.to_s)
|
130
141
|
end
|
131
142
|
end
|
data/test/parser_test.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'test_helper'
|
2
|
+
require 'shellwords'
|
2
3
|
|
3
4
|
describe Slop::Parser do
|
4
5
|
before do
|
@@ -28,6 +29,15 @@ describe Slop::Parser do
|
|
28
29
|
assert_equal %w(=), @result.args
|
29
30
|
end
|
30
31
|
|
32
|
+
it "parses flag=''" do
|
33
|
+
@options.string "--str"
|
34
|
+
@options.array "--arr", default: ["array"]
|
35
|
+
@result.parser.parse %(--str="" --arr="").shellsplit
|
36
|
+
|
37
|
+
assert_equal "", @result[:str]
|
38
|
+
assert_equal [], @result[:arr]
|
39
|
+
end
|
40
|
+
|
31
41
|
it "parses arg with leading -" do
|
32
42
|
@options.string "-t", "--text"
|
33
43
|
@result.parser.parse %w(--name=bob --text --sometext)
|
data/test/slop_test.rb
CHANGED
@@ -1,6 +1,16 @@
|
|
1
1
|
require "test_helper"
|
2
2
|
|
3
3
|
describe Slop do
|
4
|
+
describe ".parse" do
|
5
|
+
it "parses a list of arguments" do
|
6
|
+
result = Slop.parse(%w[--name Lee]) do |o|
|
7
|
+
o.string "--name"
|
8
|
+
end
|
9
|
+
|
10
|
+
assert_equal "Lee", result[:name]
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
4
14
|
describe ".option_defined?" do
|
5
15
|
it "handles bad constant names" do
|
6
16
|
assert_equal false, Slop.option_defined?("Foo?Bar")
|
data/test/types_test.rb
CHANGED
@@ -1,5 +1,33 @@
|
|
1
1
|
require 'test_helper'
|
2
2
|
|
3
|
+
describe Slop::StringOption do
|
4
|
+
before do
|
5
|
+
@options = Slop::Options.new
|
6
|
+
@age = @options.string "--name"
|
7
|
+
@minus = @options.string "--zipcode"
|
8
|
+
@result = @options.parse %w(--name Foo --zipcode 12345)
|
9
|
+
end
|
10
|
+
|
11
|
+
it "returns the value as a string" do
|
12
|
+
assert_equal "Foo", @result[:name]
|
13
|
+
assert_equal "12345", @result[:zipcode]
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
describe Slop::SymbolOption do
|
18
|
+
before do
|
19
|
+
@options = Slop::Options.new
|
20
|
+
@age = @options.symbol "--name"
|
21
|
+
@minus = @options.symbol "--zipcode"
|
22
|
+
@result = @options.parse %w(--name Foo --zipcode 12345)
|
23
|
+
end
|
24
|
+
|
25
|
+
it "returns the value as a symbol" do
|
26
|
+
assert_equal :Foo, @result[:name]
|
27
|
+
assert_equal :'12345', @result[:zipcode]
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
3
31
|
describe Slop::BoolOption do
|
4
32
|
before do
|
5
33
|
@options = Slop::Options.new
|
@@ -32,11 +60,15 @@ describe Slop::IntegerOption do
|
|
32
60
|
before do
|
33
61
|
@options = Slop::Options.new
|
34
62
|
@age = @options.integer "--age"
|
35
|
-
@
|
63
|
+
@minus = @options.integer "--minus"
|
64
|
+
@plus = @options.integer "--plus"
|
65
|
+
@result = @options.parse %w(--age 20 --minus -10 --plus +30)
|
36
66
|
end
|
37
67
|
|
38
68
|
it "returns the value as an integer" do
|
39
69
|
assert_equal 20, @result[:age]
|
70
|
+
assert_equal (-10), @result[:minus]
|
71
|
+
assert_equal 30, @result[:plus]
|
40
72
|
end
|
41
73
|
|
42
74
|
it "returns nil for non-numbers by default" do
|
@@ -50,11 +82,37 @@ describe Slop::FloatOption do
|
|
50
82
|
@options = Slop::Options.new
|
51
83
|
@apr = @options.float "--apr"
|
52
84
|
@apr_value = 2.9
|
53
|
-
@
|
85
|
+
@minus = @options.float "--minus"
|
86
|
+
@plus = @options.float "--plus"
|
87
|
+
@scientific_notation = @options.float "--scientific-notation"
|
88
|
+
@scientific_notation_value = 4e21
|
89
|
+
@result = @options.parse %W(--apr #{@apr_value} --minus -6.1 --plus +9.4 --scientific-notation #{@scientific_notation_value})
|
54
90
|
end
|
55
91
|
|
56
92
|
it "returns the value as a float" do
|
57
93
|
assert_equal @apr_value, @result[:apr]
|
94
|
+
assert_equal (-6.1), @result[:minus]
|
95
|
+
assert_equal 9.4, @result[:plus]
|
96
|
+
end
|
97
|
+
|
98
|
+
it "parses scientific notations" do
|
99
|
+
assert_equal @scientific_notation_value, @result[:scientific_notation]
|
100
|
+
|
101
|
+
@scientific_notation_value = 4E21
|
102
|
+
@result = @options.parse %W(--scientific-notation #{@scientific_notation_value})
|
103
|
+
assert_equal @scientific_notation_value, @result[:scientific_notation]
|
104
|
+
|
105
|
+
@scientific_notation_value = 4.0e21
|
106
|
+
@result = @options.parse %W(--scientific-notation #{@scientific_notation_value})
|
107
|
+
assert_equal @scientific_notation_value, @result[:scientific_notation]
|
108
|
+
|
109
|
+
@scientific_notation_value = -4e21
|
110
|
+
@result = @options.parse %W(--scientific-notation #{@scientific_notation_value})
|
111
|
+
assert_equal @scientific_notation_value, @result[:scientific_notation]
|
112
|
+
|
113
|
+
@scientific_notation_value = 4e-21
|
114
|
+
@result = @options.parse %W(--scientific-notation #{@scientific_notation_value})
|
115
|
+
assert_equal @scientific_notation_value, @result[:scientific_notation]
|
58
116
|
end
|
59
117
|
|
60
118
|
it "returns nil for non-numbers by default" do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: slop
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.
|
4
|
+
version: 4.9.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Lee Jarvis
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-05-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -71,7 +71,7 @@ homepage: http://github.com/leejarvis/slop
|
|
71
71
|
licenses:
|
72
72
|
- MIT
|
73
73
|
metadata: {}
|
74
|
-
post_install_message:
|
74
|
+
post_install_message:
|
75
75
|
rdoc_options: []
|
76
76
|
require_paths:
|
77
77
|
- lib
|
@@ -86,9 +86,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
86
86
|
- !ruby/object:Gem::Version
|
87
87
|
version: '0'
|
88
88
|
requirements: []
|
89
|
-
|
90
|
-
|
91
|
-
signing_key:
|
89
|
+
rubygems_version: 3.0.3
|
90
|
+
signing_key:
|
92
91
|
specification_version: 4
|
93
92
|
summary: Simple Lightweight Option Parsing
|
94
93
|
test_files:
|