def execute()
@status = 0
time_started = Time.now.utc
date_time_format = DateTimeFormat.new()
logger = Logger.new([$stderr, File.new('log.txt', 'w')])
logger.log('現在の統計ページをもとにリソースファイルのlanguage要素を出力')
logger.log('開始しました。 ' + date_time_format.format(time_started) )
config = Config.new()
current_page_file_name = 'current-page.txt'
resource = Resource.new(logger)
bot = WikiBot.new(config)
begin
bot.login
rescue MediaWikiApiError => error
logger.log(error.to_s)
@status = 1
return
end
current_revision_text = bot.current_revision_text(config.target_statistics_page)
bot.logout
output_file_name = 'resource-languages.xml'
logger.log('出力ファイル: ' + output_file_name )
output = File.new(output_file_name, 'w')
WikiTable.new(current_revision_text, resource, logger).rows.each do |row|
output.puts('<language><code>' + row.code + '</code>' +
'<description>' + row.description + '</description>' +
'<articleOfWiki>' + row.article_of_wiki + '</articleOfWiki>' +
'<englishDescription>' + row.english_description + '</englishDescription>' +
'<score>' + row.score + '</score></language>')
output.flush
end
output.close
process_launcher = ProcessLauncher.new
if (config.text_viewer != nil) then
process_launcher.launch(config.text_viewer, output_file_name, 'テキストビューワの起動に失敗しました: ')
end
time_ended = Time.now.utc
logger.log('終了しました。 ' + date_time_format.format(time_ended))
logger.log('要した時間: ' + (time_ended - time_started).to_s + ' 秒')
end