vigetlabs-dockit 0.1 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. data/lib/event_collection.rb +2 -0
  2. data/lib/export.rb +77 -71
  3. metadata +1 -10
@@ -1,3 +1,5 @@
1
+ require 'rexchange'
2
+
1
3
  class EventCollection
2
4
  def initialize
3
5
  @collection = []
@@ -1,5 +1,4 @@
1
- require 'rexchange'
2
- require 'chronic'
1
+ require 'event_collection'
3
2
 
4
3
  module Export
5
4
  def rack_process(user)
@@ -12,75 +11,82 @@ module Export
12
11
  end
13
12
 
14
13
  def exchange(user)
15
- RExchange::open(user.remote_uri, user.email, user.password) do |mailbox|
16
-
17
- # create ics file, clearing any old one
18
- file = File.new("#{user.username}.ics", "w")
19
- raise "Failed to create file #{user.username}.ics" unless file
20
-
21
- file.puts "BEGIN:VCALENDAR"
22
- file.puts "CALSCALE:GREGORIAN"
23
- file.puts "PRODID:-//Apple Computer\, Inc//iCal 2.0//EN"
24
- file.puts "VERSION:2.0"
25
- file.puts "X-WR-CALNAME:#{user.title}"
26
-
27
- # itemcount = 0
28
-
29
- # Loop through all calendar events, making VEVENTS
30
- mailbox.calendar.each do |event|
31
-
32
- file.puts "BEGIN:VEVENT"
33
-
34
- # Set some properties for this event
35
- file.puts "DTSTAMP;TZID=#{user.timezone}:#{dformat(event.created_at)}"
36
- file.puts "DTSTART;TZID=#{user.timezone}:#{dformat(event.start_at)}"
37
- file.puts "DTEND;TZID=#{user.timezone}:#{dformat(event.end_at)}"
38
- file.puts "LAST-MODIFIED;TZID=#{user.timezone}:#{dformat(event.modified_at)}"
39
-
40
- file.puts "SUMMARY:" + (event.subject.blank? ? "Unknown Subject" : event.subject)
41
-
42
- description = event.body.blank? ? "" : event.body.gsub!("\n","\\n").gsub("^\n","")
43
- # ?? add event.href+"?Cmd=accept" or "decline" or "tentative"
44
- # description += event.href+"?Cmd=accept"
45
- # description += event.href+"?Cmd=decline"
46
- # description += event.href+"?Cmd=tentative"
47
-
48
- file.puts "DESCRIPTION:" + description
49
-
50
- file.puts "UID:" + event.uid if event.uid
51
-
52
- if event.reminder_offset && event.reminder_offset.to_i > 60
53
- # ouput valarm details. reminder_offset is in seconds
54
- ro_min = event.reminder_offset.to_i / 60
55
- file.puts "BEGIN:VALARM"
56
- file.puts "TRIGGER:-PT#{ro_min}M"
57
- # item.puts "DESCRIPTION:Påminnelse om aktivitet"
58
- file.puts "ACTION:DISPLAY"
59
- file.puts "END:VALARM"
60
- end
61
-
62
- #add event to calendar
63
- file.puts "END:VEVENT"
64
-
65
- # itemcount += 1
66
- end
67
-
68
- # puts mailbox.inspect
69
- # puts
70
- # puts mailbox.methods
71
-
72
- # Loop through all todos, creating VTODOS
73
- # Loop through all journals, creating VJOURNAL
74
- # Loop through all free/busy time, creating VFREEBUSY
75
- # event.busy_status
76
-
77
- #close ical file
78
- file.puts "END:VCALENDAR"
79
- file.close
80
-
81
- # p "Done! Wrote #{itemcount} appointment items"
82
-
83
- end
14
+ file = File.new("#{user.username}.ics", "w")
15
+ raise "Failed to create file #{user.username}.ics" unless file
16
+
17
+ EventCollection.user = user
18
+ file.puts(EventCollection.all.to_ics)
19
+ file.close
20
+
21
+ # RExchange::open(user.remote_uri, user.email, user.password) do |mailbox|
22
+ #
23
+ # # create ics file, clearing any old one
24
+ # file = File.new("#{user.username}.ics", "w")
25
+ # raise "Failed to create file #{user.username}.ics" unless file
26
+ #
27
+ # file.puts "BEGIN:VCALENDAR"
28
+ # file.puts "CALSCALE:GREGORIAN"
29
+ # file.puts "PRODID:-//Apple Computer\, Inc//iCal 2.0//EN"
30
+ # file.puts "VERSION:2.0"
31
+ # file.puts "X-WR-CALNAME:#{user.title}"
32
+ #
33
+ # # itemcount = 0
34
+ #
35
+ # # Loop through all calendar events, making VEVENTS
36
+ # mailbox.calendar.each do |event|
37
+ #
38
+ # file.puts "BEGIN:VEVENT"
39
+ #
40
+ # # Set some properties for this event
41
+ # file.puts "DTSTAMP;TZID=#{user.timezone}:#{dformat(event.created_at)}"
42
+ # file.puts "DTSTART;TZID=#{user.timezone}:#{dformat(event.start_at)}"
43
+ # file.puts "DTEND;TZID=#{user.timezone}:#{dformat(event.end_at)}"
44
+ # file.puts "LAST-MODIFIED;TZID=#{user.timezone}:#{dformat(event.modified_at)}"
45
+ #
46
+ # file.puts "SUMMARY:" + (event.subject.blank? ? "Unknown Subject" : event.subject)
47
+ #
48
+ # description = event.body.blank? ? "" : event.body.gsub!("\n","\\n").gsub("^\n","")
49
+ # # ?? add event.href+"?Cmd=accept" or "decline" or "tentative"
50
+ # # description += event.href+"?Cmd=accept"
51
+ # # description += event.href+"?Cmd=decline"
52
+ # # description += event.href+"?Cmd=tentative"
53
+ #
54
+ # file.puts "DESCRIPTION:" + description
55
+ #
56
+ # file.puts "UID:" + event.uid if event.uid
57
+ #
58
+ # if event.reminder_offset && event.reminder_offset.to_i > 60
59
+ # # ouput valarm details. reminder_offset is in seconds
60
+ # ro_min = event.reminder_offset.to_i / 60
61
+ # file.puts "BEGIN:VALARM"
62
+ # file.puts "TRIGGER:-PT#{ro_min}M"
63
+ # # item.puts "DESCRIPTION:Påminnelse om aktivitet"
64
+ # file.puts "ACTION:DISPLAY"
65
+ # file.puts "END:VALARM"
66
+ # end
67
+ #
68
+ # #add event to calendar
69
+ # file.puts "END:VEVENT"
70
+ #
71
+ # # itemcount += 1
72
+ # end
73
+ #
74
+ # # puts mailbox.inspect
75
+ # # puts
76
+ # # puts mailbox.methods
77
+ #
78
+ # # Loop through all todos, creating VTODOS
79
+ # # Loop through all journals, creating VJOURNAL
80
+ # # Loop through all free/busy time, creating VFREEBUSY
81
+ # # event.busy_status
82
+ #
83
+ # #close ical file
84
+ # file.puts "END:VCALENDAR"
85
+ # file.close
86
+ #
87
+ # # p "Done! Wrote #{itemcount} appointment items"
88
+ #
89
+ # end
84
90
  end
85
91
 
86
92
  def dformat(t)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vigetlabs-dockit
3
3
  version: !ruby/object:Gem::Version
4
- version: "0.1"
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tony Pitale @ Viget Labs
@@ -30,15 +30,6 @@ dependencies:
30
30
  - !ruby/object:Gem::Version
31
31
  version: 0.3.0
32
32
  version:
33
- - !ruby/object:Gem::Dependency
34
- name: chronic
35
- version_requirement:
36
- version_requirements: !ruby/object:Gem::Requirement
37
- requirements:
38
- - - ">="
39
- - !ruby/object:Gem::Version
40
- version: 0.2.3
41
- version:
42
33
  - !ruby/object:Gem::Dependency
43
34
  name: activesupport
44
35
  version_requirement: