gcal4ruby 0.1.2 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG CHANGED
@@ -1,4 +1,8 @@
1
1
  #=CHANGELOG
2
+ #==version 0.1.3
3
+ #-Added support for authenticating with Google Hosted Apps accounts
4
+ #-Added flag to indicate whether a calendar is editable
5
+ #-Added handling to gracefully throw error when trying to create event on a non-editable (shared) calendar
2
6
  #==version 0.1.2
3
7
  #-Fixed to_xml dump problem with hidden and selected attributes
4
8
  #==version 0.1.1
@@ -62,6 +62,8 @@ module GCal4Ruby
62
62
  class EventSaveFailed < StandardError; end
63
63
 
64
64
  class RecurrenceValueError < StandardError; end
65
+
66
+ class CalendarNotEditable < StandardError; end
65
67
 
66
68
  #The ProxyInfo class contains information for configuring a proxy connection
67
69
 
@@ -55,6 +55,9 @@ class Calendar
55
55
  #The event feed for the calendar
56
56
  attr_reader :event_feed
57
57
 
58
+ #A flag indicating whether the calendar is editable by this account
59
+ attr_reader :editable
60
+
58
61
  #Returns true if the calendar exists on the Google Calendar system (i.e. was
59
62
  #loaded or has been saved). Otherwise returns false.
60
63
  def exists?
@@ -203,7 +206,7 @@ class Calendar
203
206
  end
204
207
  t = Calendar.find(service, @id, :first)
205
208
  if t
206
- load(t.xml)
209
+ load(t.to_xml)
207
210
  else
208
211
  return false
209
212
  end
@@ -268,8 +271,10 @@ class Calendar
268
271
  ret = @service.send_get("http://www.google.com/calendar/feeds/#{@id}/acl/full/")
269
272
  rescue Exception => e
270
273
  @public = false
274
+ @editable = false
271
275
  return true
272
276
  end
277
+ @editable = true
273
278
  r = REXML::Document.new(ret.read_body)
274
279
  r.root.elements.each("entry") do |ele|
275
280
  ele.elements.each do |e|
@@ -174,6 +174,9 @@ module GCal4Ruby
174
174
 
175
175
  #Creates a new Event. Accepts a valid Calendar object.
176
176
  def initialize(calendar)
177
+ if not calendar.editable
178
+ raise CalendarNotEditable
179
+ end
177
180
  super()
178
181
  @xml = EVENT_XML
179
182
  @calendar = calendar
@@ -28,7 +28,7 @@ class Service < Base
28
28
  # If authentication succeeds, returns true, otherwise raises the AuthenticationFailed error.
29
29
  def authenticate(username, password)
30
30
  ret = nil
31
- ret = send_post(AUTH_URL, "Email=#{username}&Passwd=#{password}&source=GCal4Ruby&service=cl")
31
+ ret = send_post(AUTH_URL, "Email=#{username}&Passwd=#{password}&source=GCal4Ruby&service=cl&accountType=HOSTED_OR_GOOGLE")
32
32
  if ret.class == Net::HTTPOK
33
33
  @auth_token = ret.read_body.to_a[2].gsub("Auth=", "").strip
34
34
  @account = username
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gcal4ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mike Reich