SHIMADA Koji
null+****@clear*****
Thu Aug 16 18:22:51 JST 2012
SHIMADA Koji 2012-08-16 18:22:51 +0900 (Thu, 16 Aug 2012) New Revision: 29f2e9c653621d9c8c55813014fa9ea8e2fa11b9 https://github.com/logaling/logaling-command/commit/29f2e9c653621d9c8c55813014fa9ea8e2fa11b9 Merged 0b973f2: Merge pull request #76 from logaling/add-loga-copy Log: Extract Repository#find_glossary Modified files: lib/logaling/command/application.rb lib/logaling/repository.rb Modified: lib/logaling/command/application.rb (+3 -7) =================================================================== --- lib/logaling/command/application.rb 2012-08-16 17:09:10 +0900 (6983c9e) +++ lib/logaling/command/application.rb 2012-08-16 18:22:51 +0900 (129334d) @@ -360,18 +360,14 @@ module Logaling::Command desc 'copy [GLOSSARY NAME] [SOURCE LANGUAGE] [TARGET LANGUAGE] [NEW GLOSSARY NAME] [NEW SOURCE LANGUAGE] [NEW TARGET LANGUAGE]', 'Copy personal glossary' def copy(project_name, source_language, target_language, new_project_name, new_source_language, new_target_language) check_logaling_home_exists - projects =****@repos***** - project_candidates = projects.reject { |project| project.name != project_name } - project_original = project_candidates.detect do |project| - project.has_glossary?(source_language, target_language) - end - unless project_original + glossary_original =****@repos*****_glossary(project_name, source_language, target_language) + unless glossary_original raise Logaling::GlossaryNotFound, "Can't found #{project_name}.#{source_language}.#{target_language}" end project_new =****@repos*****_personal_project(new_project_name, new_source_language, new_target_language) glossary_new = project_new.glossary(new_source_language, new_target_language) - project_original.glossary(source_language, target_language).terms.each do |term| + glossary_original.terms.each do |term| glossary_new.add(term[:source_term], term[:target_term], term[:note]) end Modified: lib/logaling/repository.rb (+9 -5) =================================================================== --- lib/logaling/repository.rb 2012-08-16 17:09:10 +0900 (3a403cf) +++ lib/logaling/repository.rb 2012-08-16 18:22:51 +0900 (4999b8c) @@ -131,6 +131,14 @@ module Logaling project = projects.detect{|project| project.name == project_name} end + def find_glossary(project_name, source_language, target_language) + project_candidates = projects.reject { |project| project.name != project_name } + project = project_candidates.detect do |project| + project.has_glossary?(source_language, target_language) + end + project ? project.glossary(source_language, target_language) : nil + end + def logaling_db_home File.join(@path, "db") end @@ -161,11 +169,7 @@ module Logaling end def glossary_exists?(project_name, source_language, target_language) - project_candidates = projects.reject{|project| project.name != project_name} - project = project_candidates.detect do |project| - project.has_glossary?(source_language, target_language) - end - project ? true : false + glossary = find_glossary(project_name, source_language, target_language) ? true : false end end end -------------- next part -------------- An HTML attachment was scrubbed... 다운로드