[DRE-commits] [ruby-commander] 03/11: New upstream version 4.4.2

Daisuke Higuchi dai at moszumanska.debian.org
Sat Oct 21 12:40:36 UTC 2017


This is an automated email from the git hooks/post-receive script.

dai pushed a commit to branch master
in repository ruby-commander.

commit e2fbe04c052d28487e2dc341a70d5f90a117395c
Author: HIGUCHI Daisuke (VDR dai) <dai at debian.org>
Date:   Sat Oct 21 21:16:44 2017 +0900

    New upstream version 4.4.2
---
 .rubocop.yml                      | 30 +++++++++++++++++++++++++++++-
 History.rdoc                      |  4 ++++
 commander.gemspec                 |  4 +++-
 lib/commander/command.rb          |  2 +-
 lib/commander/runner.rb           |  8 +++++---
 lib/commander/user_interaction.rb |  2 +-
 lib/commander/version.rb          |  2 +-
 spec/runner_spec.rb               | 17 +++++++++++++++++
 spec/spec_helper.rb               |  1 +
 9 files changed, 62 insertions(+), 8 deletions(-)

diff --git a/.rubocop.yml b/.rubocop.yml
index a44b4d9..d532eda 100644
--- a/.rubocop.yml
+++ b/.rubocop.yml
@@ -5,5 +5,33 @@ Encoding:
   Enabled: false
 
 # Enforce trailing comma after last item of multiline hashes.
-Style/TrailingComma:
+Style/TrailingCommaInLiteral:
   EnforcedStyleForMultiline: comma
+
+Metrics/BlockLength:
+  Enabled: false
+
+Style/SignalException:
+  EnforcedStyle: only_fail
+
+Style/ParallelAssignment:
+  Enabled: false
+
+Style/NumericLiteralPrefix:
+  EnforcedOctalStyle: zero_only
+
+Style/MethodMissing:
+  Enabled: false
+
+Style/SpaceInsideStringInterpolation:
+  Enabled: false
+
+Style/MultilineOperationIndentation:
+  Enabled: false
+
+Style/EmptyMethod:
+  EnforcedStyle: expanded
+
+Metrics/ModuleLength:
+  CountComments: false  # count full line comments?
+  Max: 150
diff --git a/History.rdoc b/History.rdoc
index d05c0e9..3323302 100644
--- a/History.rdoc
+++ b/History.rdoc
@@ -1,3 +1,7 @@
+=== 4.4.2 / 2016-12-20
+
+* Add `help_paging` program flag so that help paging may be disabled. (@gogiel)
+
 === 4.4.1 / 2016-12-02
 
 * Fix #36 - Warning about MissingSourceFile (@fallwith)
diff --git a/commander.gemspec b/commander.gemspec
index 1990387..f67eb11 100644
--- a/commander.gemspec
+++ b/commander.gemspec
@@ -22,8 +22,10 @@ Gem::Specification.new do |s|
   s.add_development_dependency('rspec', '~> 3.2')
   s.add_development_dependency('rake')
   s.add_development_dependency('simplecov')
-  s.add_development_dependency('rubocop', '~> 0.29.1')
   if RUBY_VERSION < '2.0'
+    s.add_development_dependency('rubocop', '~> 0.41.1')
     s.add_development_dependency('json', '< 2.0')
+  else
+    s.add_development_dependency('rubocop', '~> 0.46')
   end
 end
diff --git a/lib/commander/command.rb b/lib/commander/command.rb
index fb15816..f5edf76 100644
--- a/lib/commander/command.rb
+++ b/lib/commander/command.rb
@@ -140,7 +140,7 @@ module Commander
       fail ArgumentError, 'must pass an object, class, or block.' if args.empty? && !block
       @when_called = block ? [block] : args
     end
-    alias_method :action, :when_called
+    alias action when_called
 
     ##
     # Run the command with _args_.
diff --git a/lib/commander/runner.rb b/lib/commander/runner.rb
index 1d90d5f..8ca340f 100644
--- a/lib/commander/runner.rb
+++ b/lib/commander/runner.rb
@@ -134,6 +134,7 @@ module Commander
     #   :name            Program name, defaults to basename of executable
     #   :help_formatter  Defaults to Commander::HelpFormatter::Terminal
     #   :help            Allows addition of arbitrary global help blocks
+    #   :help_paging     Flag for toggling help paging
     #   :int_message     Message to display when interrupted (CTRL + C)
     #
 
@@ -147,7 +148,7 @@ module Commander
         @program[key] = block
       else
         unless args.empty?
-          @program[key] = (args.count == 1 && args[0]) || args
+          @program[key] = args.count == 1 ? args[0] : args
         end
         @program[key]
       end
@@ -246,7 +247,7 @@ module Commander
 
     def valid_command_names_from(*args)
       arg_string = args.delete_if { |value| value =~ /^-/ }.join ' '
-      commands.keys.find_all { |name| name if /^#{name}\b/.match arg_string }
+      commands.keys.find_all { |name| name if arg_string =~ /^#{name}\b/ }
     end
 
     ##
@@ -283,6 +284,7 @@ module Commander
       {
         help_formatter: HelpFormatter::Terminal,
         name: File.basename($PROGRAM_NAME),
+        help_paging: true,
       }
     end
 
@@ -297,7 +299,7 @@ module Commander
         c.example 'Display global help', 'command help'
         c.example "Display help for 'foo'", 'command help foo'
         c.when_called do |args, _options|
-          UI.enable_paging
+          UI.enable_paging if program(:help_paging)
           if args.empty?
             say help_formatter.render
           else
diff --git a/lib/commander/user_interaction.rb b/lib/commander/user_interaction.rb
index 08b5923..91bed1f 100644
--- a/lib/commander/user_interaction.rb
+++ b/lib/commander/user_interaction.rb
@@ -181,7 +181,7 @@ module Commander
           #{statement}
           end if
         end tell
-        ),
+        )
       ).strip.to_sym
     end
 
diff --git a/lib/commander/version.rb b/lib/commander/version.rb
index faa019f..1da2b93 100644
--- a/lib/commander/version.rb
+++ b/lib/commander/version.rb
@@ -1,3 +1,3 @@
 module Commander
-  VERSION = '4.4.1'
+  VERSION = '4.4.2'.freeze
 end
diff --git a/spec/runner_spec.rb b/spec/runner_spec.rb
index 828f308..ebff198 100644
--- a/spec/runner_spec.rb
+++ b/spec/runner_spec.rb
@@ -407,6 +407,23 @@ describe Commander do
     it 'can be used before or after the command and options' do
       expect(run('test', '--help')).to eq("Implement help for test here\n")
     end
+
+    describe 'help_paging program information' do
+      it 'enables paging when enabled' do
+        run('--help') { program :help_paging, true }
+        expect(Commander::UI).to have_received(:enable_paging)
+      end
+
+      it 'is enabled by default' do
+        run('--help')
+        expect(Commander::UI).to have_received(:enable_paging)
+      end
+
+      it 'does not enable paging when disabled' do
+        run('--help') { program :help_paging, false }
+        expect(Commander::UI).not_to have_received(:enable_paging)
+      end
+    end
   end
 
   describe 'with invalid options' do
diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb
index 83ed668..9426755 100644
--- a/spec/spec_helper.rb
+++ b/spec/spec_helper.rb
@@ -58,6 +58,7 @@ end
 def run(*args)
   new_command_runner(*args) do
     program :help_formatter, Commander::HelpFormatter::Base
+    yield if block_given?
   end.run!
   @output.string
 end

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-ruby-extras/ruby-commander.git



More information about the Pkg-ruby-extras-commits mailing list