orbit-basic/app/jobs/nccu_calendar.rb

22 lines
611 B
Ruby
Raw Normal View History

class NccuCalendar
require 'open-uri'
2012-05-15 06:03:54 +00:00
require 'tempfile'
@queue = :high
def self.perform()
# temp_file = Tempfile.new('new_cal')
# open('http://events.nccu.edu.tw/Month').read{|data|
# temp_file << data
# }
2012-05-15 06:03:54 +00:00
open(File.join(Rails.root, 'public/static', 'nccu_calendar.xml'), 'wb') do |fo|
fo.print open('http://events.nccu.edu.tw/Month').read
end
# FileUtils.mv(temp_file, File.join(Rails.root, 'public/static', 'nccu_calendar.xml'))
2012-05-15 06:03:54 +00:00
2012-10-01 13:09:09 +00:00
puts "[#{ DateTime.now.strftime("%Y %D %H:%M")}]NccuCalendar Synced #{File.join(Rails.root, 'public/static', 'nccu_calendar.xml')}"
end
end