null+****@clear*****
null+****@clear*****
Wed Jun 13 16:38:53 JST 2012
SUZUKI Miho 2012-06-13 16:38:53 +0900 (Wed, 13 Jun 2012) New Revision: e1b547206818e0c721a852385958732a21273a39 https://github.com/logaling/logaling-command/commit/e1b547206818e0c721a852385958732a21273a39 Merged 7228757: Merge pull request #60 from logaling/refactor-structure Log: Use glossary object instead of glossary source when run update command Modified files: lib/logaling/command/application.rb lib/logaling/glossary.rb Modified: lib/logaling/command/application.rb (+4 -4) =================================================================== --- lib/logaling/command/application.rb 2012-06-13 16:28:51 +0900 (891a3b9) +++ lib/logaling/command/application.rb 2012-06-13 16:38:53 +0900 (28bdc62) @@ -213,13 +213,13 @@ module Logaling::Command } @config.check_required_option(required_options) check_logaling_home_exists - @repository.index - - if****@repos*****_pair_exists_and_has_same_note?(source_term, new_target_term, note, @config.glossary) + project =****@repos*****_project(@config.glossary) + glossary = project.find_glossary(@config.source_language, @config.target_language) + if glossary.bilingual_pair_exists?(source_term, new_target_term, note) raise Logaling::TermError, "term '#{source_term}: #{new_target_term}' already exists in '#{@config.glossary}'" end - glossary_source.update(source_term, target_term, new_target_term, note) + glossary.update(source_term, target_term, new_target_term, note) rescue Logaling::CommandFailed, Logaling::TermError => e say e.message rescue Logaling::GlossaryNotFound => e Modified: lib/logaling/glossary.rb (+6 -2) =================================================================== --- lib/logaling/glossary.rb 2012-06-13 16:28:51 +0900 (632f1af) +++ lib/logaling/glossary.rb 2012-06-13 16:38:53 +0900 (de40472) @@ -37,12 +37,12 @@ module Logaling terms end - def bilingual_pair_exists?(source_term, target_term) + def bilingual_pair_exists?(source_term, target_term, note=nil) raise Logaling::GlossaryDBNotFound unless File.exist?(@project.glossary_db_path) index terms = [] Logaling::GlossaryDB.open(@project.glossary_db_path, "utf8") do |db| - terms = db.get_bilingual_pair(source_term, target_term, @name) + terms = db.get_bilingual_pair(source_term, target_term, @name, note) end !terms.empty? end @@ -51,6 +51,10 @@ module Logaling glossary_source.add(source_term, target_term, note) end + def update(source_term, target_term, new_target_term, note) + glossary_source.update(source_term, target_term, new_target_term, note) + end + private def index Logaling::GlossaryDB.open(@project.glossary_db_path, "utf8") do |db| -------------- next part -------------- An HTML attachment was scrubbed... 다운로드