orbit-basic/app/jobs/nccu_calendar.rb

22 lines
507 B
Ruby

class NccuCalendar
require 'open-uri'
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
# }
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'))
puts "NccuCalendar Synced4"
end
end