[logaling-commit] logaling/logaling-command [refactor-structure] Change GlossaryDB#glossary_sources_related_on_glossary to receive glossary

Back to archive index

null+****@clear***** null+****@clear*****
Mon Jun 18 12:00:39 JST 2012


SUZUKI Miho	2012-06-18 12:00:39 +0900 (Mon, 18 Jun 2012)

  New Revision: 3b728e8a034c9751890413d10ac6dfb554e4b4a6
  https://github.com/logaling/logaling-command/commit/3b728e8a034c9751890413d10ac6dfb554e4b4a6

  Log:
    Change GlossaryDB#glossary_sources_related_on_glossary to receive glossary

  Modified files:
    lib/logaling/glossary.rb
    lib/logaling/glossary_db.rb

  Modified: lib/logaling/glossary.rb (+5 -2)
===================================================================
--- lib/logaling/glossary.rb    2012-06-18 11:51:25 +0900 (a32e20b)
+++ lib/logaling/glossary.rb    2012-06-18 12:00:39 +0900 (8e60ac6)
@@ -75,6 +75,10 @@ module Logaling
       end
     end
 
+    def to_s
+      [@name, @source_language, @target_language].join('.')
+    end
+
     private
     def index
       Logaling::GlossaryDB.open(@project.glossary_db_path, "utf8") do |db|
@@ -85,8 +89,7 @@ module Logaling
             db.index_glossary_source(glossary_source)
           end
         end
-        glossary_string = [@name, @source_language, @target_language].join('.')
-        indexed_glossary_sources = db.glossary_sources_related_on_glossary(glossary_string)
+        indexed_glossary_sources = db.glossary_sources_related_on_glossary(self)
         (indexed_glossary_sources - glossary_sources.map(&:source_path)).each do |removed_glossary_source|
           puts "now deindex #{@name}..."
           db.deindex_glossary(@name, removed_glossary_source)

  Modified: lib/logaling/glossary_db.rb (+2 -2)
===================================================================
--- lib/logaling/glossary_db.rb    2012-06-18 11:51:25 +0900 (162fd20)
+++ lib/logaling/glossary_db.rb    2012-06-18 12:00:39 +0900 (edfaf7e)
@@ -234,9 +234,9 @@ module Logaling
       ]).map{|record| record.key}
     end
 
-    def glossary_sources_related_on_glossary(glossary_string)
+    def glossary_sources_related_on_glossary(glossary)
       records = Groonga["glossary_sources"].select do |record|
-        [record.key =~ glossary_string]
+        [record.key =~ glossary.to_s]
       end
       records.map{|record| record.key.key }
     end
-------------- next part --------------
An HTML attachment was scrubbed...
下載 



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