SUZUKI Miho
null+****@clear*****
Wed Nov 7 23:53:03 JST 2012
SUZUKI Miho 2012-11-07 23:53:03 +0900 (Wed, 07 Nov 2012) New Revision: 268c4262009c9ffa0a13665e61829f2e18eab860 https://github.com/logaling/logaling-command/commit/268c4262009c9ffa0a13665e61829f2e18eab860 Log: Use project object and remove unnecessary methods Modified files: lib/logaling/glossary_db.rb lib/logaling/glossary_sources/base.rb lib/logaling/project.rb Modified: lib/logaling/glossary_db.rb (+7 -5) =================================================================== --- lib/logaling/glossary_db.rb 2012-11-07 23:51:59 +0900 (4f77804) +++ lib/logaling/glossary_db.rb 2012-11-07 23:53:03 +0900 (3fc9f73) @@ -449,16 +449,18 @@ module Logaling end def glossary_source_of_the_same_project_exist?(glossary_source) + project = glossary_source.glossary.project glossary_source_num = 0 get_all_glossary_sources.each do |glossary_source_taken| - if glossary_source.belongs_to_personal? && glossary_source_taken.belongs_to_personal? - if glossary_source.glossary_name == glossary_source_taken.glossary_name + project_taken = glossary_source_taken.glossary.project + if project.personal? && project_taken.personal? + if glossary_source.glossary.name == glossary_source_taken.glossary.name glossary_source_num = 1 break end - elsif glossary_source.belongs_to_project? && glossary_source_taken.belongs_to_project? - if glossary_source.project_name == glossary_source_taken.project_name && - glossary_source.glossary_name == glossary_source_taken.glossary_name + elsif project.normal_project? && project_taken.normal_project? + if project.name == project_taken.name && + glossary_source.glossary.name == glossary_source_taken.glossary.name glossary_source_num = 1 break end Modified: lib/logaling/glossary_sources/base.rb (+0 -16) =================================================================== --- lib/logaling/glossary_sources/base.rb 2012-11-07 23:51:59 +0900 (b1eaae0) +++ lib/logaling/glossary_sources/base.rb 2012-11-07 23:53:03 +0900 (9dfced5) @@ -37,22 +37,6 @@ module Logaling def mtime File.mtime(@source_path) end - - def belongs_to_personal? - @source_path =~ /.+\/personal\/.+/ ? true : false - end - - def belongs_to_project? - @source_path =~ /.+\/projects\/.+/ ? true : false - end - - def glossary_name - File.basename(@source_path).split(".", 2)[0] - end - - def project_name - @source_path =~ /.+\/projects\/([^\/]+).+/ ? $1 : nil - end end end end Modified: lib/logaling/project.rb (+20 -0) =================================================================== --- lib/logaling/project.rb 2012-11-07 23:51:59 +0900 (011919c) +++ lib/logaling/project.rb 2012-11-07 23:53:03 +0900 (82081de) @@ -88,6 +88,14 @@ module Logaling false end + def personal? + false + end + + def normal_project? + true + end + private def all_glossary_source_path Dir.glob(File.join(glossary_source_path, "*")) @@ -111,6 +119,10 @@ module Logaling def imported? true end + + def normal_project? + false + end end class PersonalProject < Project @@ -148,5 +160,13 @@ module Logaling def initialize_glossary(source_language, target_language) glossary(source_language, target_language).initialize_glossary_source end + + def personal? + true + end + + def normal_project? + false + end end end -------------- next part -------------- An HTML attachment was scrubbed... ダウンロード