[logaling-commit] logaling/logaling-command [refactor-structure] Improve interface for creating GlossarySource object

Back to archive index

null+****@clear***** null+****@clear*****
Thu Jun 14 23:21:21 JST 2012


SHIMADA Koji	2012-06-14 23:21:21 +0900 (Thu, 14 Jun 2012)

  New Revision: 5ec4cf824c407d3b59d10be3df5b2adbe12237d1

  Log:
    Improve interface for creating GlossarySource object
    
    - remove dependency on logaling_home
    - transit source_path when initialize

  Modified files:
    lib/logaling/glossary.rb
    lib/logaling/glossary_source.rb

  Modified: lib/logaling/glossary.rb (+2 -3)
===================================================================
--- lib/logaling/glossary.rb    2012-06-14 23:11:30 +0900 (0ed06ae)
+++ lib/logaling/glossary.rb    2012-06-14 23:21:21 +0900 (db05284)
@@ -67,12 +67,11 @@ module Logaling
       if @glossary_source
         @glossary_source
       else
-        @glossary_source = Logaling::GlossarySource.new(self)
         file_name = [@name, @source_language, @target_language, 'yml'].join('.')
         source_dir =****@proje*****_source_path
         FileUtils.mkdir_p(source_dir)
-        @glossary_source.source_path = File.join(source_dir, file_name)
-        @glossary_source
+        source_path = File.join(source_dir, file_name)
+        Logaling::GlossarySource.new(source_path, self)
       end
     end
 

  Modified: lib/logaling/glossary_source.rb (+3 -12)
===================================================================
--- lib/logaling/glossary_source.rb    2012-06-14 23:11:30 +0900 (386e011)
+++ lib/logaling/glossary_source.rb    2012-06-14 23:21:21 +0900 (45841de)
@@ -61,10 +61,10 @@ module Logaling
         glossary_source
       end
     end
-    attr_writer :source_path
+    attr_reader :source_path
 
-    def initialize(glossary, logaling_home = nil)
-      @logaling_home = logaling_home
+    def initialize(source_path, glossary)
+      @source_path = source_path
       @glossary = glossary
     end
 
@@ -124,15 +124,6 @@ module Logaling
       end
     end
 
-    def source_path
-      if @source_path
-        @source_path
-      else
-        fname = [@glossary.name, @glossary.source_language, @glossary.target_language].join(".")
-        @source_path = File.join(@logaling_home, "projects", @glossary.name, "glossary", "#{fname}.yml")
-      end
-    end
-
     private
     def build_term(source_term, target_term, note)
       note ||= ''




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