[logaling-commit] logaling/logaling-command [loga-new-no-project] raise error if glossary already exist

Back to archive index

null+****@clear***** null+****@clear*****
Thu Aug 9 16:26:06 JST 2012


SUZUKI Miho	2012-08-09 16:26:06 +0900 (Thu, 09 Aug 2012)

  New Revision: 947e5bb59f55199db5785f141e2a09ba24dd5475
  https://github.com/logaling/logaling-command/commit/947e5bb59f55199db5785f141e2a09ba24dd5475

  Log:
    raise error if glossary already exist

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

  Modified: lib/logaling/command/application.rb (+2 -0)
===================================================================
--- lib/logaling/command/application.rb    2012-08-09 15:44:53 +0900 (72ea0b5)
+++ lib/logaling/command/application.rb    2012-08-09 16:26:06 +0900 (336d517)
@@ -90,6 +90,8 @@ module Logaling::Command
       end
     rescue Logaling::CommandFailed => e
       say e.message
+    rescue Logaling::GlossaryAlreadyRegistered => e
+      say e.message
     end
 
     desc 'import', 'Import external glossary'

  Modified: lib/logaling/repository.rb (+7 -2)
===================================================================
--- lib/logaling/repository.rb    2012-08-09 15:44:53 +0900 (f589157)
+++ lib/logaling/repository.rb    2012-08-09 16:26:06 +0900 (c059e6d)
@@ -46,10 +46,15 @@ module Logaling
 
     def create_personal_glossary(glossary_name, source_language, target_language)
       FileUtils.mkdir_p(personal_path)
+      if project = find_project(glossary_name)
+        if project.glossaries.map(&:to_s).index([glossary_name, source_language, target_language].join('.'))
+          raise Logaling::GlossaryAlreadyRegistered
+        end
+      end
       glossary_source_name = [glossary_name, source_language, target_language,'yml'].join('.')
       FileUtils.touch(File.join(personal_path, glossary_source_name))
-      # raise error if already file exist
-      # raise error if same file in /projects
+    rescue
+      raise Logaling::GlossaryAlreadyRegistered, "The glossary '#{glossary_name}' is already exist."
     end
 
     def import(glossary_source)
-------------- next part --------------
An HTML attachment was scrubbed...
다운로드 



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