[logaling-commit] logaling/logaling-command [master] [#38938441] Execute index in operation

Back to archive index

SUZUKI Miho null+****@clear*****
Mon Nov 5 11:44:12 JST 2012


SUZUKI Miho	2012-11-05 11:44:12 +0900 (Mon, 05 Nov 2012)

  New Revision: 946b7677e90fe077d9f14966d145cc4214e2aa3d
  https://github.com/logaling/logaling-command/commit/946b7677e90fe077d9f14966d145cc4214e2aa3d

  Merged a73da78: Merge pull request #88 from logaling/execute-index-in-operation

  Log:
    [#38938441] Execute index in operation

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

  Modified: lib/logaling/command/application.rb (+2 -13)
===================================================================
--- lib/logaling/command/application.rb    2012-11-05 11:19:25 +0900 (fc666d8)
+++ lib/logaling/command/application.rb    2012-11-05 11:44:12 +0900 (b06a0a4)
@@ -81,7 +81,7 @@ module Logaling::Command
             @dotfile_path = options["logaling-config"] || Logaling::Project.find_dotfile
             @project_config_path = File.join(@dotfile_path, 'config')
             @config.load(@project_config_path)
-            register_and_index
+            @repository.register(@dotfile_path, @config.glossary)
           end
           say "Successfully created #{logaling_config_path}"
         else
@@ -115,10 +115,8 @@ module Logaling::Command
           end
           glossary = Logaling::Glossary.new(args[0], args[2], args[3])
           @repository.import_tmx(Logaling::ExternalGlossary.get(external_glossary), glossary, url)
-          @repository.index
         else
           @repository.import(Logaling::ExternalGlossary.get(external_glossary))
-          @repository.index
         end
       end
     rescue Logaling::CommandFailed => e
@@ -136,7 +134,7 @@ module Logaling::Command
       @config.check_required_option("glossary" => "Do 'loga register' at project directory.")
       raise Logaling::CommandFailed, "Try 'loga new' first." unless File.exist?(@dotfile_path)
 
-      register_and_index
+      @repository.register(@dotfile_path, @config.glossary)
       say "#{@config.glossary} is now registered to logaling."
     rescue Logaling::CommandFailed => e
       say e.message
@@ -151,7 +149,6 @@ module Logaling::Command
 
       project =****@repos*****_project(@config.glossary)
       @repository.unregister(project)
-      @repository.index
       say "#{@config.glossary} is now unregistered."
     rescue Logaling::CommandFailed => e
       say e.message
@@ -204,7 +201,6 @@ module Logaling::Command
       glossary = project.glossary(@config.source_language, @config.target_language)
 
       glossary.add(source_term, target_term, note)
-      glossary.index!
     rescue Logaling::CommandFailed => e
       say e.message
     rescue Logaling::TermError => e
@@ -235,7 +231,6 @@ module Logaling::Command
       else
         glossary.delete_all(source_term, options["force"])
       end
-      glossary.index!
     rescue Logaling::CommandFailed, Logaling::TermError => e
       say e.message
     rescue Logaling::GlossaryNotFound => e
@@ -259,7 +254,6 @@ module Logaling::Command
       glossary = project.glossary(@config.source_language, @config.target_language)
 
       glossary.update(source_term, target_term, new_target_term, note)
-      glossary.index!
     rescue Logaling::CommandFailed => e
       say e.message
     rescue Logaling::TermError => e
@@ -421,10 +415,5 @@ module Logaling::Command
         raise Logaling::CommandFailed, "Do 'loga import tmx <glossary name> <url or path>'"
       end
     end
-
-    def register_and_index
-      @repository.register(@dotfile_path, @config.glossary)
-      @repository.index
-    end
   end
 end

  Modified: lib/logaling/glossary.rb (+4 -0)
===================================================================
--- lib/logaling/glossary.rb    2012-11-05 11:19:25 +0900 (fbc9fa9)
+++ lib/logaling/glossary.rb    2012-11-05 11:44:12 +0900 (6f4f03d)
@@ -56,6 +56,7 @@ module Logaling
     def add(source_term, target_term, note)
       raise Logaling::TermError if bilingual_pair_exists?(source_term, target_term)
       glossary_source.add(source_term, target_term, note)
+      index!
     end
 
     def update(source_term, target_term, new_target_term, note)
@@ -64,15 +65,18 @@ module Logaling
       end
 
       glossary_source.update(source_term, target_term, new_target_term, note)
+      index!
     end
 
     def delete(source_term, target_term)
       raise Logaling::TermError unless bilingual_pair_exists?(source_term, target_term)
       glossary_source.delete(source_term, target_term)
+      index!
     end
 
     def delete_all(source_term, force=false)
       glossary_source.delete_all(source_term, force)
+      index!
     end
 
     def glossary_source

  Modified: lib/logaling/repository.rb (+5 -0)
===================================================================
--- lib/logaling/repository.rb    2012-11-05 11:19:25 +0900 (943fefa)
+++ lib/logaling/repository.rb    2012-11-05 11:44:12 +0900 (faf6180)
@@ -33,6 +33,7 @@ module Logaling
       else
         raise Logaling::GlossaryAlreadyRegistered, register_name
       end
+      index
     rescue Logaling::GlossaryAlreadyRegistered => e
       raise e
     rescue
@@ -42,6 +43,7 @@ module Logaling
     def unregister(project)
       raise Logaling::ProjectNotFound unless project
       FileUtils.rm_rf(project.path, :secure => true)
+      index
     end
 
     def create_personal_project(project_name, source_language, target_language)
@@ -56,6 +58,7 @@ module Logaling
         raise Logaling::GlossaryNotFound, "The glossary '#{project_name}' not found."
       end
       PersonalProject.remove(personal_glossary_root_path, project_name, source_language, target_language, self)
+      index
     rescue Logaling::GlossaryNotFound => e
       raise e
     rescue
@@ -67,6 +70,7 @@ module Logaling
       Dir.chdir(cache_path) do
         glossary_source.import
       end
+      index
     rescue
       raise Logaling::CommandFailed, "Failed import #{glossary_source.class.name} to #{cache_path}."
     end
@@ -76,6 +80,7 @@ module Logaling
       Dir.chdir(cache_path) do
         glossary_source.import(glossary, url)
       end
+      index
     rescue Logaling::GlossaryNotFound => e
       raise e
     rescue

  Modified: spec/logaling/command_spec.rb (+0 -1)
===================================================================
--- spec/logaling/command_spec.rb    2012-11-05 11:19:25 +0900 (a062e06)
+++ spec/logaling/command_spec.rb    2012-11-05 11:44:12 +0900 (9fba53a)
@@ -576,7 +576,6 @@ describe Logaling::Command::Application do
       before do
         project = repository.find_project('spec')
         repository.unregister(project)
-        repository.index
         command.options = base_options.merge("no-pager" => true)
         @stdout = capture(:stdout) {command.list}
       end
-------------- next part --------------
An HTML attachment was scrubbed...
Download 



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