Class: JIJI::Migration::Migrator1_1_0
- Inherits:
-
Object
- Object
- JIJI::Migration::Migrator1_1_0
- Defined in:
- lib/jiji/migration/migrator1_1_0.rb
Overview
1.0.3 → 1.1.0
Instance Method Summary collapse
-
#key_to_sym(map) ⇒ Object
ハッシュのキーをシンボルに置換する.
- #migrate(registry) ⇒ Object
Instance Method Details
#key_to_sym(map) ⇒ Object
ハッシュのキーをシンボルに置換する
35 36 37 38 39 40 41 |
# File 'lib/jiji/migration/migrator1_1_0.rb', line 35 def key_to_sym( map ) map.inject({}) {|r,e| v = e[1].kind_of?(Hash) ? key_to_sym( e[1] ) : e[1] r.store(e[0].to_sym, v) r } end |
#migrate(registry) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/jiji/migration/migrator1_1_0.rb', line 12 def migrate( registry ) #設定ファイルを更新 conf_file = registry.base_dir + "/conf/configuration.yaml" return unless File.exist? conf_file tmp = key_to_sym(YAML.load_file(conf_file)) # 証券会社アクセス関連の設定値を置換 if( tmp[:securities] && tmp[:securities][:account] ) old = tmp[:securities] tmp[:securities] = { :type=>:click_securities_demo, :user=>old[:account] &&old[:account][:user] ? old[:account][:user] : "", :password=>old[:account] &&old[:account][:password] ? old[:account][:password] : "" } open( conf_file, "w" ) {|f| f << YAML.dump( tmp ) } # 設定値を再読み込み registry.conf.load end end |