null+****@clear*****
null+****@clear*****
Wed Jun 6 22:27:50 JST 2012
SHIMADA Koji 2012-06-06 22:27:50 +0900 (Wed, 06 Jun 2012) New Revision: df9b3c6ec6095d5acade6f8e6ae831cf974f5576 Log: Extract GlossaryDB#latest_version?, #update_version_to_latest Modified files: lib/logaling/glossary_db.rb Modified: lib/logaling/glossary_db.rb (+14 -3) =================================================================== --- lib/logaling/glossary_db.rb 2012-06-06 21:47:22 +0900 (2215838) +++ lib/logaling/glossary_db.rb 2012-06-06 22:27:50 +0900 (8d6f1cf) @@ -49,11 +49,10 @@ module Logaling end def recreate_table - version = Groonga["configurations"] ? get_config("version") : 0 - if version.to_i != VERSION + unless latest_version? remove_schema populate_schema - add_config("version", VERSION.to_s) + update_version_to_latest end end @@ -389,6 +388,18 @@ module Logaling struct_snipped_text(snipped_text) end + def latest_version? + current_version == VERSION + end + + def current_version + Groonga["configurations"] ? get_config("version").to_i : 0 + end + + def update_version_to_latest + add_config("version", VERSION.to_s) + end + def get_config(conf_key) records = Groonga["configurations"].select do |record| record.conf_key == conf_key