slop 4.6.0 → 4.6.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 66456d3c9b1836976bf1db77744397d30ed6eddd
4
- data.tar.gz: 615f7a217ab9668b2eab4234230f67b7bad76ffc
3
+ metadata.gz: fb0866db90cc2226117322463845a56a78f43cc2
4
+ data.tar.gz: acd05e15e79c70f68d6248a9bdcf8e3c1afa128f
5
5
  SHA512:
6
- metadata.gz: 5976dae0692f77d98ef26995737385da682592ddd4631209543f1604130c607f6f584a787a036595d668914245b17cc0141050e8fe36843f288bda93f5bcd74a
7
- data.tar.gz: a5ed147ed93952f3d3d3e38abd8ece30bb6131e43d085281c91c0c12bd4490473fc0f3169e6f82cc6b8a1aa494d1d77188eeba63ec622794614f586bcf1fccbe
6
+ metadata.gz: 276b3847e95efdafb6eb47516168a3e4c984db3cf2b60c88eb8d7a9d67815956ea3d039a9ddc04dfc0d25c1ada21ab7c7d9a9825b39c31d85ab79e53b605cc78
7
+ data.tar.gz: 211808f3fae95a2c7d69bee7072df3e8b05cc5c2c134d81706143d459741af3914f042a8b08a6952aa8628f5324d0cff50def90eb297a5307c87ce4794e8eb49
@@ -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
@@ -6,7 +6,7 @@ require 'slop/types'
6
6
  require 'slop/error'
7
7
 
8
8
  module Slop
9
- VERSION = '4.6.0'
9
+ VERSION = '4.6.1'
10
10
 
11
11
  # Parse an array of options (defaults to ARGV). Accepts an
12
12
  # optional hash of configuration options and block.
@@ -61,7 +61,7 @@ module Slop
61
61
  # the help text.
62
62
  def separator(string)
63
63
  if separators[options.size]
64
- separators.last << "\n#{string}"
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
 
@@ -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.0
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-10-06 00:00:00.000000000 Z
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.6.13
90
+ rubygems_version: 2.5.2.1
91
91
  signing_key:
92
92
  specification_version: 4
93
93
  summary: Simple Lightweight Option Parsing