Module: Export
- Included in:
- Dockit
- Defined in:
- lib/export.rb
Instance Method Summary collapse
Instance Method Details
#dformat(t) ⇒ Object
92 93 94 |
# File 'lib/export.rb', line 92 def dformat(t) t.strftime('%Y%m%dT%H%M%S') end |
#exchange(user) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 |
# File 'lib/export.rb', line 13 def exchange(user) file = File.new("#{user.username}.ics", "w") raise "Failed to create file #{user.username}.ics" unless file EventCollection.user = user file.puts(EventCollection.all.to_ics) file.close # RExchange::open(user.remote_uri, user.email, user.password) do |mailbox| # # # create ics file, clearing any old one # file = File.new("#{user.username}.ics", "w") # raise "Failed to create file #{user.username}.ics" unless file # # file.puts "BEGIN:VCALENDAR" # file.puts "CALSCALE:GREGORIAN" # file.puts "PRODID:-//Apple Computer\, Inc//iCal 2.0//EN" # file.puts "VERSION:2.0" # file.puts "X-WR-CALNAME:#{user.title}" # # # itemcount = 0 # # # Loop through all calendar events, making VEVENTS # mailbox.calendar.each do |event| # # file.puts "BEGIN:VEVENT" # # # Set some properties for this event # file.puts "DTSTAMP;TZID=#{user.timezone}:#{dformat(event.created_at)}" # file.puts "DTSTART;TZID=#{user.timezone}:#{dformat(event.start_at)}" # file.puts "DTEND;TZID=#{user.timezone}:#{dformat(event.end_at)}" # file.puts "LAST-MODIFIED;TZID=#{user.timezone}:#{dformat(event.modified_at)}" # # file.puts "SUMMARY:" + (event.subject.blank? ? "Unknown Subject" : event.subject) # # description = event.body.blank? ? "" : event.body.gsub!("\n","\\n").gsub("^\n","") # # ?? add event.href+"?Cmd=accept" or "decline" or "tentative" # # description += event.href+"?Cmd=accept" # # description += event.href+"?Cmd=decline" # # description += event.href+"?Cmd=tentative" # # file.puts "DESCRIPTION:" + description # # file.puts "UID:" + event.uid if event.uid # # if event.reminder_offset && event.reminder_offset.to_i > 60 # # ouput valarm details. reminder_offset is in seconds # ro_min = event.reminder_offset.to_i / 60 # file.puts "BEGIN:VALARM" # file.puts "TRIGGER:-PT#{ro_min}M" # # item.puts "DESCRIPTION:Påminnelse om aktivitet" # file.puts "ACTION:DISPLAY" # file.puts "END:VALARM" # end # # #add event to calendar # file.puts "END:VEVENT" # # # itemcount += 1 # end # # # puts mailbox.inspect # # puts # # puts mailbox.methods # # # Loop through all todos, creating VTODOS # # Loop through all journals, creating VJOURNAL # # Loop through all free/busy time, creating VFREEBUSY # # event.busy_status # # #close ical file # file.puts "END:VCALENDAR" # file.close # # # p "Done! Wrote #{itemcount} appointment items" # # end end |
#rack_process(user) ⇒ Object
4 5 6 7 8 9 10 11 |
# File 'lib/export.rb', line 4 def rack_process(user) lambda do |env| # puts user.inspect exchange(user) Rack::File.new('.').call(env) end end |