clamp 1.2.0.beta1 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: aec7a5c34695b2517afb8215a0cbe8e9e4b2c8b9
4
- data.tar.gz: f20e0d18b9e4be570fc7ae1f349d4d022f0f7644
3
+ metadata.gz: 2fe91eba2afc3a9297ecee33bfaf08a3be3522db
4
+ data.tar.gz: 54f0085f58bf85f9cb5d0db0339eaabfe7ffb528
5
5
  SHA512:
6
- metadata.gz: 554f0e8fefe510adeacd74357333302d2f3ae9a4b98f87e0140956e4b35ff6f60b7b3031260b8cba2c2f96079b201ebc4c6256bed160d52038a079e7538defda
7
- data.tar.gz: 85d29744e560feb6c06096739df752128bd1df915237da53b1c7ea7150ade1d3516016eb3014c7fc1f2958fdcf2074c35e00d6aa64057a8c8c56c9c82094f879
6
+ metadata.gz: ffd0bc644d279f96e68663a0a815ebc0c6825d8cbb4ec69d2fea5315e273fdc587040f1dc761cb51a66362aa6b203789d9c15f56b02bd37c1c98024eaf6b79ff
7
+ data.tar.gz: 06a3e512e3bec497227459f93a9dfd7357fd258695f837d1a3ba4569ae2f3bcfeb0561a7d65f8163b5272e0251224017b7e80e64fbe861295223c9ade8ce9e69
@@ -2,6 +2,15 @@ Eval:
2
2
  Exclude:
3
3
  - "Rakefile"
4
4
 
5
+ Layout/EmptyLinesAroundBlockBody:
6
+ Enabled: false
7
+
8
+ Layout/EmptyLinesAroundClassBody:
9
+ EnforcedStyle: empty_lines
10
+
11
+ Layout/EmptyLinesAroundModuleBody:
12
+ Enabled: false
13
+
5
14
  Metrics/AbcSize:
6
15
  Enabled: false
7
16
 
@@ -11,9 +20,13 @@ Metrics/LineLength:
11
20
  Metrics/MethodLength:
12
21
  Max: 30
13
22
 
14
- Style/AccessorMethodName:
23
+ Naming/AccessorMethodName:
15
24
  Enabled: false
16
25
 
26
+ Naming/FileName:
27
+ Exclude:
28
+ - "bin/*"
29
+
17
30
  Style/ClassAndModuleChildren:
18
31
  EnforcedStyle: nested
19
32
  Exclude:
@@ -24,23 +37,9 @@ Style/Documentation:
24
37
  - "lib/**/version.rb"
25
38
  - "spec/**/*"
26
39
 
27
- Style/EmptyLinesAroundBlockBody:
28
- Enabled: false
29
-
30
- Style/EmptyLinesAroundClassBody:
31
- EnforcedStyle: empty_lines
32
-
33
- Style/EmptyLinesAroundModuleBody:
34
- Enabled: false
35
-
36
40
  Style/Encoding:
37
- EnforcedStyle: when_needed
38
41
  Enabled: true
39
42
 
40
- Style/FileName:
41
- Exclude:
42
- - "bin/*"
43
-
44
43
  Style/HashSyntax:
45
44
  EnforcedStyle: hash_rockets
46
45
 
@@ -50,7 +49,7 @@ Style/Lambda:
50
49
  Style/NumericLiterals:
51
50
  Enabled: false
52
51
 
53
- Style/PredicateName:
52
+ Naming/PredicateName:
54
53
  Enabled: false
55
54
 
56
55
  Style/StringLiterals:
data/CHANGES.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Changelog
2
2
 
3
- ## PENDING
3
+ ## 1.2.0 (2018-02-12)
4
4
 
5
5
  * Add option to `Clamp.allow_options_after_parameters`.
6
6
 
data/Gemfile CHANGED
@@ -6,7 +6,7 @@ group :development do
6
6
  gem "guard-rspec", "~> 4.6.5", :require => false
7
7
  gem "listen", "~> 3.0.2"
8
8
  gem "rake", "~> 10.4"
9
- gem "rubocop", "~> 0.43.0", :require => false
9
+ gem "rubocop", :require => false
10
10
  end
11
11
 
12
12
  group :test do
data/README.md CHANGED
@@ -298,11 +298,13 @@ Clamp will check the specified envariables in the absence of values supplied on
298
298
 
299
299
  ### Allowing options after parameters
300
300
 
301
- Many option-parsing libraries - notably [GNU `getopt(3)`](https://www.gnu.org/software/libc/manual/html_node/Using-Getopt.html) - allow option and parameter arguments to appear in any order on the command-line, e.g.
301
+ By default, Clamp only recognises options _before_ positional parameters.
302
+
303
+ Some other option-parsing libraries - notably [GNU `getopt(3)`](https://www.gnu.org/software/libc/manual/html_node/Using-Getopt.html) - allow option and parameter arguments to appear in any order on the command-line, e.g.
302
304
 
303
305
  foobar --foo=bar something --fnord=snuffle another-thing
304
306
 
305
- By default, Clamp does not allow options and parameters to be "interspersed" in this way. If you want that behaviour, set:
307
+ If you want Clamp to allow options and parameters to be "interspersed" in this way, set:
306
308
 
307
309
  ```ruby
308
310
  Clamp.allow_options_after_parameters = true
@@ -69,8 +69,10 @@ module Clamp
69
69
 
70
70
  def verify_required_options_are_set
71
71
  self.class.recognised_options.each do |option|
72
- # If this option is required and the value is nil, there's an error.
73
- next unless option.required? && send(option.attribute_name).nil?
72
+ # If this option is required and the value is nil (or [] for multivalued), there's an error.
73
+ next unless option.required? &&
74
+ (!option.multivalued? && send(option.attribute_name).nil?) ||
75
+ (option.multivalued? && send(option.attribute_name).empty?)
74
76
  if option.environment_variable
75
77
  message = Clamp.message(:option_or_env_required,
76
78
  :option => option.switches.first,
@@ -1,3 +1,3 @@
1
1
  module Clamp
2
- VERSION = "1.2.0.beta1".freeze
2
+ VERSION = "1.2.0".freeze
3
3
  end
@@ -269,6 +269,34 @@ describe Clamp::Command do
269
269
 
270
270
  end
271
271
 
272
+ context "with :required and :multivalued" do
273
+
274
+ before do
275
+ command.class.option "--port", "PORT", "port to listen on", :required => true, :multivalued => true
276
+ end
277
+
278
+ context "when no value is provided" do
279
+
280
+ it "raises a UsageError" do
281
+ expect do
282
+ command.parse([])
283
+ end.to raise_error(Clamp::UsageError)
284
+ end
285
+
286
+ end
287
+
288
+ context "when a value is provided" do
289
+
290
+ it "does not raise an error" do
291
+ expect do
292
+ command.parse(["--port", "12345"])
293
+ end.not_to raise_error
294
+ end
295
+
296
+ end
297
+
298
+ end
299
+
272
300
  context "with a block" do
273
301
 
274
302
  before do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: clamp
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.0.beta1
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mike Williams
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-11-08 00:00:00.000000000 Z
11
+ date: 2018-02-11 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: |
14
14
  Clamp provides an object-model for command-line utilities.
@@ -82,9 +82,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
82
82
  version: '0'
83
83
  required_rubygems_version: !ruby/object:Gem::Requirement
84
84
  requirements:
85
- - - ">"
85
+ - - ">="
86
86
  - !ruby/object:Gem::Version
87
- version: 1.3.1
87
+ version: '0'
88
88
  requirements: []
89
89
  rubyforge_project:
90
90
  rubygems_version: 2.6.13