[logaling-commit] logaling/logaling-command [loga-new-no-project] Extract Repository#glossary_exists? method

Back to archive index

SHIMADA Koji null+****@clear*****
Mon Aug 13 11:06:12 JST 2012


SHIMADA Koji	2012-08-13 11:06:12 +0900 (Mon, 13 Aug 2012)

  New Revision: 65d036c070205609883838d993ea810b872bacbd
  https://github.com/logaling/logaling-command/commit/65d036c070205609883838d993ea810b872bacbd

  Log:
    Extract Repository#glossary_exists? method

  Modified files:
    lib/logaling/repository.rb

  Modified: lib/logaling/repository.rb (+11 -4)
===================================================================
--- lib/logaling/repository.rb    2012-08-13 10:56:31 +0900 (bc61a1c)
+++ lib/logaling/repository.rb    2012-08-13 11:06:12 +0900 (f0db47e)
@@ -46,10 +46,8 @@ module Logaling
 
     def create_personal_glossary(glossary_name, source_language, target_language)
       FileUtils.mkdir_p(personal_glossary_root_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
+      if glossary_exists?(glossary_name, source_language, target_language)
+        raise Logaling::GlossaryAlreadyRegistered
       end
       glossary_source_name = [glossary_name, source_language, target_language,'yml'].join('.')
       FileUtils.touch(File.join(personal_glossary_root_path, glossary_source_name))
@@ -165,5 +163,14 @@ module Logaling
     def imported_glossary_paths
       Dir[File.join(cache_path, "*")]
     end
+
+    def glossary_exists?(glossary_name, source_language, target_language)
+      project = find_project(glossary_name)
+      if project && project.glossaries.map(&:to_s).index([glossary_name, source_language, target_language].join('.'))
+        true
+      else
+        false
+      end
+    end
   end
 end
-------------- next part --------------
An HTML attachment was scrubbed...
Download 



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