[logaling-commit] logaling/logaling-command [master] Add Glossary#index!

Zurück zum Archiv-Index

SHIMADA Koji null+****@clear*****
Fri Sep 28 16:30:49 JST 2012


SHIMADA Koji	2012-09-28 16:30:49 +0900 (Fri, 28 Sep 2012)

  New Revision: 953d056c8c4f8c088cd1f7ab9841069008ab58c0
  https://github.com/logaling/logaling-command/commit/953d056c8c4f8c088cd1f7ab9841069008ab58c0

  Log:
    Add Glossary#index!
    
    - add force option to Glossary#index
    - change Glossary#index's method visibility to public

  Modified files:
    lib/logaling/glossary.rb

  Modified: lib/logaling/glossary.rb (+7 -3)
===================================================================
--- lib/logaling/glossary.rb    2012-09-28 14:35:12 +0900 (244ad50)
+++ lib/logaling/glossary.rb    2012-09-28 16:30:49 +0900 (fbc9fa9)
@@ -101,12 +101,15 @@ module Logaling
       [@name, @source_language, @target_language].join('.')
     end
 
-    private
-    def index
+    def index!
+      index(force: true)
+    end
+
+    def index(options = { force: false })
       Logaling::GlossaryDB.open(@project.glossary_db_path, "utf8") do |db|
         db.recreate_table
         glossary_sources.each do |glossary_source|
-          unless db.glossary_source_exist?(glossary_source)
+          if !db.glossary_source_exist?(glossary_source) || options[:force] == true
             puts "now index #{@name}..."
             db.index_glossary_source(glossary_source)
           end
@@ -119,6 +122,7 @@ module Logaling
       end
     end
 
+    private
     def glossary_sources
       glob_condition = SUPPORTED_FILE_TYPE.map do |type|
         file_name = [self.to_s, type].join('.')
-------------- next part --------------
An HTML attachment was scrubbed...
Download 



More information about the logaling-commit mailing list
Zurück zum Archiv-Index