SHIMADA Koji
null+****@clear*****
Wed Dec 12 10:16:50 JST 2012
SHIMADA Koji 2012-12-12 10:16:50 +0900 (Wed, 12 Dec 2012) New Revision: bbd6c0998b5fe95eab366c4baee9d6683fc4d0d7 https://github.com/logaling/logaling-server/commit/bbd6c0998b5fe95eab366c4baee9d6683fc4d0d7 Merged f495c6f: Merge pull request #45 from logaling/show-terms-of-imported-project Log: Extract GlossaryInfo from ExternalGlossariesController#show Added files: app/models/glossary_info.rb Modified files: app/controllers/external_glossaries_controller.rb Modified: app/controllers/external_glossaries_controller.rb (+5 -4) =================================================================== --- app/controllers/external_glossaries_controller.rb 2012-12-12 09:37:12 +0900 (d2e3c64) +++ app/controllers/external_glossaries_controller.rb 2012-12-12 10:16:50 +0900 (b879b0d) @@ -1,10 +1,11 @@ +#coding: utf-8 + class ExternalGlossariesController < ApplicationController def show - project_name, bilingual_pair = params[:id].split('/', 2) - source_language, target_language = bilingual_pair.split('-', 2) + glossary_info = GlossaryInfo.new_by_formatted_string(params[:id]) - @project = LogalingServer.repository.find_project(project_name) - @glossary =****@proje*****(source_language, target_language) + @project = LogalingServer.repository.find_project(glossary_info.project_name) + @glossary =****@proje*****(glossary_info.source_language, glossary_info.target_language) @terms = Kaminari.paginate_array(@glossary.terms).page(params[:page]) end Added: app/models/glossary_info.rb (+17 -0) 100644 =================================================================== --- /dev/null +++ app/models/glossary_info.rb 2012-12-12 10:16:50 +0900 (b114eaf) @@ -0,0 +1,17 @@ +#coding: utf-8 + +class GlossaryInfo + class << self + #extected_format: "(project_name)/(source_language)-(target_language)" + def new_by_formatted_string(formatted_string) + project_name, bilingual_pair = formatted_string.split('/', 2) + source_language, target_language = bilingual_pair.split('-', 2) + new(project_name: project_name, source_language: source_language, target_language: target_language) + end + end + include ActiveAttr::Model + + attribute :project_name, type: String, default: '' + attribute :source_language, type: String, default: '' + attribute :target_language, type: String, default: '' +end -------------- next part -------------- An HTML attachment was scrubbed... Descargar