commander 4.4.3 → 4.4.4

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
- SHA1:
3
- metadata.gz: 1fab0ac21561072424d7bf0d3e3ae8c07f00c721
4
- data.tar.gz: a5e55123decc318877105e073ad5519a1d7e08c5
2
+ SHA256:
3
+ metadata.gz: 44969cb91e63472555ff36e2d39513cb5ac4c0f8f9c626f8b85bcd836e1a8227
4
+ data.tar.gz: '00957023e0b9d380efab260b267082dd15c11c8a7f5e9b536f65bd8a0719b370'
5
5
  SHA512:
6
- metadata.gz: 0b99a7f4c91b1fb9deee588616aadcd56dee44db34d6d99b8efd6efcc199097f94df8fec3947eeb48270da6b18df176be252fd2e9025b58a2c11df6d687bce55
7
- data.tar.gz: cdd0930f1ce730579c1f1572643ea6632683262df7bf5438b107994a7523fe0a7d71505e77304eda1e6f442ad8a9b98d710e7043cb761237bb024f8d503001d5
6
+ metadata.gz: 0c71a8f9f030be8c93267a75027cfeac2712d31cc8907bfcfc1534f190d3f4615a930e13fbc0f1cb7cbbd7eae73cffa6136b2d63657193639064a4fde6d95f7c
7
+ data.tar.gz: 12e7152d828da458b7ca79a10ce08d8a8ef00d815feaf86a394b68da8892b64ce8422df0530a6c470a2784fcd23ae561abefbeb33e6e7ddddd47ea64c0cd4545
@@ -1,5 +1,12 @@
1
1
  inherit_from: .rubocop_todo.yml
2
2
 
3
+ AllCops:
4
+ TargetRubyVersion: 1.9
5
+
6
+ # not Ruby 1.9.3 compatible
7
+ Style/PercentLiteralDelimiters:
8
+ Enabled: false
9
+
3
10
  # Offense count: 5
4
11
  Encoding:
5
12
  Enabled: false
@@ -23,10 +30,10 @@ Style/NumericLiteralPrefix:
23
30
  Style/MethodMissing:
24
31
  Enabled: false
25
32
 
26
- Style/SpaceInsideStringInterpolation:
33
+ Layout/SpaceInsideStringInterpolation:
27
34
  Enabled: false
28
35
 
29
- Style/MultilineOperationIndentation:
36
+ Layout/MultilineOperationIndentation:
30
37
  Enabled: false
31
38
 
32
39
  Style/EmptyMethod:
@@ -6,7 +6,7 @@
6
6
  # versions of RuboCop, may require this file to be generated again.
7
7
 
8
8
  # Offense count: 2
9
- Lint/Eval:
9
+ Security/Eval:
10
10
  Enabled: false
11
11
 
12
12
  # Offense count: 2
@@ -1,4 +1,5 @@
1
1
  language: ruby
2
+ cache: bundler
2
3
  before_install:
3
4
  - gem update --system
4
5
  - gem update bundler
@@ -6,7 +7,8 @@ rvm:
6
7
  - 1.9.3
7
8
  - 2.0.0
8
9
  - 2.1.10
9
- - 2.2.6
10
- - 2.3.3
11
- - 2.4.0
10
+ - 2.2.9
11
+ - 2.3.6
12
+ - 2.4.3
13
+ - 2.5.0
12
14
  - jruby-19mode
@@ -1,3 +1,7 @@
1
+ === 4.4.4 / 2018-01-18
2
+
3
+ * Fix deprecated constant warnings on Ruby 2.5. (@mattbrictson)
4
+
1
5
  === 4.4.3 / 2016-12-28
2
6
 
3
7
  * Fix deprecated constant warnings on Ruby 2.4.
data/README.md CHANGED
@@ -1,5 +1,5 @@
1
- [<img src="https://secure.travis-ci.org/commander-rb/commander.png?branch=master" alt="Build Status" />](http://travis-ci.org/commander-rb/commander)
2
- [![Inline docs](http://inch-ci.org/github/commander-rb/commander.png)](http://inch-ci.org/github/commander-rb/commander)
1
+ [<img src="https://api.travis-ci.org/commander-rb/commander.svg" alt="Build Status" />](http://travis-ci.org/commander-rb/commander)
2
+ [![Inline docs](http://inch-ci.org/github/commander-rb/commander.svg)](http://inch-ci.org/github/commander-rb/commander)
3
3
 
4
4
  # Commander
5
5
 
@@ -339,6 +339,21 @@ $ foo install gem
339
339
  # => installing to
340
340
  ```
341
341
 
342
+ ### Long descriptions
343
+
344
+ If you need to have a long command description, keep your short description under `summary`, and consider multi-line strings for `description`:
345
+
346
+ ```ruby
347
+ program :summary, 'Stupid command that prints foo or bar.'
348
+ program :description, %q(
349
+ #{c.summary}
350
+
351
+ More information about that stupid command that prints foo or bar.
352
+
353
+ And more
354
+ )
355
+ ```
356
+
342
357
  ### Additional Global Help
343
358
 
344
359
  Arbitrary help can be added using the following `#program` symbol:
@@ -1,4 +1,5 @@
1
1
  # -*- encoding: utf-8 -*-
2
+
2
3
  $LOAD_PATH.push File.expand_path('../lib', __FILE__)
3
4
  require 'commander/version'
4
5
 
@@ -26,6 +27,6 @@ Gem::Specification.new do |s|
26
27
  s.add_development_dependency('rubocop', '~> 0.41.1')
27
28
  s.add_development_dependency('json', '< 2.0')
28
29
  else
29
- s.add_development_dependency('rubocop', '~> 0.46')
30
+ s.add_development_dependency('rubocop', '~> 0.49.1')
30
31
  end
31
32
  end
@@ -324,22 +324,45 @@ module Commander
324
324
  # Implements ask_for_CLASS methods.
325
325
 
326
326
  module AskForClass
327
- DEPRECATED_CONSTANTS = [:Config, :TimeoutError, :MissingSourceFile, :NIL, :TRUE, :FALSE, :Fixnum, :Bignum].freeze
328
- # All special cases in HighLine::Question#convert, except those that implement #parse
329
- (
330
- [Float, Integer, String, Symbol, Regexp, Array, File, Pathname] +
331
- # All Classes that respond to #parse
332
- # Ignore constants that trigger deprecation warnings
333
- (Object.constants - DEPRECATED_CONSTANTS).map do |const|
334
- Object.const_get(const)
335
- end.select do |const|
336
- const.class == Class && const.respond_to?(:parse)
337
- end
338
- ).each do |klass|
327
+ DEPRECATED_CONSTANTS = [:Config, :TimeoutError, :MissingSourceFile, :NIL, :TRUE, :FALSE, :Fixnum, :Bignum, :Data].freeze
328
+
329
+ # define methods for common classes
330
+ [Float, Integer, String, Symbol, Regexp, Array, File, Pathname].each do |klass|
339
331
  define_method "ask_for_#{klass.to_s.downcase}" do |prompt|
340
332
  $terminal.ask(prompt, klass)
341
333
  end
342
334
  end
335
+
336
+ def method_missing(method_name, *arguments, &block)
337
+ if method_name.to_s =~ /^ask_for_(.*)/
338
+ if arguments.count != 1
339
+ fail ArgumentError, "wrong number of arguments (given #{arguments.count}, expected 1)"
340
+ end
341
+ prompt = arguments.first
342
+ requested_class = Regexp.last_match[1]
343
+
344
+ # All Classes that respond to #parse
345
+ # Ignore constants that trigger deprecation warnings
346
+ available_classes = (Object.constants - DEPRECATED_CONSTANTS).map do |const|
347
+ Object.const_get(const)
348
+ end.select do |const|
349
+ const.class == Class && const.respond_to?(:parse)
350
+ end
351
+
352
+ klass = available_classes.find { |k| k.to_s.downcase == requested_class }
353
+ if klass
354
+ $terminal.ask(prompt, klass)
355
+ else
356
+ super
357
+ end
358
+ else
359
+ super
360
+ end
361
+ end
362
+
363
+ def respond_to_missing?(method_name, include_private = false)
364
+ method_name.to_s.start_with?('ask_for_') || super
365
+ end
343
366
  end
344
367
 
345
368
  ##
@@ -1,3 +1,3 @@
1
1
  module Commander
2
- VERSION = '4.4.3'.freeze
2
+ VERSION = '4.4.4'.freeze
3
3
  end
@@ -6,8 +6,49 @@ describe Commander::Methods do
6
6
  expect(subject.ancestors).to include(Commander::UI)
7
7
  end
8
8
 
9
- it 'includes Commander::UI::AskForClass' do
10
- expect(subject.ancestors).to include(Commander::UI::AskForClass)
9
+ describe 'AskForClass' do
10
+ it 'includes Commander::UI::AskForClass' do
11
+ expect(subject.ancestors).to include(Commander::UI::AskForClass)
12
+ end
13
+
14
+ describe 'defining methods' do
15
+ let(:terminal) { double }
16
+
17
+ before do
18
+ allow(terminal).to receive(:ask)
19
+ $_old_terminal = $terminal
20
+ $terminal = terminal
21
+ end
22
+
23
+ after do
24
+ $terminal = $_old_terminal
25
+ end
26
+
27
+ subject do
28
+ Class.new do
29
+ include Commander::UI::AskForClass
30
+ end.new
31
+ end
32
+
33
+ it 'defines common "ask_for_*" methods' do
34
+ expect(subject.respond_to?(:ask_for_float)).to be_truthy
35
+ end
36
+
37
+ it 'responds to "ask_for_*" methods for classes that implement #parse' do
38
+ expect(subject.respond_to?(:ask_for_datetime)).to be_truthy
39
+ end
40
+
41
+ it 'fails "ask_for_*" method invocations without a prompt' do
42
+ expect do
43
+ subject.ask_for_datetime
44
+ end.to raise_error(ArgumentError)
45
+ end
46
+
47
+ it 'implements "ask_for_*"' do
48
+ expect(terminal).to receive(:ask)
49
+ subject.ask_for_datetime('hi')
50
+ end
51
+ end
11
52
  end
12
53
 
13
54
  it 'includes Commander::Delegates' do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: commander
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.4.3
4
+ version: 4.4.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - TJ Holowaychuk
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2016-12-28 00:00:00.000000000 Z
12
+ date: 2018-01-18 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: highline
@@ -73,14 +73,14 @@ dependencies:
73
73
  requirements:
74
74
  - - "~>"
75
75
  - !ruby/object:Gem::Version
76
- version: '0.46'
76
+ version: 0.49.1
77
77
  type: :development
78
78
  prerelease: false
79
79
  version_requirements: !ruby/object:Gem::Requirement
80
80
  requirements:
81
81
  - - "~>"
82
82
  - !ruby/object:Gem::Version
83
- version: '0.46'
83
+ version: 0.49.1
84
84
  description: The complete solution for Ruby command-line executables. Commander bridges
85
85
  the gap between other terminal related libraries you know and love (OptionParser,
86
86
  HighLine), while providing many new features, and an elegant API.
@@ -157,7 +157,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
157
157
  version: '0'
158
158
  requirements: []
159
159
  rubyforge_project:
160
- rubygems_version: 2.6.8
160
+ rubygems_version: 2.7.4
161
161
  signing_key:
162
162
  specification_version: 4
163
163
  summary: The complete solution for Ruby command-line executables