gcal4ruby 0.5.4 → 0.5.5

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.
data/CHANGELOG CHANGED
@@ -1,4 +1,9 @@
1
1
  #=CHANGELOG
2
+ #==version 0.5.5
3
+ #* Fixed calendar::find method. Thanks to AB <a.berezovskiy@gmail.com>.
4
+ #* Improved recurrence handling. Thanks to John Paul Narowski <jnarowski@gmail.com>.
5
+ #* Fixed documentation bug for event reminders.
6
+ #* Changed license to LGPLv3.
2
7
  #==version 0.5.4
3
8
  #* Fixed Service#to_iframe bgcolor bug
4
9
  #==version 0.5.3
data/README CHANGED
@@ -7,8 +7,10 @@
7
7
  #
8
8
  #==Author and Contact Information
9
9
  #GCal4Ruby was created and is maintained by {Mike Reich}[mailto:mike@seabourneconsulting.com]
10
- #and is licenses under the GPL v2. Feel free to use and update, but be sure to contribute your
11
- #code back to the project and attribute as required by the license.
10
+ #and is licenses under the LGPL v3. Feel free to use and update, but be sure to contribute your
11
+ #code back to the project and attribute as required by the license. You can find the text of the LGPL
12
+ #here: http://www.gnu.org/licenses/lgpl.html.
13
+ #
12
14
  #===Website
13
15
  #http://cookingandcoding.com/gcal4ruby/
14
16
  #
@@ -182,7 +182,7 @@ module GCal4Ruby
182
182
  cals.each do |cal|
183
183
  if query.is_a?(Hash)
184
184
  results << cal if query[:query] and cal.title.downcase.include? query[:query].downcase
185
- results << cal if query[:title] and cal.title == query[:query]
185
+ results << cal if query[:title] and cal.title == query[:title]
186
186
  else
187
187
  results << cal if cal.title.downcase.include? query.downcase
188
188
  end
@@ -210,21 +210,21 @@ module GCal4Ruby
210
210
  xml = REXML::Document.new(super)
211
211
  xml.root.elements.each(){}.map do |ele|
212
212
  case ele.name
213
- when "summary"
213
+ when "summary"
214
214
  ele.text = @summary
215
- when "timezone"
215
+ when "timezone"
216
216
  ele.attributes["value"] = @timezone
217
- when "hidden"
217
+ when "hidden"
218
218
  ele.attributes["value"] = @hidden.to_s
219
- when "color"
219
+ when "color"
220
220
  ele.attributes["value"] = @color
221
- when "selected"
221
+ when "selected"
222
222
  ele.attributes["value"] = @selected.to_s
223
223
  end
224
224
  end
225
225
  xml.to_s
226
226
  end
227
-
227
+
228
228
  #Loads the Calendar with returned data from Google Calendar feed. Returns true if successful.
229
229
  def load(string)
230
230
  super(string)
@@ -234,23 +234,23 @@ module GCal4Ruby
234
234
  xml.root.elements.each(){}.map do |ele|
235
235
  case ele.name
236
236
  when "id"
237
- @id = ele.text.gsub("http://www.google.com/calendar/feeds/default/calendars/", "")
237
+ @id = ele.text.gsub("http://www.google.com/calendar/feeds/default/calendars/", "")
238
238
  when 'summary'
239
- @summary = ele.text
239
+ @summary = ele.text
240
240
  when "color"
241
- @color = ele.attributes['value']
241
+ @color = ele.attributes['value']
242
242
  when 'hidden'
243
- @hidden = ele.attributes["value"] == "true" ? true : false
243
+ @hidden = ele.attributes["value"] == "true" ? true : false
244
244
  when 'timezone'
245
- @timezone = ele.attributes["value"]
245
+ @timezone = ele.attributes["value"]
246
246
  when "selected"
247
- @selected = ele.attributes["value"] == "true" ? true : false
247
+ @selected = ele.attributes["value"] == "true" ? true : false
248
248
  when "link"
249
- if ele.attributes['rel'] == 'edit'
250
- @edit_feed = ele.attributes['href']
251
- end
249
+ if ele.attributes['rel'] == 'edit'
250
+ @edit_feed = ele.attributes['href']
251
+ end
252
252
  when 'accesslevel'
253
- @editable = (ele.attributes["value"] == 'editor' or ele.attributes["value"] == 'owner' or ele.attributes["value"] == 'root')
253
+ @editable = (ele.attributes["value"] == 'editor' or ele.attributes["value"] == 'owner' or ele.attributes["value"] == 'root')
254
254
  end
255
255
  end
256
256
 
@@ -308,9 +308,9 @@ module GCal4Ruby
308
308
  params[:border] ||= "0"
309
309
  params.each{|key, value| params[key] = CGI::escape(value)}
310
310
  output = "#{params.to_a.collect{|a| a.join("=")}.join("&")}"
311
-
311
+
312
312
  output += "&src=#{id}"
313
-
313
+
314
314
  "<iframe src='http://www.google.com/calendar/embed?#{output}' style='#{params[:border]} px solid;' width='#{params[:width]}' height='#{params[:height]}' frameborder='#{params[:border]}' scrolling='no'></iframe>"
315
315
  end
316
316
 
@@ -341,12 +341,12 @@ module GCal4Ruby
341
341
  params[:border] ||= "0"
342
342
  params.each{|key, value| params[key] = CGI::escape(value)}
343
343
  output = "#{params.to_a.collect{|a| a.join("=")}.join("&")}"
344
-
344
+
345
345
  output += "&src=#{id}"
346
-
346
+
347
347
  "<iframe src='http://www.google.com/calendar/embed?#{output}' style='#{params[:border]} px solid;' width='#{params[:width]}' height='#{params[:height]}' frameborder='#{params[:border]}' scrolling='no'></iframe>"
348
348
  end
349
-
349
+
350
350
  private
351
351
  def self.get_instance(service, d)
352
352
  if d.is_a? Net::HTTPOK
@@ -60,7 +60,7 @@ module GCal4Ruby
60
60
  # event.start_time = Time.parse("06/20/2009 at 5 pm")
61
61
  # event.end_time = Time.parse("06/20/2009 at 8 pm")
62
62
  # event.where = "Luigi's"
63
- # event.reminder = {:minutes => 15, :method => 'email'}
63
+ # event.reminder = [{:minutes => 15, :method => 'email'}]
64
64
  # event.save
65
65
  #
66
66
  #9. Create an event with attendees
@@ -111,7 +111,7 @@ module GCal4Ruby
111
111
  attr_accessor :status
112
112
  #Flag indicating whether it is an all day event
113
113
  attr_reader :all_day
114
- #The reminder settings for the event, returned as a hash
114
+ #An array of reminders. Each item in the array is a hash representing the event reminder.
115
115
  attr_reader :reminder
116
116
  #The date the event was last edited
117
117
  attr_reader :edited
@@ -132,7 +132,7 @@ module GCal4Ruby
132
132
  end
133
133
  end
134
134
 
135
- #Sets the reminder options for the event. Parameter must be a hash a :minutes key with a value of 5 up to 40320 (4 weeks)
135
+ #Sets the reminder options for the event. Parameter must be an array of hashes containing a :minutes key with a value of 5 up to 40320 (4 weeks)
136
136
  #and a :method key of with a value of one the following:
137
137
  #alert:: causes an alert to appear when a user is viewing the calendar in a browser
138
138
  #email:: sends the user an email message
@@ -57,45 +57,36 @@ module GCal4Ruby
57
57
  @all_day ||= false
58
58
  end
59
59
 
60
- #Accepts a string containing a properly formatted ISO 8601 recurrence rule and loads it into the recurrence object
60
+ #Accepts a string containing a properly formatted ISO 8601 recurrence rule and loads it into the recurrence object.
61
+ #Contributed by John Paul Narowski.
61
62
  def load(rec)
63
+ @frequency = {}
62
64
  attrs = rec.split("\n")
63
65
  attrs.each do |val|
64
66
  key, value = val.split(":")
65
- case key
66
- when 'DTSTART'
67
- @start_time = Time.parse_complete(value)
68
- when 'DTSTART;VALUE=DATE'
69
- @start_time = Time.parse(value)
70
- @all_day = true
71
- when 'DTSTART;VALUE=DATE-TIME'
72
- @start_time = Time.parse_complete(value)
73
- when 'DTEND'
74
- @end_time = Time.parse_complete(value)
75
- when 'DTEND;VALUE=DATE'
76
- @end_time = Time.parse(value)
77
- when 'DTEND;VALUE=DATE-TIME'
78
- @end_time = Time.parse_complete(value)
79
- when 'RRULE'
80
- vals = value.split(";")
81
- key = ''
82
- by = ''
83
- int = nil
84
- vals.each do |rr|
85
- a, h = rr.split("=")
86
- case a
87
- when 'FREQ'
88
- key = h.downcase.capitalize
89
- when 'INTERVAL'
90
- int = h
91
- when 'UNTIL'
92
- @repeat_until = Time.parse(value)
93
- else
94
- by = h.split(",")
67
+ if key == 'RRULE'
68
+ value.split(";").each do |rr|
69
+ rr_key, rr_value = rr.split("=")
70
+ rr_key = rr_key.downcase.to_sym
71
+ unless @frequency.has_key?(rr_key)
72
+ if rr_key == :until
73
+ @repeat_until = Time.parse_complete(rr_value)
74
+ else
75
+ @frequency[rr_key] = rr_value
95
76
  end
96
77
  end
97
- @frequency = {key => by}
98
- @frequency.merge({'interval' => int}) if int
78
+ end
79
+ elsif key == 'INTERVAL'
80
+ @frequency[:inverval] = value.to_i
81
+ elsif key.include?("DTSTART;TZID") or key.include?("DTSTART") or key.include?('DTSTART;VALUE=DATE-TIME')
82
+ @start_time = Time.parse_complete(value)
83
+ elsif key.include?('DTSTART;VALUE=DATE')
84
+ @start_time = Time.parse(value)
85
+ @all_day = true
86
+ elsif key.include?("DTEND;TZID") or key.include?("DTEND") or key.include?('DTEND;VALUE=DATE-TIME')
87
+ @end_time = Time.parse_complete(value)
88
+ elsif key.include?('DTEND;VALUE=DATE')
89
+ @end_time = Time.parse(value)
99
90
  end
100
91
  end
101
92
  end
@@ -119,19 +110,19 @@ module GCal4Ruby
119
110
  f += "#{key.downcase} " if key != 'interval'
120
111
  case key.downcase
121
112
  when "secondly"
122
- by += "every #{value} second"
113
+ by += "every #{value} second"
123
114
  when "minutely"
124
- by += "every #{value} minute"
115
+ by += "every #{value} minute"
125
116
  when "hourly"
126
- by += "every #{value} hour"
117
+ by += "every #{value} hour"
127
118
  when "weekly"
128
- by += "on #{value}" if value
119
+ by += "on #{value}" if value
129
120
  when "monthly"
130
- by += "on #{value}"
121
+ by += "on #{value}"
131
122
  when "yearly"
132
- by += "on the #{value} day of the year"
123
+ by += "on the #{value} day of the year"
133
124
  when 'interval'
134
- i += "for #{value} times"
125
+ i += "for #{value} times"
135
126
  end
136
127
  end
137
128
  output += f+i+by
@@ -144,7 +135,6 @@ module GCal4Ruby
144
135
 
145
136
  #Returns a string with the correctly formatted ISO 8601 recurrence rule
146
137
  def to_recurrence_string
147
-
148
138
  output = ''
149
139
  if @all_day
150
140
  output += "DTSTART;VALUE=DATE:#{@start_time.utc.strftime("%Y%m%d")}\n"
@@ -171,22 +161,22 @@ module GCal4Ruby
171
161
  else
172
162
  value = v
173
163
  end
174
- f += "#{key.upcase};" if key != 'interval'
175
- case key.downcase
164
+ f += "#{key.to_s.upcase};" if key != 'interval'
165
+ case key.to_s.downcase
176
166
  when "secondly"
177
- by += "BYSECOND=#{value};"
167
+ by += "BYSECOND=#{value};"
178
168
  when "minutely"
179
- by += "BYMINUTE=#{value};"
169
+ by += "BYMINUTE=#{value};"
180
170
  when "hourly"
181
- by += "BYHOUR=#{value};"
171
+ by += "BYHOUR=#{value};"
182
172
  when "weekly"
183
- by += "BYDAY=#{value};" if value
173
+ by += "BYDAY=#{value};" if value
184
174
  when "monthly"
185
- by += "BYDAY=#{value};"
175
+ by += "BYDAY=#{value};"
186
176
  when "yearly"
187
- by += "BYYEARDAY=#{value};"
177
+ by += "BYYEARDAY=#{value};"
188
178
  when 'interval'
189
- i += "INTERVAL=#{value};"
179
+ i += "INTERVAL=#{value};"
190
180
  end
191
181
  end
192
182
  output += f+i+by
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 5
8
- - 4
9
- version: 0.5.4
8
+ - 5
9
+ version: 0.5.5
10
10
  platform: ruby
11
11
  authors:
12
12
  - Mike Reich
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-05-24 00:00:00 +10:00
17
+ date: 2010-08-15 00:00:00 -04:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
@@ -27,8 +27,8 @@ dependencies:
27
27
  segments:
28
28
  - 0
29
29
  - 1
30
- - 2
31
- version: 0.1.2
30
+ - 5
31
+ version: 0.1.5
32
32
  type: :runtime
33
33
  version_requirements: *id001
34
34
  description: "GCal4Ruby is a Ruby Gem that can be used to interact with the current version of the Google Calendar API. GCal4Ruby provides the following features: Create and edit calendar events, Add and invite users to events, Set reminders, Make recurring events."