「uten.rb」の編集履歴(バックアップ)一覧はこちら

uten.rb」(2007/07/13 (金) 00:22:21) の最新版変更点

追加された行は緑色になります。

削除された行は赤色になります。

//ruby #パーサクラス定義の取り込み require 'shikint.rb' #パーサ用各国別パラメタ定義の取り込み require 'cashrec_def.rb' #データベースアクセス用定義 require 'rubygems' require_gem 'activerecord' db_env = YAML.load(open('./sigint.yml')) ActiveRecord::Base.establish_connection( db_env['database'] ) class LatestCashRecord < ActiveRecord::Base belongs_to :nation , :foreign_key => "id" end class Nation < ActiveRecord::Base end class Property < ActiveRecord::Base end #登録されたパーサ全てを利用し、順番に各藩国の財務表を調べていく。 for nation in ZaimuParser.nations.values.sort_by{|n| n.no} print nation.no,nation.name,"\n" rec = LatestCashRecord.find(nation.no) rec[:url] = nation.url #各国財務表ページの「最終更新日時」を取得する。 #(実際には意味のある情報が取れていないので、文殊では表示していない・・) begin nation.head rec.last_modified = nation.response['Last-Modified'] rescue #例外処理 rec.last_modified = nil end #各国財務ページの解析、および文殊への登録(の準備) begin nation.parse parsed = nation.parsed rec.fund = parsed[0].to_i rec.resource = parsed[1].to_i rec.food = parsed[2].to_i rec.fuel = parsed[3].to_i rec.entertainment = parsed[4].to_i rescue #例外処理 rec.fund = nil rec.resource = nil rec.food = nil rec.fuel = nil rec.entertainment = nil ensure rec.save #データベースへコミット end end #財務チェックを行った日時を、文殊に登録する。 zaimu_checked = Property.find(:first , :conditions => "name = 'zaimu_checked'") unless zaimu_checked zaimu_checked = Property.new zaimu_checked.name = 'zaimu_checked' end zaimu_checked.value = Time.now.strftime("%Y/%m/%d %H:%M") zaimu_checked.save

表示オプション

横に並べて表示:
変化行の前後のみ表示:
記事メニュー
目安箱バナー