[logaling-commit] logaling/logaling-command [master] Reduce Repository#show_glossary arguments

Back to archive index

null+****@clear***** null+****@clear*****
Sat Feb 18 23:09:28 JST 2012


SHIMADA Koji	2012-02-18 23:09:28 +0900 (Sat, 18 Feb 2012)

  New Revision: dca5b901cb1fa1a4166e8229728008ae4391e239

  Merged fccddcf: Merge pull request #48 from logaling/improve-repository-interface

  Log:
    Reduce Repository#show_glossary arguments

  Modified files:
    lib/logaling/command/application.rb
    lib/logaling/glossary.rb
    lib/logaling/glossary_db.rb
    lib/logaling/repository.rb

  Modified: lib/logaling/command/application.rb (+1 -1)
===================================================================
--- lib/logaling/command/application.rb    2012-02-16 19:57:19 +0900 (b6e6b54)
+++ lib/logaling/command/application.rb    2012-02-18 23:09:28 +0900 (6b07789)
@@ -214,7 +214,7 @@ module Logaling::Command
       }
       @config.check_required_option(required_options)
       @repository.index
-      terms =****@repos*****_glossary(@config.glossary, @config.source_language, @config.target_language)
+      terms =****@repos*****_glossary(@glossary)
       unless terms.empty?
         run_pager
         max_str_size = terms.map{|term| term[:source_term].size}.sort.last

  Modified: lib/logaling/glossary.rb (+1 -0)
===================================================================
--- lib/logaling/glossary.rb    2012-02-16 19:57:19 +0900 (fbd9780)
+++ lib/logaling/glossary.rb    2012-02-18 23:09:28 +0900 (2bb0586)
@@ -66,6 +66,7 @@ module Logaling
         File.join(logaling_home, "projects", glossary, "glossary", "#{fname}.yml")
       end
     end
+    attr_reader :glossary, :source_language, :target_language
 
     def initialize(glossary, source_language, target_language, logaling_home)
       @path = Glossary.build_path(glossary, source_language, target_language, logaling_home)

  Modified: lib/logaling/glossary_db.rb (+4 -4)
===================================================================
--- lib/logaling/glossary_db.rb    2012-02-16 19:57:19 +0900 (fa77cec)
+++ lib/logaling/glossary_db.rb    2012-02-18 23:09:28 +0900 (9dc48ad)
@@ -123,12 +123,12 @@ module Logaling
       specified_glossary.expression.close
     end
 
-    def translation_list(glossary, source_language, target_language)
+    def translation_list(glossary_source)
       records_raw = Groonga["translations"].select do |record|
         [
-          record.glossary == glossary,
-          record.source_language == source_language,
-          record.target_language == target_language
+          record.glossary == glossary_source.glossary,
+          record.source_language == glossary_source.source_language,
+          record.target_language == glossary_source.target_language
         ]
       end
 

  Modified: lib/logaling/repository.rb (+2 -2)
===================================================================
--- lib/logaling/repository.rb    2012-02-16 19:57:19 +0900 (08a0eb9)
+++ lib/logaling/repository.rb    2012-02-18 23:09:28 +0900 (ab02c58)
@@ -60,12 +60,12 @@ module Logaling
       terms
     end
 
-    def show_glossary(glossary, source_language, target_language)
+    def show_glossary(glossary_source)
       raise GlossaryDBNotFound unless File.exist?(logaling_db_home)
 
       terms = []
       Logaling::GlossaryDB.open(logaling_db_home, "utf8") do |db|
-        terms = db.translation_list(glossary, source_language, target_language)
+        terms = db.translation_list(glossary_source)
       end
       terms
     end




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