[logaling-commit] logaling/logaling-command [master] extract Config.setup method from Command::Application#new

Back to archive index

null+****@clear***** null+****@clear*****
Tue Feb 14 20:40:26 JST 2012


SHIMADA Koji	2012-02-14 20:40:26 +0900 (Tue, 14 Feb 2012)

  New Revision: de8c920c712c5e538ac633a2a1ddbd07284860ea

  Merged b0ee22d: Merge pull request #43 from logaling/extract-config-object

  Log:
    extract Config.setup method from Command::Application#new

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

  Modified: lib/logaling/command/application.rb (+3 -3)
===================================================================
--- lib/logaling/command/application.rb    2012-02-14 20:31:59 +0900 (60fc081)
+++ lib/logaling/command/application.rb    2012-02-14 20:40:26 +0900 (a71c56f)
@@ -57,9 +57,9 @@ module Logaling::Command
     def new(project_name, source_language, target_language=nil)
       unless File.exist?(LOGALING_CONFIG)
         FileUtils.mkdir_p(File.join(LOGALING_CONFIG, "glossary"))
-        config = {"glossary" => project_name, "source-language" => source_language}
-        config["target-language"] = target_language if target_language
-        Logaling::Config.new(config).write_config(File.join(LOGALING_CONFIG, "config"))
+
+        config = Logaling::Config.setup(project_name, source_language, target_language)
+        config.write_config(File.join(LOGALING_CONFIG, "config"))
 
         register unless options["no-register"]
         say "Successfully created #{LOGALING_CONFIG}"

  Modified: lib/logaling/config.rb (+6 -0)
===================================================================
--- lib/logaling/config.rb    2012-02-14 20:31:59 +0900 (17d0fc5)
+++ lib/logaling/config.rb    2012-02-14 20:40:26 +0900 (f37fa7d)
@@ -16,6 +16,12 @@
 module Logaling
   class Config
     class << self
+      def setup(project_name, source_language, target_language)
+        config = {"glossary" => project_name, "source-language" => source_language}
+        config["target-language"] = target_language if target_language
+        Logaling::Config.new(config)
+      end
+
       def add(config_path, key, value)
         raise Logaling::CommandFailed, "#{key} is unsupported option" unless support?(key)
 




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