[logaling-commit] logaling/logaling-command [change-glossarysourcepath-fullpath-to-relativepath] Rename GlossarySource#source_path_full to #expand_path

Back to archive index

SHIMADA Koji null+****@clear*****
Wed Nov 21 14:47:39 JST 2012


SHIMADA Koji	2012-11-21 14:47:39 +0900 (Wed, 21 Nov 2012)

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

  Log:
    Rename GlossarySource#source_path_full to #expand_path

  Modified files:
    lib/logaling/glossary_sources/base.rb
    lib/logaling/glossary_sources/glossary_csv_source.rb
    lib/logaling/glossary_sources/glossary_tsv_source.rb
    lib/logaling/glossary_sources/glossary_yaml_source.rb
    spec/logaling/command_spec.rb
    spec/logaling/glossary_spec.rb
    spec/logaling/repository_spec.rb

  Modified: lib/logaling/glossary_sources/base.rb (+2 -2)
===================================================================
--- lib/logaling/glossary_sources/base.rb    2012-11-21 14:31:34 +0900 (df86d50)
+++ lib/logaling/glossary_sources/base.rb    2012-11-21 14:47:39 +0900 (36a9a00)
@@ -35,10 +35,10 @@ module Logaling
       end
 
       def mtime
-        File.mtime(source_path_full)
+        File.mtime(expand_path)
       end
 
-      def source_path_full
+      def expand_path
         @glossary.project.repository.expand_path(@source_path)
       end
     end

  Modified: lib/logaling/glossary_sources/glossary_csv_source.rb (+1 -1)
===================================================================
--- lib/logaling/glossary_sources/glossary_csv_source.rb    2012-11-21 14:31:34 +0900 (778a632)
+++ lib/logaling/glossary_sources/glossary_csv_source.rb    2012-11-21 14:47:39 +0900 (dfcab3b)
@@ -22,7 +22,7 @@ module Logaling::GlossarySources
   class GlossaryCsvSource < Base
     def load
       glossary_source = []
-      CSV.open(source_path_full, "r:utf-8",  {:col_sep => ','}) do |csv|
+      CSV.open(expand_path, "r:utf-8",  {:col_sep => ','}) do |csv|
         csv.each do |row|
           glossary_source << {"source_term" => row[0], "target_term" => row[1], "note" => ""} if row.size >= 2
         end

  Modified: lib/logaling/glossary_sources/glossary_tsv_source.rb (+1 -1)
===================================================================
--- lib/logaling/glossary_sources/glossary_tsv_source.rb    2012-11-21 14:31:34 +0900 (b73dd66)
+++ lib/logaling/glossary_sources/glossary_tsv_source.rb    2012-11-21 14:47:39 +0900 (1550dd5)
@@ -22,7 +22,7 @@ module Logaling::GlossarySources
   class GlossaryTsvSource < Base
     def load
       glossary_source = []
-      CSV.open(source_path_full, "r:utf-8",  {:col_sep => "\t"}) do |tsv|
+      CSV.open(expand_path, "r:utf-8",  {:col_sep => "\t"}) do |tsv|
         tsv.each do |row|
           glossary_source << {"source_term" => row[0], "target_term" => row[1], "note" => ""} if row.size >= 2
         end

  Modified: lib/logaling/glossary_sources/glossary_yaml_source.rb (+6 -6)
===================================================================
--- lib/logaling/glossary_sources/glossary_yaml_source.rb    2012-11-21 14:31:34 +0900 (0ceb71b)
+++ lib/logaling/glossary_sources/glossary_yaml_source.rb    2012-11-21 14:47:39 +0900 (0fee500)
@@ -28,13 +28,13 @@ require "fileutils"
 module Logaling::GlossarySources
   class GlossaryYamlSource < Base
     def load
-      YAML::load_file(source_path_full) || []
+      YAML::load_file(expand_path) || []
     rescue TypeError
       []
     end
 
     def add(source_term, target_term, note)
-      initialize_source unless File.exist?(source_path_full)
+      initialize_source unless File.exist?(expand_path)
 
       glossary_source = self.load
       glossary_source << build_term(source_term, target_term, note)
@@ -44,7 +44,7 @@ module Logaling::GlossarySources
     end
 
     def update(source_term, target_term, new_target_term, note)
-      raise Logaling::GlossaryNotFound unless File.exist?(source_path_full)
+      raise Logaling::GlossaryNotFound unless File.exist?(expand_path)
 
       glossary_source = self.load
       target_index = find_term_index(glossary_source, source_term, target_term)
@@ -57,7 +57,7 @@ module Logaling::GlossarySources
     end
 
     def delete(source_term, target_term)
-      raise Logaling::GlossaryNotFound unless File.exist?(source_path_full)
+      raise Logaling::GlossaryNotFound unless File.exist?(expand_path)
 
       glossary_source = self.load
       target_index = find_term_index(glossary_source, source_term, target_term)
@@ -70,7 +70,7 @@ module Logaling::GlossarySources
     end
 
     def delete_all(source_term, force=false)
-      raise Logaling::GlossaryNotFound unless File.exist?(source_path_full)
+      raise Logaling::GlossaryNotFound unless File.exist?(expand_path)
 
       glossary_source = self.load
       delete_candidates = target_terms(glossary_source, source_term)
@@ -121,7 +121,7 @@ module Logaling::GlossarySources
     end
 
     def dump_glossary_source(glossary_source)
-      File.open(source_path_full, "w") do |f|
+      File.open(expand_path, "w") do |f|
         f << YAML.dump(glossary_source)
       end
     end

  Modified: spec/logaling/command_spec.rb (+1 -1)
===================================================================
--- spec/logaling/command_spec.rb    2012-11-21 14:31:34 +0900 (06ef27a)
+++ spec/logaling/command_spec.rb    2012-11-21 14:47:39 +0900 (2f60ae7)
@@ -25,7 +25,7 @@ describe Logaling::Command::Application do
   let(:target_project_path) { File.join(logaling_home, "projects", "spec") }
   let(:repository) { Logaling::Repository.new(logaling_home) }
   let(:glossary) { repository.find_project('spec').glossary('en', 'ja') }
-  let(:glossary_source_path) { glossary.glossary_source.source_path_full }
+  let(:glossary_source_path) { glossary.glossary_source.expand_path }
 
   before do
     FileUtils.rm_rf(File.join(logaling_home, 'projects', 'spec'))

  Modified: spec/logaling/glossary_spec.rb (+6 -6)
===================================================================
--- spec/logaling/glossary_spec.rb    2012-11-21 14:31:34 +0900 (53ed93d)
+++ spec/logaling/glossary_spec.rb    2012-11-21 14:47:39 +0900 (26b6cc3)
@@ -25,14 +25,14 @@ module Logaling
     let(:repository) { Logaling::Repository.new(logaling_home) }
     let(:glossary) { repository.find_project('spec').glossary('en', 'ja') }
     let(:glossary_source_path) { glossary.glossary_source.source_path }
-    let(:glossary_source_path_full) { glossary.glossary_source.source_path_full }
+    let(:glossary_source_expand_path) { glossary.glossary_source.expand_path }
 
     before do
       # clear directories and files
       FileUtils.rm_rf(File.join(logaling_home, 'projects', 'spec'), :secure => true)
       FileUtils.mkdir_p(File.join(logaling_home, 'projects', 'spec', 'glossary'))
-      FileUtils.touch(glossary_source_path_full)
-      File.open(glossary_source_path_full, "w") {|f| f << YAML.dump([]) }
+      FileUtils.touch(glossary_source_expand_path)
+      File.open(glossary_source_expand_path, "w") {|f| f << YAML.dump([]) }
       # and clear db too
       glossary.index!
     end
@@ -44,7 +44,7 @@ module Logaling
         end
 
         it 'glossary yaml should have that bilingual pair' do
-          yaml = YAML::load_file(glossary_source_path_full)
+          yaml = YAML::load_file(glossary_source_expand_path)
           term = yaml.index({"source_term"=>"spec", "target_term"=>"スペック", "note"=>"テストスペック"})
           term.should_not be_nil
         end
@@ -56,7 +56,7 @@ module Logaling
         end
 
         it "should create the glossary and add term" do
-          yaml = YAML::load_file(glossary_source_path_full)
+          yaml = YAML::load_file(glossary_source_expand_path)
           term = yaml.index({"source_term"=>"test", "target_term"=>"テスト", "note"=>"テスト"})
           term.should_not be_nil
         end
@@ -92,7 +92,7 @@ module Logaling
         end
 
         it 'should clear note' do
-          yaml = YAML::load_file(glossary_source_path_full)
+          yaml = YAML::load_file(glossary_source_expand_path)
           term = yaml.index({"source_term"=>"user", "target_term"=>"ユーザ", "note"=>""})
           term.should_not be_nil
         end

  Modified: spec/logaling/repository_spec.rb (+6 -6)
===================================================================
--- spec/logaling/repository_spec.rb    2012-11-21 14:31:34 +0900 (d38752e)
+++ spec/logaling/repository_spec.rb    2012-11-21 14:47:39 +0900 (43dc791)
@@ -25,7 +25,7 @@ module Logaling
     let(:repository) { Logaling::Repository.new(logaling_home) }
     let(:glossary) { repository.find_project('spec').glossary('en', 'ja') }
     let(:glossary_source_path) { glossary.glossary_source.source_path }
-    let(:glossary_source_path_full) { glossary.glossary_source.source_path_full }
+    let(:glossary_source_expand_path) { glossary.glossary_source.expand_path }
 
     before do
       FileUtils.rm_rf(File.join(logaling_home, 'projects', 'spec'), :secure => true)
@@ -119,7 +119,7 @@ module Logaling
       end
 
       context 'when tsv file as glossary exists' do
-        let(:tsv_path) { glossary_source_path_full.sub(/yml$/, 'tsv') }
+        let(:tsv_path) { glossary_source_expand_path.sub(/yml$/, 'tsv') }
 
         before do
           FileUtils.touch(tsv_path)
@@ -139,12 +139,12 @@ module Logaling
     end
 
     describe '#index' do
-      let(:tsv_path) { File.join(File.dirname(glossary_source_path_full), "spec.en.ja.tsv") }
-      let(:csv_path) { File.join(File.dirname(glossary_source_path_full), "spec.en.ja.csv") }
+      let(:tsv_path) { File.join(File.dirname(glossary_source_expand_path), "spec.en.ja.tsv") }
+      let(:csv_path) { File.join(File.dirname(glossary_source_expand_path), "spec.en.ja.csv") }
 
       context 'when yml file as glossary exists' do
         before do
-          File.open(glossary_source_path_full, 'w') do |f|
+          File.open(glossary_source_expand_path, 'w') do |f|
             YAML.dump([], f)
           end
           glossary.add("spec_logaling", "スペック", "備考")
@@ -157,7 +157,7 @@ module Logaling
         end
 
         after do
-          FileUtils.rm_rf(glossary_source_path_full, :secure => true)
+          FileUtils.rm_rf(glossary_source_expand_path, :secure => true)
         end
       end
 
-------------- next part --------------
An HTML attachment was scrubbed...
Télécharger 



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