slop 4.6.0 → 4.6.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +8 -0
- data/README.md +3 -2
- data/lib/slop.rb +1 -1
- data/lib/slop/options.rb +5 -1
- data/test/options_test.rb +31 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fb0866db90cc2226117322463845a56a78f43cc2
|
4
|
+
data.tar.gz: acd05e15e79c70f68d6248a9bdcf8e3c1afa128f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 276b3847e95efdafb6eb47516168a3e4c984db3cf2b60c88eb8d7a9d67815956ea3d039a9ddc04dfc0d25c1ada21ab7c7d9a9825b39c31d85ab79e53b605cc78
|
7
|
+
data.tar.gz: 211808f3fae95a2c7d69bee7072df3e8b05cc5c2c134d81706143d459741af3914f042a8b08a6952aa8628f5324d0cff50def90eb297a5307c87ce4794e8eb49
|
data/CHANGELOG.md
CHANGED
@@ -1,6 +1,14 @@
|
|
1
1
|
Changelog
|
2
2
|
=========
|
3
3
|
|
4
|
+
v4.6.1 (2017-11-20)
|
5
|
+
-------------------
|
6
|
+
|
7
|
+
Bug fixes/Enhancements
|
8
|
+
* Fix separator so it doesn't mutate user data. #223 (Marc-André Lafortune)
|
9
|
+
* Add additional tests for `Options#separator` and fix issue where
|
10
|
+
the last separator was ignored. #222
|
11
|
+
|
4
12
|
v4.6.0 (2017-10-06)
|
5
13
|
-------------------
|
6
14
|
|
data/README.md
CHANGED
@@ -30,14 +30,15 @@ opts = Slop.parse do |o|
|
|
30
30
|
end
|
31
31
|
end
|
32
32
|
|
33
|
-
ARGV #=> -v --host 192.168.0.1 --check-ssl-certificate
|
33
|
+
ARGV #=> -v --login alice --host 192.168.0.1 --check-ssl-certificate
|
34
34
|
|
35
35
|
opts[:host] #=> 192.168.0.1
|
36
|
+
opts[:login] #=> alice
|
36
37
|
opts.verbose? #=> true
|
37
38
|
opts.quiet? #=> false
|
38
39
|
opts.check_ssl_certificate? #=> true
|
39
40
|
|
40
|
-
opts.to_hash #=> { host: "192.168.0.1", port: 80, verbose: true, quiet: false, check_ssl_certificate: true }
|
41
|
+
opts.to_hash #=> { host: "192.168.0.1", login: "alice", port: 80, verbose: true, quiet: false, check_ssl_certificate: true }
|
41
42
|
```
|
42
43
|
|
43
44
|
Note that the block we've added to the `--version` flag will be executed
|
data/lib/slop.rb
CHANGED
data/lib/slop/options.rb
CHANGED
@@ -61,7 +61,7 @@ module Slop
|
|
61
61
|
# the help text.
|
62
62
|
def separator(string)
|
63
63
|
if separators[options.size]
|
64
|
-
separators
|
64
|
+
separators[-1] += "\n#{string}"
|
65
65
|
else
|
66
66
|
separators[options.size] = string
|
67
67
|
end
|
@@ -111,6 +111,10 @@ module Slop
|
|
111
111
|
str << "#{prefix}#{opt.to_s(offset: len)}\n"
|
112
112
|
end
|
113
113
|
|
114
|
+
if sep = separators[options.size]
|
115
|
+
str << "#{sep}\n"
|
116
|
+
end
|
117
|
+
|
114
118
|
str
|
115
119
|
end
|
116
120
|
|
data/test/options_test.rb
CHANGED
@@ -36,6 +36,36 @@ describe Slop::Options do
|
|
36
36
|
end
|
37
37
|
end
|
38
38
|
|
39
|
+
describe "#separator" do
|
40
|
+
it "appends separators between options in order" do
|
41
|
+
@options.separator("foo")
|
42
|
+
@options.on("--foo")
|
43
|
+
@options.separator("bar")
|
44
|
+
|
45
|
+
assert_equal ["foo", "bar"], @options.separators
|
46
|
+
end
|
47
|
+
|
48
|
+
it "appends strings to the last separator if no options exist" do
|
49
|
+
@options.separator("foo")
|
50
|
+
@options.separator("bar")
|
51
|
+
|
52
|
+
assert_equal ["foo\nbar"], @options.separators
|
53
|
+
end
|
54
|
+
|
55
|
+
it "includes separators in the help text" do
|
56
|
+
@options.on("--foo")
|
57
|
+
@options.separator("bar")
|
58
|
+
|
59
|
+
help = @options.to_s.squeeze(" ")
|
60
|
+
assert help.end_with?("--foo \nbar\n")
|
61
|
+
end
|
62
|
+
|
63
|
+
it "accepts a frozen argument, even when called multiple times for the same option" do
|
64
|
+
@options.separator("foo".freeze)
|
65
|
+
@options.separator("bar".freeze)
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
39
69
|
describe "#method_missing" do
|
40
70
|
it "uses the method name as an option type" do
|
41
71
|
option = @options.string("--name")
|
@@ -86,7 +116,7 @@ describe Slop::Options do
|
|
86
116
|
describe "custom banner" do
|
87
117
|
it "is prefixed with defined banner" do
|
88
118
|
@options_config = Slop::Options.new({banner: "custom banner"})
|
89
|
-
assert_match(/^custom banner/, @options_config.to_s)
|
119
|
+
assert_match(/^custom banner/, @options_config.to_s)
|
90
120
|
end
|
91
121
|
it "banner is disabled" do
|
92
122
|
@options_config = Slop::Options.new({banner: false})
|
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.6.
|
4
|
+
version: 4.6.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Lee Jarvis
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-11-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -87,7 +87,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
87
87
|
version: '0'
|
88
88
|
requirements: []
|
89
89
|
rubyforge_project:
|
90
|
-
rubygems_version: 2.
|
90
|
+
rubygems_version: 2.5.2.1
|
91
91
|
signing_key:
|
92
92
|
specification_version: 4
|
93
93
|
summary: Simple Lightweight Option Parsing
|