slop 4.2.1 → 4.3.0

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: 46b97913fc755da80d6ce7680b9c62edaa097f18
4
- data.tar.gz: e5717f5a2ae612a433f9b602a1fbb0692a75cb77
3
+ metadata.gz: 09ca8b84867d657dc875e33dd3d230c4e38f7789
4
+ data.tar.gz: 89f3079de8089096383c7a7c10e2ca01b3ae0706
5
5
  SHA512:
6
- metadata.gz: 80d06a261ab8201470395cc679f0b833ca16f1c340ba6fe4f0a819cbb6fec16b9b41bd86b46d745f27bdbc047a0fbd3b2a5038aaa897f561e657780858437da9
7
- data.tar.gz: 102f8d9c8d39db648ef5bb2f9aeae9366ee5b98d83748e8aab076a948ff63699f3fc6ea4eb7371df28958afb9d9e8f97d70a8d7f6fb9ebe477894b07c6fc6ad5
6
+ metadata.gz: 340ec84f97161a331d066eec37d45347dfb3368569276df62c214aa9fcf4d7cc5f9b4de442bfc85f02efa0f0492cf32739efe2a1fcac132695d02a165c67bd13
7
+ data.tar.gz: 0c3d8e9a7bd21afd3a6748a4b71901dbf4e08c1e6434c731cbabd117441eb7030721d07743ce893caaba92eb6eb2f37e613019de4258a00af0af05950e96eadd
@@ -1,8 +1,11 @@
1
1
  cache: bundler
2
+ before_install:
3
+ - gem update bundler
2
4
  rvm:
3
5
  - 2.0.0
4
6
  - 2.1
5
7
  - 2.2
8
+ - 2.3.0
6
9
  - rbx-2
7
10
  - jruby-head
8
11
  - ruby-head
@@ -1,6 +1,13 @@
1
1
  Changelog
2
2
  =========
3
3
 
4
+ v4.3.0 (2016-03-19)
5
+ -------------------
6
+
7
+ Features
8
+ * Allow disabling array delimiter. #189 (Mike Pastore)
9
+ * Allow passing custom banner as config. #191 (Philip Rees)
10
+
4
11
  v4.2.1 (2015-11-25)
5
12
  -------------------
6
13
 
data/README.md CHANGED
@@ -132,6 +132,9 @@ end
132
132
  # --files foo.txt --files bar.rb
133
133
  ```
134
134
 
135
+ If you want to disable the built-in string-splitting, set the delimiter to
136
+ `nil`.
137
+
135
138
  Custom option types
136
139
  -------------------
137
140
 
@@ -272,7 +275,7 @@ Upgrading from version 3
272
275
  ------------------------
273
276
 
274
277
  Slop v4 is completely non-backwards compatible. The code has been rewritten
275
- from the group up. If you're already using version 3 you have *have* to update
278
+ from the ground up. If you're already using version 3 you *have* to update
276
279
  your code to use version 4. Here's an overview of the more fundamental changes:
277
280
 
278
281
  #### No more `instance_eval`
@@ -6,7 +6,7 @@ require 'slop/types'
6
6
  require 'slop/error'
7
7
 
8
8
  module Slop
9
- VERSION = '4.2.1'
9
+ VERSION = '4.3.0'
10
10
 
11
11
  # Parse an array of options (defaults to ARGV). Accepts an
12
12
  # optional hash of configuration options and block.
@@ -26,7 +26,7 @@ module Slop
26
26
  def initialize(**config)
27
27
  @options = []
28
28
  @separators = []
29
- @banner = "usage: #{$0} [options]"
29
+ @banner = config[:banner].is_a?(String) ? config[:banner] : config.fetch(:banner, "usage: #{$0} [options]")
30
30
  @config = DEFAULT_CONFIG.merge(config)
31
31
  @parser = Parser.new(self, @config)
32
32
 
@@ -62,7 +62,11 @@ module Slop
62
62
  class ArrayOption < Option
63
63
  def call(value)
64
64
  @value ||= []
65
- @value.concat value.split(delimiter, limit)
65
+ if delimiter
66
+ @value.concat value.split(delimiter, limit)
67
+ else
68
+ @value << value
69
+ end
66
70
  end
67
71
 
68
72
  def default_value
@@ -70,7 +74,7 @@ module Slop
70
74
  end
71
75
 
72
76
  def delimiter
73
- config[:delimiter] || ","
77
+ config.fetch(:delimiter, ",")
74
78
  end
75
79
 
76
80
  def limit
@@ -55,7 +55,7 @@ describe Slop::Options do
55
55
  end
56
56
 
57
57
  describe "#to_s" do
58
- it "is prefixed with the banner" do
58
+ it "is prefixed with the default banner" do
59
59
  assert_match(/^usage/, @options.to_s)
60
60
  end
61
61
 
@@ -82,4 +82,15 @@ describe Slop::Options do
82
82
  assert_match(/^ -h, --help/, @options.to_s.lines.last)
83
83
  end
84
84
  end
85
+
86
+ describe "custom banner" do
87
+ it "is prefixed with defined banner" do
88
+ @options_config = Slop::Options.new({banner: "custom banner"})
89
+ assert_match(/^custom banner/, @options_config.to_s)
90
+ end
91
+ it "banner is disabled" do
92
+ @options_config = Slop::Options.new({banner: false})
93
+ assert_match("", @options_config.to_s)
94
+ end
95
+ end
85
96
  end
@@ -67,6 +67,7 @@ describe Slop::ArrayOption do
67
67
  before do
68
68
  @options = Slop::Options.new
69
69
  @files = @options.array "--files"
70
+ @multi = @options.array "-M", delimiter: nil
70
71
  @delim = @options.array "-d", delimiter: ":"
71
72
  @limit = @options.array "-l", limit: 2
72
73
  @result = @options.parse %w(--files foo.txt,bar.rb)
@@ -85,6 +86,11 @@ describe Slop::ArrayOption do
85
86
  assert_equal %w(foo.txt bar.rb), @result[:files]
86
87
  end
87
88
 
89
+ it "collects multiple option values with no delimiter" do
90
+ @result.parser.parse %w(-M foo,bar -M bar,qux)
91
+ assert_equal %w(foo,bar bar,qux), @result[:M]
92
+ end
93
+
88
94
  it "can use a custom delimiter" do
89
95
  @result.parser.parse %w(-d foo.txt:bar.rb)
90
96
  assert_equal %w(foo.txt bar.rb), @result[:d]
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.2.1
4
+ version: 4.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Lee Jarvis
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-11-25 00:00:00.000000000 Z
11
+ date: 2016-03-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -86,7 +86,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
86
86
  version: '0'
87
87
  requirements: []
88
88
  rubyforge_project:
89
- rubygems_version: 2.4.5
89
+ rubygems_version: 2.5.1
90
90
  signing_key:
91
91
  specification_version: 4
92
92
  summary: Simple Lightweight Option Parsing