commander 4.5.2 → 4.6.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
  SHA256:
3
- metadata.gz: c911ee8aef66db7dbe8045f9f996ff0b810afeacb6f8efc7fc288e322937f59a
4
- data.tar.gz: b22b126f597fad5adcc4ecc44c60ac57ac70b3ce2ffeb646d8001eabf088da8d
3
+ metadata.gz: f91f8a37c32e7971823b150b8b89d7f992a6971c66351ae7527b27cdbf0926db
4
+ data.tar.gz: bcd3c3131f145cea800da48c7231a6d3b0b892eed9107fd64dac52b03da2f44b
5
5
  SHA512:
6
- metadata.gz: '04589993f113b0ed3aab4d90ae8a963f5d68999535f523def84e9d6d2a355c0a5b2bbdc4a5969c0bcf8d44e6d1a40f42e1e6f5bbafe35126b321ef46c05f235f'
7
- data.tar.gz: 52c16dd44e1801cb3ee353332dada749c013b452d3976c1a9aed9829d16b545f20b625cadcb37fba4fb09468c2c17a04d1dce14f665b2cdd4ac14e664d2a79fd
6
+ metadata.gz: e9c808ed77df3bc880db7a790ca207b6b6beb98be447f27f55fdcd25dc32c1131bb06d6d69e47de076b590ff4182e250b6b752b3bf2439ef0f94a2168d3acc40
7
+ data.tar.gz: fcfb725ce863649b098cea94314d612a5b755abd996199ed63a3e8018baef804790b8ce57e02229fed75c3247597f2030aab3bec47d0a544eb81586c45548722
data/.rubocop.yml CHANGED
@@ -1,18 +1,20 @@
1
1
  inherit_from: .rubocop_todo.yml
2
2
 
3
3
  AllCops:
4
- TargetRubyVersion: 1.9
4
+ TargetRubyVersion: 2.4
5
+ NewCops: enable
6
+ SuggestExtensions: false
5
7
 
6
8
  # not Ruby 1.9.3 compatible
7
9
  Style/PercentLiteralDelimiters:
8
10
  Enabled: false
9
11
 
10
- # Offense count: 5
11
- Encoding:
12
- Enabled: false
12
+ # Enforce trailing comma after last item of multiline arrays.
13
+ Style/TrailingCommaInArrayLiteral:
14
+ EnforcedStyleForMultiline: comma
13
15
 
14
16
  # Enforce trailing comma after last item of multiline hashes.
15
- Style/TrailingCommaInLiteral:
17
+ Style/TrailingCommaInHashLiteral:
16
18
  EnforcedStyleForMultiline: comma
17
19
 
18
20
  Metrics/BlockLength:
@@ -27,7 +29,7 @@ Style/ParallelAssignment:
27
29
  Style/NumericLiteralPrefix:
28
30
  EnforcedOctalStyle: zero_only
29
31
 
30
- Style/MethodMissing:
32
+ Style/MissingRespondToMissing:
31
33
  Enabled: false
32
34
 
33
35
  Layout/SpaceInsideStringInterpolation:
@@ -42,3 +44,21 @@ Style/EmptyMethod:
42
44
  Metrics/ModuleLength:
43
45
  CountComments: false # count full line comments?
44
46
  Max: 150
47
+
48
+ Lint/EmptyBlock:
49
+ Enabled: false
50
+
51
+ Style/FormatStringToken:
52
+ Enabled: false
53
+
54
+ Style/MixinUsage:
55
+ Enabled: false
56
+
57
+ Lint/ErbNewArguments:
58
+ Enabled: false
59
+
60
+ Style/DocumentDynamicEvalDefinition:
61
+ Enabled: false
62
+
63
+ Naming/HeredocDelimiterNaming:
64
+ Enabled: false
data/.rubocop_todo.yml CHANGED
@@ -10,12 +10,12 @@ Security/Eval:
10
10
  Enabled: false
11
11
 
12
12
  # Offense count: 2
13
- Lint/HandleExceptions:
13
+ Lint/SuppressedException:
14
14
  Enabled: false
15
15
 
16
16
  # Offense count: 5
17
17
  Metrics/AbcSize:
18
- Max: 29
18
+ Max: 30
19
19
 
20
20
  # Offense count: 1
21
21
  # Configuration parameters: CountComments.
@@ -28,7 +28,7 @@ Metrics/CyclomaticComplexity:
28
28
 
29
29
  # Offense count: 89
30
30
  # Configuration parameters: AllowURI, URISchemes.
31
- Metrics/LineLength:
31
+ Layout/LineLength:
32
32
  Max: 242
33
33
 
34
34
  # Offense count: 7
@@ -41,7 +41,7 @@ Metrics/PerceivedComplexity:
41
41
  Max: 14
42
42
 
43
43
  # Offense count: 1
44
- Style/AccessorMethodName:
44
+ Naming/AccessorMethodName:
45
45
  Enabled: false
46
46
 
47
47
  # Offense count: 18
data/.travis.yml CHANGED
@@ -4,10 +4,10 @@ before_install:
4
4
  - gem update --system
5
5
  - gem update bundler
6
6
  rvm:
7
- - 2.3
8
7
  - 2.4
9
8
  - 2.5
10
9
  - 2.6
11
10
  - 2.7
11
+ - 3.0
12
12
  - jruby
13
13
  - ruby-head
data/Gemfile CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  source 'https://rubygems.org'
2
4
 
3
5
  gemspec
data/History.rdoc CHANGED
@@ -1,3 +1,9 @@
1
+ === 4.6.0 / 2021-04-09
2
+
3
+ * Fix error with SortedSet on Ruby 3.0 (#98).
4
+ * Remove `#reset_io` as it didn't do anything.
5
+ * Drop support for Ruby < 2.4.
6
+
1
7
  === 4.5.2 / 2020-03-12
2
8
 
3
9
  * Fix bug handling global options provided in option=value form (#47). (@orien)
data/Rakefile CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'bundler/gem_tasks'
2
4
  require 'rspec/core/rake_task'
3
5
  require 'rubocop/rake_task'
@@ -10,4 +12,4 @@ end
10
12
 
11
13
  RuboCop::RakeTask.new
12
14
 
13
- task default: [:spec, :rubocop]
15
+ task default: %i[spec rubocop]
data/bin/commander CHANGED
@@ -1,4 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
2
3
 
3
4
  require 'rubygems'
4
5
  require 'commander/import'
@@ -97,7 +98,7 @@ command :init do |c|
97
98
  File.chmod 0755, file
98
99
  say "Initialized template in #{file}"
99
100
  end
100
- rescue => e
101
+ rescue StandardError => e
101
102
  abort e
102
103
  end
103
104
  end
data/commander.gemspec CHANGED
@@ -1,6 +1,6 @@
1
- # -*- encoding: utf-8 -*-
1
+ # frozen_string_literal: true
2
2
 
3
- $LOAD_PATH.push File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.push File.expand_path('lib', __dir__)
4
4
  require 'commander/version'
5
5
 
6
6
  Gem::Specification.new do |s|
@@ -13,12 +13,13 @@ Gem::Specification.new do |s|
13
13
  s.summary = 'The complete solution for Ruby command-line executables'
14
14
  s.description = 'The complete solution for Ruby command-line executables. Commander bridges the gap between other terminal related libraries you know and love (OptionParser, HighLine), while providing many new features, and an elegant API.'
15
15
  s.metadata = {
16
- 'bug_tracker_uri' => "#{s.homepage}/issues",
17
- 'changelog_uri' => "#{s.homepage}/blob/master/History.rdoc",
16
+ 'bug_tracker_uri' => "#{s.homepage}/issues",
17
+ 'changelog_uri' => "#{s.homepage}/blob/master/History.rdoc",
18
18
  'documentation_uri' => "https://www.rubydoc.info/gems/commander/#{s.version}",
19
- 'homepage_uri' => s.homepage,
20
- 'source_code_uri' => "#{s.homepage}/tree/v#{s.version}",
19
+ 'homepage_uri' => s.homepage,
20
+ 'source_code_uri' => "#{s.homepage}/tree/v#{s.version}",
21
21
  }
22
+ s.required_ruby_version = '>= 2.4'
22
23
 
23
24
  s.files = `git ls-files`.split("\n")
24
25
  s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
@@ -27,13 +28,8 @@ Gem::Specification.new do |s|
27
28
 
28
29
  s.add_runtime_dependency('highline', '~> 2.0.0')
29
30
 
30
- s.add_development_dependency('rspec', '~> 3.2')
31
31
  s.add_development_dependency('rake')
32
+ s.add_development_dependency('rspec', '~> 3.2')
33
+ s.add_development_dependency('rubocop', '~> 1.12.1')
32
34
  s.add_development_dependency('simplecov')
33
- if RUBY_VERSION < '2.0'
34
- s.add_development_dependency('rubocop', '~> 0.41.1')
35
- s.add_development_dependency('json', '< 2.0')
36
- else
37
- s.add_development_dependency('rubocop', '~> 0.49.1')
38
- end
39
35
  end
data/lib/commander.rb CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  #--
2
4
  # Copyright (c) 2008-2009 TJ Holowaychuk <tj@vision-media.ca>
3
5
  #
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Blank
2
4
  def self.included(base)
3
5
  base.class_eval do
@@ -1,9 +1,10 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'optparse'
2
4
 
3
5
  module Commander
4
6
  class Command
5
- attr_accessor :name, :examples, :syntax, :description
6
- attr_accessor :summary, :proxy_options, :options
7
+ attr_accessor :name, :examples, :syntax, :description, :summary, :proxy_options, :options
7
8
  attr_reader :global_options
8
9
 
9
10
  ##
@@ -140,6 +141,7 @@ module Commander
140
141
 
141
142
  def when_called(*args, &block)
142
143
  fail ArgumentError, 'must pass an object, class, or block.' if args.empty? && !block
144
+
143
145
  @when_called = block ? [block] : args
144
146
  end
145
147
  alias action when_called
@@ -163,6 +165,7 @@ module Commander
163
165
 
164
166
  def parse_options_and_call_procs(*args)
165
167
  return args if args.empty?
168
+
166
169
  # empty proxy_options before populating via OptionParser
167
170
  # prevents duplication of options if the command is run twice
168
171
  proxy_options.clear
@@ -182,8 +185,8 @@ module Commander
182
185
 
183
186
  case object
184
187
  when Proc then object.call(args, options)
185
- when Class then meth != :call ? object.new.send(meth, args, options) : object.new(args, options)
186
- else object.send(meth, args, options) if object
188
+ when Class then meth == :call ? object.new(args, options) : object.new.send(meth, args, options)
189
+ else object&.send(meth, args, options)
187
190
  end
188
191
  end
189
192
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Commander
2
4
  def configure(*configuration_opts, &configuration_block)
3
5
  configuration_module = Module.new
@@ -1,2 +1,4 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'commander/core_ext/array'
2
4
  require 'commander/core_ext/object'
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class Array
2
4
  ##
3
5
  # Split _string_ into an array. Used in
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class Object
2
4
  ##
3
5
  # Return the current binding.
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Commander
2
4
  module Delegates
3
5
  %w(
@@ -11,7 +13,7 @@ module Commander
11
13
  always_trace!
12
14
  never_trace!
13
15
  ).each do |meth|
14
- eval <<-END, binding, __FILE__, __LINE__
16
+ eval <<-END, binding, __FILE__, __LINE__ + 1
15
17
  def #{meth}(*args, &block)
16
18
  ::Commander::Runner.instance.#{meth}(*args, &block)
17
19
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Commander
2
4
  module HelpFormatter
3
5
  autoload :Base, 'commander/help_formatters/base'
@@ -43,7 +45,7 @@ module Commander
43
45
  module_function
44
46
 
45
47
  def indent(amount, text)
46
- text.to_s.gsub("\n", "\n" + (' ' * amount))
48
+ text.to_s.gsub("\n", "\n#{' ' * amount}")
47
49
  end
48
50
  end
49
51
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Commander
2
4
  ##
3
5
  # = Help Formatter
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'erb'
2
4
 
3
5
  module Commander
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'erb'
2
4
 
3
5
  module Commander
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'commander'
2
4
 
3
5
  include Commander::Methods
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Commander
2
4
  module Methods
3
5
  include Commander::UI
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Commander
2
4
  module Platform
3
5
  def self.jruby?
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'optparse'
2
4
 
3
5
  module Commander
@@ -7,22 +9,10 @@ module Commander
7
9
  #++
8
10
 
9
11
  class CommandError < StandardError; end
10
- class InvalidCommandError < CommandError; end
11
-
12
- ##
13
- # Array of commands.
14
-
15
- attr_reader :commands
16
12
 
17
- ##
18
- # Global options.
19
-
20
- attr_reader :options
21
-
22
- ##
23
- # Hash of help formatter aliases.
13
+ class InvalidCommandError < CommandError; end
24
14
 
25
- attr_reader :help_formatter_aliases
15
+ attr_reader :commands, :options, :help_formatter_aliases
26
16
 
27
17
  ##
28
18
  # Initialize a new command runner. Optionally
@@ -41,7 +31,7 @@ module Commander
41
31
  # Return singleton Runner instance.
42
32
 
43
33
  def self.instance
44
- @singleton ||= new
34
+ @instance ||= new
45
35
  end
46
36
 
47
37
  ##
@@ -76,7 +66,7 @@ module Commander
76
66
  OptionParser::InvalidArgument,
77
67
  OptionParser::MissingArgument => e
78
68
  abort e.to_s
79
- rescue => e
69
+ rescue StandardError => e
80
70
  if @never_trace
81
71
  abort "error: #{e}."
82
72
  else
@@ -231,15 +221,16 @@ module Commander
231
221
  # Get active command within arguments passed to this runner.
232
222
 
233
223
  def active_command
234
- @__active_command ||= command(command_name_from_args)
224
+ @active_command ||= command(command_name_from_args)
235
225
  end
236
226
 
237
227
  ##
238
228
  # Attempts to locate a command name from within the arguments.
239
229
  # Supports multi-word commands, using the largest possible match.
230
+ # Returns the default command, if no valid commands found in the args.
240
231
 
241
232
  def command_name_from_args
242
- @__command_name_from_args ||= (valid_command_names_from(*@args.dup).sort.last || @default_command)
233
+ @command_name_from_args ||= (longest_valid_command_name_from(@args) || @default_command)
243
234
  end
244
235
 
245
236
  ##
@@ -255,7 +246,7 @@ module Commander
255
246
  # Help formatter instance.
256
247
 
257
248
  def help_formatter
258
- @__help_formatter ||= program(:help_formatter).new self
249
+ @help_formatter ||= program(:help_formatter).new self
259
250
  end
260
251
 
261
252
  ##
@@ -304,7 +295,7 @@ module Commander
304
295
  if args.empty?
305
296
  say help_formatter.render
306
297
  else
307
- command = command args.join(' ')
298
+ command = command(longest_valid_command_name_from(args))
308
299
  begin
309
300
  require_valid_command command
310
301
  rescue InvalidCommandError => e
@@ -332,6 +323,7 @@ module Commander
332
323
  options.each do |option|
333
324
  switches = option[:switches]
334
325
  next if switches.empty?
326
+
335
327
  option_takes_argument = switches.any? { |s| s =~ /[ =]/ }
336
328
  switches = expand_optionally_negative_switches(switches)
337
329
 
@@ -456,5 +448,15 @@ module Commander
456
448
  def say(*args) #:nodoc:
457
449
  HighLine.default_instance.say(*args)
458
450
  end
451
+
452
+ private
453
+
454
+ ##
455
+ # Attempts to locate a command name from within the provided arguments.
456
+ # Supports multi-word commands, using the largest possible match.
457
+
458
+ def longest_valid_command_name_from(args)
459
+ valid_command_names_from(*args.dup).max
460
+ end
459
461
  end
460
462
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'tempfile'
2
4
  require 'shellwords'
3
5
 
@@ -218,20 +220,16 @@ module Commander
218
220
  #
219
221
 
220
222
  def io(input = nil, output = nil, &block)
223
+ orig_stdin, orig_stdout = $stdin, $stdout
221
224
  $stdin = File.new(input) if input
222
225
  $stdout = File.new(output, 'r+') if output
223
226
  return unless block
227
+
224
228
  yield
229
+ $stdin, $stdout = orig_stdin, orig_stdout
225
230
  reset_io
226
231
  end
227
232
 
228
- ##
229
- # Reset IO to initial constant streams.
230
-
231
- def reset_io
232
- $stdin, $stdout = STDIN, STDOUT
233
- end
234
-
235
233
  ##
236
234
  # Find an editor available in path. Optionally supply the _preferred_
237
235
  # editor. Returns the name as a string, nil if none is available.
@@ -274,6 +272,7 @@ module Commander
274
272
  def enable_paging
275
273
  return unless $stdout.tty?
276
274
  return unless Process.respond_to? :fork
275
+
277
276
  read, write = IO.pipe
278
277
 
279
278
  # Kernel.fork is not supported on all platforms and configurations.
@@ -324,7 +323,7 @@ module Commander
324
323
  # Implements ask_for_CLASS methods.
325
324
 
326
325
  module AskForClass
327
- DEPRECATED_CONSTANTS = [:Config, :TimeoutError, :MissingSourceFile, :NIL, :TRUE, :FALSE, :Fixnum, :Bignum, :Data].freeze
326
+ DEPRECATED_CONSTANTS = %i[Config TimeoutError MissingSourceFile NIL TRUE FALSE Fixnum Bignum Data].freeze
328
327
 
329
328
  # define methods for common classes
330
329
  [Float, Integer, String, Symbol, Regexp, Array, File, Pathname].each do |klass|
@@ -338,15 +337,21 @@ module Commander
338
337
  if arguments.count != 1
339
338
  fail ArgumentError, "wrong number of arguments (given #{arguments.count}, expected 1)"
340
339
  end
340
+
341
341
  prompt = arguments.first
342
342
  requested_class = Regexp.last_match[1]
343
343
 
344
344
  # All Classes that respond to #parse
345
345
  # Ignore constants that trigger deprecation warnings
346
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)
347
+ begin
348
+ Object.const_get(const)
349
+ rescue RuntimeError
350
+ # Rescue errors in Ruby 3 for SortedSet:
351
+ # The `SortedSet` class has been extracted from the `set` library.
352
+ end
353
+ end.compact.select do |const|
354
+ const.instance_of?(Class) && const.respond_to?(:parse)
350
355
  end
351
356
 
352
357
  klass = available_classes.find { |k| k.to_s.downcase == requested_class }
@@ -498,7 +503,7 @@ module Commander
498
503
  steps_remaining: steps_remaining,
499
504
  total_steps: @total_steps,
500
505
  time_elapsed: format('%0.2fs', time_elapsed),
501
- time_remaining: @step > 0 ? format('%0.2fs', time_remaining) : '',
506
+ time_remaining: @step.positive? ? format('%0.2fs', time_remaining) : '',
502
507
  }.merge! @tokens
503
508
  end
504
509
 
@@ -507,6 +512,7 @@ module Commander
507
512
 
508
513
  def show
509
514
  return if finished?
515
+
510
516
  erase_line
511
517
  if completed?
512
518
  HighLine.default_instance.say UI.replace_tokens(@complete_message, generate_tokens) if @complete_message.is_a? String
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Commander
2
- VERSION = '4.5.2'.freeze
4
+ VERSION = '4.6.0'
3
5
  end
data/spec/command_spec.rb CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  describe Commander::Command do
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
  require 'commander/configure'
3
5
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  describe Array do
@@ -12,7 +14,7 @@ describe Array do
12
14
 
13
15
  it 'should match %w behavior with multiple backslashes' do
14
16
  str = 'just a\\ test'
15
- expect(Array.parse(str)).to eq(eval("%w(#{str})"))
17
+ expect(Array.parse(str)).to eq(['just', 'a test'])
16
18
  end
17
19
  end
18
20
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  describe Object do
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  describe Commander::HelpFormatter::TerminalCompact do
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  describe Commander::HelpFormatter::Terminal do
data/spec/methods_spec.rb CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
  require 'commander/methods'
3
5
 
data/spec/runner_spec.rb CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  describe Commander do
@@ -484,6 +486,22 @@ describe Commander do
484
486
  expect(run('test', '--help')).to eq("Implement help for test here\n")
485
487
  end
486
488
 
489
+ it 'can be used after the command and command arguments' do
490
+ expect(run('test', 'command-arg', '--help')).to eq("Implement help for test here\n")
491
+ end
492
+
493
+ it 'can be used before a single-word command with command arguments' do
494
+ expect(run('help', 'test', 'command-arg')).to eq("Implement help for test here\n")
495
+ end
496
+
497
+ it 'can be used before a multi-word command with command arguments' do
498
+ expect(
499
+ run('help', 'module', 'install', 'command-arg') do
500
+ command('module install') { |c| c.when_called { say 'whee!' } }
501
+ end
502
+ ).to eq("Implement help for module install here\n")
503
+ end
504
+
487
505
  describe 'help_paging program information' do
488
506
  it 'enables paging when enabled' do
489
507
  run('--help') { program :help_paging, true }
data/spec/spec_helper.rb CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'rubygems'
2
4
  require 'stringio'
3
5
  require 'simplecov'
@@ -6,7 +8,7 @@ SimpleCov.start do
6
8
  end
7
9
 
8
10
  # Unshift so that local files load instead of something in gems
9
- $LOAD_PATH.unshift File.dirname(__FILE__) + '/../lib'
11
+ $LOAD_PATH.unshift "#{File.dirname(__FILE__)}/../lib"
10
12
 
11
13
  # This basically replicates the behavior of `require 'commander/import'`
12
14
  # but without adding an `at_exit` hook, which interferes with exit code
@@ -49,7 +51,7 @@ end
49
51
  # Create a new command runner
50
52
 
51
53
  def new_command_runner(*args, &block)
52
- Commander::Runner.instance_variable_set :"@singleton", Commander::Runner.new(args)
54
+ Commander::Runner.instance_variable_set :@instance, Commander::Runner.new(args)
53
55
  program :name, 'test'
54
56
  program :version, '1.2.3'
55
57
  program :description, 'something'
data/spec/ui_spec.rb CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  describe Commander::UI do
@@ -5,7 +7,7 @@ describe Commander::UI do
5
7
 
6
8
  describe '.replace_tokens' do
7
9
  it 'should replace tokens within a string, with hash values' do
8
- result = Commander::UI.replace_tokens 'Welcome :name, enjoy your :object'.freeze, name: 'TJ', object: 'cookie'
10
+ result = Commander::UI.replace_tokens 'Welcome :name, enjoy your :object', name: 'TJ', object: 'cookie'
9
11
  expect(result).to eq('Welcome TJ, enjoy your cookie')
10
12
  end
11
13
  end
@@ -15,7 +17,7 @@ describe Commander::UI do
15
17
  exception = false
16
18
  begin
17
19
  progress([]) {}
18
- rescue
20
+ rescue StandardError
19
21
  exception = true
20
22
  end
21
23
  expect(exception).not_to be true
metadata CHANGED
@@ -1,15 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: commander
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.5.2
4
+ version: 4.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - TJ Holowaychuk
8
8
  - Gabriel Gilder
9
- autorequire:
9
+ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2020-03-12 00:00:00.000000000 Z
12
+ date: 2021-04-09 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: highline
@@ -25,6 +25,20 @@ dependencies:
25
25
  - - "~>"
26
26
  - !ruby/object:Gem::Version
27
27
  version: 2.0.0
28
+ - !ruby/object:Gem::Dependency
29
+ name: rake
30
+ requirement: !ruby/object:Gem::Requirement
31
+ requirements:
32
+ - - ">="
33
+ - !ruby/object:Gem::Version
34
+ version: '0'
35
+ type: :development
36
+ prerelease: false
37
+ version_requirements: !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - ">="
40
+ - !ruby/object:Gem::Version
41
+ version: '0'
28
42
  - !ruby/object:Gem::Dependency
29
43
  name: rspec
30
44
  requirement: !ruby/object:Gem::Requirement
@@ -40,19 +54,19 @@ dependencies:
40
54
  - !ruby/object:Gem::Version
41
55
  version: '3.2'
42
56
  - !ruby/object:Gem::Dependency
43
- name: rake
57
+ name: rubocop
44
58
  requirement: !ruby/object:Gem::Requirement
45
59
  requirements:
46
- - - ">="
60
+ - - "~>"
47
61
  - !ruby/object:Gem::Version
48
- version: '0'
62
+ version: 1.12.1
49
63
  type: :development
50
64
  prerelease: false
51
65
  version_requirements: !ruby/object:Gem::Requirement
52
66
  requirements:
53
- - - ">="
67
+ - - "~>"
54
68
  - !ruby/object:Gem::Version
55
- version: '0'
69
+ version: 1.12.1
56
70
  - !ruby/object:Gem::Dependency
57
71
  name: simplecov
58
72
  requirement: !ruby/object:Gem::Requirement
@@ -67,20 +81,6 @@ dependencies:
67
81
  - - ">="
68
82
  - !ruby/object:Gem::Version
69
83
  version: '0'
70
- - !ruby/object:Gem::Dependency
71
- name: rubocop
72
- requirement: !ruby/object:Gem::Requirement
73
- requirements:
74
- - - "~>"
75
- - !ruby/object:Gem::Version
76
- version: 0.49.1
77
- type: :development
78
- prerelease: false
79
- version_requirements: !ruby/object:Gem::Requirement
80
- requirements:
81
- - - "~>"
82
- - !ruby/object:Gem::Version
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.
@@ -143,10 +143,10 @@ licenses:
143
143
  metadata:
144
144
  bug_tracker_uri: https://github.com/commander-rb/commander/issues
145
145
  changelog_uri: https://github.com/commander-rb/commander/blob/master/History.rdoc
146
- documentation_uri: https://www.rubydoc.info/gems/commander/4.5.2
146
+ documentation_uri: https://www.rubydoc.info/gems/commander/4.6.0
147
147
  homepage_uri: https://github.com/commander-rb/commander
148
- source_code_uri: https://github.com/commander-rb/commander/tree/v4.5.2
149
- post_install_message:
148
+ source_code_uri: https://github.com/commander-rb/commander/tree/v4.6.0
149
+ post_install_message:
150
150
  rdoc_options: []
151
151
  require_paths:
152
152
  - lib
@@ -154,15 +154,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
154
154
  requirements:
155
155
  - - ">="
156
156
  - !ruby/object:Gem::Version
157
- version: '0'
157
+ version: '2.4'
158
158
  required_rubygems_version: !ruby/object:Gem::Requirement
159
159
  requirements:
160
160
  - - ">="
161
161
  - !ruby/object:Gem::Version
162
162
  version: '0'
163
163
  requirements: []
164
- rubygems_version: 3.0.6
165
- signing_key:
164
+ rubygems_version: 3.2.15
165
+ signing_key:
166
166
  specification_version: 4
167
167
  summary: The complete solution for Ruby command-line executables
168
168
  test_files: