[logaling-commit] logaling/logaling-command [fix-format-output] Use TermDefaultRenderer when executing show command

Back to archive index

null+****@clear***** null+****@clear*****
Fri Jul 20 01:04:06 JST 2012


SHIMADA Koji	2012-07-20 01:04:06 +0900 (Fri, 20 Jul 2012)

  New Revision: 4222bb49c3241ee7c3aa57b16721561e350835f4
  https://github.com/logaling/logaling-command/commit/4222bb49c3241ee7c3aa57b16721561e350835f4

  Log:
    Use TermDefaultRenderer when executing show command

  Modified files:
    lib/logaling/command/application.rb
    lib/logaling/command/renderers.rb

  Modified: lib/logaling/command/application.rb (+4 -4)
===================================================================
--- lib/logaling/command/application.rb    2012-07-18 17:14:07 +0900 (04bd85c)
+++ lib/logaling/command/application.rb    2012-07-20 01:04:06 +0900 (59149ef)
@@ -310,11 +310,11 @@ module Logaling::Command
       terms = glossary.terms
       unless terms.empty?
         run_pager
-        max_source_term_size = max_str_size(terms)
         terms.each do |term|
-          target_string = "#{term[:target_term]}"
-          target_string <<  "\t# #{term[:note]}" unless term[:note].empty?
-          printf("  %-#{max_source_term_size+10}s %s\n", term[:source_term], target_string)
+          term_renderer = Logaling::Command::Renderers::TermDefaultRenderer.new(term, @repository, @config, options)
+          term_renderer.max_str_size = max_str_size(terms)
+          term_renderer.hide_glossary_name
+          term_renderer.render($stdout)
         end
       else
         "glossary <#{@config.glossary}> not found"

  Modified: lib/logaling/command/renderers.rb (+9 -1)
===================================================================
--- lib/logaling/command/renderers.rb    2012-07-18 17:14:07 +0900 (3376944)
+++ lib/logaling/command/renderers.rb    2012-07-20 01:04:06 +0900 (d63babc)
@@ -80,6 +80,10 @@ module Logaling::Command
 
       def initialize(term, repository, config, options)
         super
+        @term[:snipped_source_term] = [@term[:source_term]]
+        @term[:snipped_target_term] = [@term[:target_term]]
+        @render_option = {}
+        @render_option[:show_glossary] = true
         @max_str_size = 0
       end
 
@@ -90,7 +94,7 @@ module Logaling::Command
       end
 
       def glossary_name
-        if****@repos*****_counts > 1
+        if @render_option[:show_glossary] && @repository.glossary_counts > 1
           if @term[:glossary_name] ==****@confi*****
             @term[:glossary_name].foreground(:white).background(:green)
           else
@@ -105,6 +109,10 @@ module Logaling::Command
         note_string = super
         "# #{note_string}" if note_string
       end
+
+      def hide_glossary_name
+        @render_option[:show_glossary] = false
+      end
     end
 
     class TermCsvRenderer < TermRenderer
-------------- next part --------------
An HTML attachment was scrubbed...
다운로드 



More information about the logaling-commit mailing list
Back to archive index