Hello community,

here is the log from the commit of package rubygem-commander for 
openSUSE:Factory checked in at 2015-05-06 07:49:22
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/rubygem-commander (Old)
 and      /work/SRC/openSUSE:Factory/.rubygem-commander.new (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "rubygem-commander"

Changes:
--------
--- /work/SRC/openSUSE:Factory/rubygem-commander/rubygem-commander.changes      
2015-04-25 14:09:06.000000000 +0200
+++ /work/SRC/openSUSE:Factory/.rubygem-commander.new/rubygem-commander.changes 
2015-05-06 07:49:42.000000000 +0200
@@ -1,0 +2,10 @@
+Mon May  4 04:29:01 UTC 2015 - [email protected]
+
+- updated to version 4.3.4
+ see installed History.rdoc
+
+  === 4.3.4 / 2015-05-03
+  
+  * Fixed a regression with the compact help formatter.
+
+-------------------------------------------------------------------

Old:
----
  commander-4.3.3.gem

New:
----
  commander-4.3.4.gem

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Other differences:
------------------
++++++ rubygem-commander.spec ++++++
--- /var/tmp/diff_new_pack.NdoVwT/_old  2015-05-06 07:49:42.000000000 +0200
+++ /var/tmp/diff_new_pack.NdoVwT/_new  2015-05-06 07:49:42.000000000 +0200
@@ -24,7 +24,7 @@
 #
 
 Name:           rubygem-commander
-Version:        4.3.3
+Version:        4.3.4
 Release:        0
 %define mod_name commander
 %define mod_full_name %{mod_name}-%{version}

++++++ commander-4.3.3.gem -> commander-4.3.4.gem ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/History.rdoc new/History.rdoc
--- old/History.rdoc    2015-04-21 20:31:51.000000000 +0200
+++ new/History.rdoc    2015-05-04 04:02:45.000000000 +0200
@@ -1,6 +1,11 @@
+=== 4.3.4 / 2015-05-03
+
+* Fixed a regression with the compact help formatter.
+
 === 4.3.3 / 2015-04-21
 
 * Updated to highline 1.7.2 to fix a regression with terminal size 
(https://github.com/JEG2/highline/pull/139).
+* Help formatting updated to look better for commands with long names. 
(@jszwedko)
 
 === 4.3.2 / 2015-03-31
 
Files old/checksums.yaml.gz and new/checksums.yaml.gz differ
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/lib/commander/help_formatters/terminal/help.erb 
new/lib/commander/help_formatters/terminal/help.erb
--- old/lib/commander/help_formatters/terminal/help.erb 2015-04-21 
20:31:51.000000000 +0200
+++ new/lib/commander/help_formatters/terminal/help.erb 2015-05-04 
04:02:45.000000000 +0200
@@ -1,10 +1,3 @@
-<%
-  # TODO: move into formatter?
-  longest_command = @commands.keys.max_by(&:size)
-  max_command_length = longest_command ? longest_command.size : 20
-  longest_alias = @aliases.keys.max_by(&:size)
-  max_aliases_length = longest_alias ? longest_alias.size : 20
-%>
   <%= $terminal.color "NAME", :bold %>:
 
     <%= program :name %>
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/lib/commander/help_formatters/terminal.rb 
new/lib/commander/help_formatters/terminal.rb
--- old/lib/commander/help_formatters/terminal.rb       2015-04-21 
20:31:51.000000000 +0200
+++ new/lib/commander/help_formatters/terminal.rb       2015-05-04 
04:02:45.000000000 +0200
@@ -4,11 +4,11 @@
   module HelpFormatter
     class Terminal < Base
       def render
-        template(:help).result @runner.get_binding
+        template(:help).result(ProgramContext.new(@runner).get_binding)
       end
 
       def render_command(command)
-        template(:command_help).result command.get_binding
+        template(:command_help).result(Context.new(command).get_binding)
       end
 
       def template(name)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/lib/commander/help_formatters/terminal_compact/help.erb 
new/lib/commander/help_formatters/terminal_compact/help.erb
--- old/lib/commander/help_formatters/terminal_compact/help.erb 2015-04-21 
20:31:51.000000000 +0200
+++ new/lib/commander/help_formatters/terminal_compact/help.erb 2015-05-04 
04:02:45.000000000 +0200
@@ -1,5 +1,3 @@
-<% max_command_length = @commands.keys.max_by(&:size).size %>
-<% max_aliases_length = @aliases.keys.max_by(&:size).size %>
   <%= program :name %>
 
   <%= program :description %>
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/lib/commander/help_formatters.rb 
new/lib/commander/help_formatters.rb
--- old/lib/commander/help_formatters.rb        2015-04-21 20:31:51.000000000 
+0200
+++ new/lib/commander/help_formatters.rb        2015-05-04 04:02:45.000000000 
+0200
@@ -4,6 +4,42 @@
     autoload :Terminal, 'commander/help_formatters/terminal'
     autoload :TerminalCompact, 'commander/help_formatters/terminal_compact'
 
+    class Context
+      def initialize(target)
+        @target = target
+      end
+
+      def get_binding
+        @target.instance_eval { binding }.tap do |bind|
+          decorate_binding(bind)
+        end
+      end
+
+      # No-op, override in subclasses.
+      def decorate_binding(_bind)
+      end
+    end
+
+    class ProgramContext < Context
+      def decorate_binding(bind)
+        bind.eval("max_command_length = #{max_command_length(bind)}")
+        bind.eval("max_aliases_length = #{max_aliases_length(bind)}")
+      end
+
+      def max_command_length(bind)
+        max_key_length(bind.eval('@commands'))
+      end
+
+      def max_aliases_length(bind)
+        max_key_length(bind.eval('@aliases'))
+      end
+
+      def max_key_length(hash, default = 20)
+        longest = hash.keys.max_by(&:size)
+        longest ? longest.size : default
+      end
+    end
+
     module_function
 
     def indent(amount, text)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/lib/commander/version.rb new/lib/commander/version.rb
--- old/lib/commander/version.rb        2015-04-21 20:31:51.000000000 +0200
+++ new/lib/commander/version.rb        2015-05-04 04:02:45.000000000 +0200
@@ -1,3 +1,3 @@
 module Commander
-  VERSION = '4.3.3'
+  VERSION = '4.3.4'
 end
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/metadata new/metadata
--- old/metadata        2015-04-21 20:31:51.000000000 +0200
+++ new/metadata        2015-05-04 04:02:45.000000000 +0200
@@ -1,7 +1,7 @@
 --- !ruby/object:Gem::Specification
 name: commander
 version: !ruby/object:Gem::Version
-  version: 4.3.3
+  version: 4.3.4
 platform: ruby
 authors:
 - TJ Holowaychuk
@@ -9,7 +9,7 @@
 autorequire: 
 bindir: bin
 cert_chain: []
-date: 2015-04-21 00:00:00.000000000 Z
+date: 2015-05-04 00:00:00.000000000 Z
 dependencies:
 - !ruby/object:Gem::Dependency
   name: highline
@@ -131,6 +131,7 @@
 - spec/configure_spec.rb
 - spec/core_ext/array_spec.rb
 - spec/core_ext/object_spec.rb
+- spec/help_formatters/terminal_compact_spec.rb
 - spec/help_formatters/terminal_spec.rb
 - spec/methods_spec.rb
 - spec/runner_spec.rb
@@ -165,6 +166,7 @@
 - spec/configure_spec.rb
 - spec/core_ext/array_spec.rb
 - spec/core_ext/object_spec.rb
+- spec/help_formatters/terminal_compact_spec.rb
 - spec/help_formatters/terminal_spec.rb
 - spec/methods_spec.rb
 - spec/runner_spec.rb
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/spec/help_formatters/terminal_compact_spec.rb 
new/spec/help_formatters/terminal_compact_spec.rb
--- old/spec/help_formatters/terminal_compact_spec.rb   1970-01-01 
01:00:00.000000000 +0100
+++ new/spec/help_formatters/terminal_compact_spec.rb   2015-05-04 
04:02:45.000000000 +0200
@@ -0,0 +1,69 @@
+require 'spec_helper'
+
+describe Commander::HelpFormatter::TerminalCompact do
+  include Commander::Methods
+
+  before :each do
+    mock_terminal
+  end
+
+  describe 'global help' do
+    before :each do
+      new_command_runner 'help' do
+        program :help_formatter, :compact
+        command :'install gem' do |c|
+          c.syntax = 'foo install gem [options]'
+          c.summary = 'Install some gem'
+        end
+      end.run!
+      @global_help = @output.string
+    end
+
+    describe 'should display' do
+      it 'the command name' do
+        expect(@global_help).to include('install gem')
+      end
+
+      it 'the summary' do
+        expect(@global_help).to include('Install some gem')
+      end
+    end
+  end
+
+  describe 'command help' do
+    before :each do
+      new_command_runner 'help', 'install', 'gem' do
+        program :help_formatter, :compact
+        command :'install gem' do |c|
+          c.syntax = 'foo install gem [options]'
+          c.summary = 'Install some gem'
+          c.description = 'Install some gem, blah blah blah'
+          c.example 'one', 'two'
+          c.example 'three', 'four'
+        end
+      end.run!
+      @command_help = @output.string
+    end
+
+    describe 'should display' do
+      it 'the command name' do
+        expect(@command_help).to include('install gem')
+      end
+
+      it 'the description' do
+        expect(@command_help).to include('Install some gem, blah blah blah')
+      end
+
+      it 'all examples' do
+        expect(@command_help).to include('# one')
+        expect(@command_help).to include('two')
+        expect(@command_help).to include('# three')
+        expect(@command_help).to include('four')
+      end
+
+      it 'the syntax' do
+        expect(@command_help).to include('foo install gem [options]')
+      end
+    end
+  end
+end


Reply via email to