[logaling-commit] logaling/logaling-command [loga-new-no-project] Do loga new without creating .logaling

Back to archive index

null+****@clear***** null+****@clear*****
Wed Aug 8 23:20:14 JST 2012


SUZUKI Miho	2012-08-08 23:20:14 +0900 (Wed, 08 Aug 2012)

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

  Log:
    Do loga new without creating .logaling

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

  Modified: lib/logaling/command/application.rb (+20 -14)
===================================================================
--- lib/logaling/command/application.rb    2012-07-30 11:12:47 +0900 (6c7d72c)
+++ lib/logaling/command/application.rb    2012-08-08 23:20:14 +0900 (0f3f320)
@@ -64,23 +64,29 @@ module Logaling::Command
 
     desc 'new [PROJECT NAME] [SOURCE LANGUAGE] [TARGET LANGUAGE(optional)]', 'Create .logaling'
     method_option "no-register", type: :boolean, default: false
+    method_option "no-project", type: :boolean, default: false
     def new(project_name, source_language, target_language=nil)
-      unless File.exist?(logaling_config_path)
-        FileUtils.mkdir_p(File.join(logaling_config_path, "glossary"))
-
-        config = Logaling::Config.new("glossary" => project_name, "source-language" => source_language)
-        config.merge!("target-language" => target_language) if target_language
-        config.save(File.join(logaling_config_path, "config"))
-
-        unless options["no-register"]
-          @dotfile_path = options["logaling-config"] ? options["logaling-config"] : Logaling::Project.find_dotfile
-          @project_config_path = File.join(@dotfile_path, 'config')
-          @config.load(@project_config_path)
-          register_and_index
+      unless options['no-project']
+        unless File.exist?(logaling_config_path)
+          FileUtils.mkdir_p(File.join(logaling_config_path, "glossary"))
+
+          config = Logaling::Config.new("glossary" => project_name, "source-language" => source_language)
+          config.merge!("target-language" => target_language) if target_language
+          config.save(File.join(logaling_config_path, "config"))
+
+          unless options["no-register"]
+            @dotfile_path = options["logaling-config"] ? options["logaling-config"] : Logaling::Project.find_dotfile
+            @project_config_path = File.join(@dotfile_path, 'config')
+            @config.load(@project_config_path)
+            register_and_index
+          end
+          say "Successfully created #{logaling_config_path}"
+        else
+          say "#{logaling_config_path} already exists."
         end
-        say "Successfully created #{logaling_config_path}"
       else
-        say "#{logaling_config_path} already exists."
+        # raise error if target is nil 
+        @repository.create_user_glossary(project_name, source_language, target_language)
       end
     end
 

  Modified: lib/logaling/repository.rb (+8 -0)
===================================================================
--- lib/logaling/repository.rb    2012-07-30 11:12:47 +0900 (26e8055)
+++ lib/logaling/repository.rb    2012-08-08 23:20:14 +0900 (107b9ea)
@@ -44,6 +44,14 @@ module Logaling
       FileUtils.rm_rf(project.path, :secure => true)
     end
 
+    def create_user_glossary(glossary_name, source_language, target_language)
+      FileUtils.mkdir_p(logaling_user_glossaries_path)
+      glossary_source_name = [glossary_name, source_language, target_language,'yml'].join('.')
+      FileUtils.touch(File.join(logaling_user_glossaries_path, glossary_source_name))
+      # raise error if already file exist
+      # raise error if same file in /projects
+    end
+
     def import(glossary_source)
       FileUtils.mkdir_p(cache_path)
       Dir.chdir(cache_path) do
-------------- next part --------------
An HTML attachment was scrubbed...
Télécharger 



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