[logaling-commit] logaling/logaling-command [master] Extract PersonalProject.create method

Zurück zum Archiv-Index

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


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

  New Revision: 4a24965e14af9a6545653f5dfb3f9cbc84aca785
  https://github.com/logaling/logaling-command/commit/4a24965e14af9a6545653f5dfb3f9cbc84aca785

  Merged 3c178f5: Merge pull request #74 from logaling/loga-new-no-project

  Log:
    Extract PersonalProject.create method

  Modified files:
    lib/logaling/glossary.rb
    lib/logaling/project.rb
    lib/logaling/repository.rb

  Modified: lib/logaling/glossary.rb (+4 -0)
===================================================================
--- lib/logaling/glossary.rb    2012-08-13 12:31:56 +0900 (57d20c1)
+++ lib/logaling/glossary.rb    2012-08-13 12:33:06 +0900 (c301518)
@@ -75,6 +75,10 @@ module Logaling
       end
     end
 
+    def initialize_glossary_source
+      glossary_source.initialize_source
+    end
+
     def to_s
       [@name, @source_language, @target_language].join('.')
     end

  Modified: lib/logaling/project.rb (+12 -0)
===================================================================
--- lib/logaling/project.rb    2012-08-13 12:31:56 +0900 (877bfdb)
+++ lib/logaling/project.rb    2012-08-13 12:33:06 +0900 (d372eb8)
@@ -98,6 +98,14 @@ module Logaling
   end
 
   class PersonalProject < Project
+    def self.create(root_path, glossary_name, source_language, target_language)
+      project_name = [glossary_name, source_language, target_language, 'yml'].join('.')
+      project_path = File.join(root_path, project_name)
+      project = PersonalProject.new(project_path)
+      project.initialize_glossary(source_language, target_language)
+      project
+    end
+
     def name
       File.basename(@path).split(/\./).first
     end
@@ -110,5 +118,9 @@ module Logaling
     def glossary_source_path
       File.dirname(@path)
     end
+
+    def initialize_glossary(source_language, target_language)
+      glossary(source_language, target_language).initialize_glossary_source
+    end
   end
 end

  Modified: lib/logaling/repository.rb (+1 -3)
===================================================================
--- lib/logaling/repository.rb    2012-08-13 12:31:56 +0900 (50314f5)
+++ lib/logaling/repository.rb    2012-08-13 12:33:06 +0900 (ac30106)
@@ -48,9 +48,7 @@ module Logaling
       if glossary_exists?(glossary_name, source_language, target_language)
         raise Logaling::GlossaryAlreadyRegistered
       end
-      FileUtils.mkdir_p(personal_glossary_root_path)
-      glossary_source_name = [glossary_name, source_language, target_language,'yml'].join('.')
-      FileUtils.touch(File.join(personal_glossary_root_path, glossary_source_name))
+      PersonalProject.create(personal_glossary_root_path, glossary_name, source_language, target_language)
     rescue
       raise Logaling::GlossaryAlreadyRegistered, "The glossary '#{glossary_name}' already exists."
     end
-------------- next part --------------
An HTML attachment was scrubbed...
Download 



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