edave-gcal4ruby 0.6.0 → 0.7.0
Sign up to get free protection for your applications and to get access to all the features.
- data/{README → README.md} +22 -14
- data/lib/gcal4ruby/calendar.rb +1 -0
- data/lib/gcal4ruby/event.rb +3 -0
- data/lib/gcal4ruby/recurrence.rb +1 -1
- data/lib/gcal4ruby/service.rb +15 -6
- metadata +6 -6
data/{README → README.md}
RENAMED
@@ -1,40 +1,46 @@
|
|
1
|
-
|
1
|
+
# edave-GCal4Ruby
|
2
2
|
|
3
|
-
|
3
|
+
## Introduction
|
4
4
|
GCal4Ruby is a full featured wrapper for the google calendar API. GCal4Ruby implements
|
5
|
-
all of the functionality available through the Google
|
5
|
+
all of the functionality available through the Google Calendar API, including permissions,
|
6
6
|
attendees, reminders and event recurrence.
|
7
7
|
|
8
|
-
|
8
|
+
## Author and Contact Information
|
9
9
|
GCal4Ruby was created and is maintained by {Mike Reich}[mailto:mike@seabourneconsulting.com]
|
10
10
|
and is licenses under the LGPL v3. Feel free to use and update, but be sure to contribute your
|
11
11
|
code back to the project and attribute as required by the license. You can find the text of the LGPL
|
12
12
|
here: http://www.gnu.org/licenses/lgpl.html.
|
13
13
|
|
14
|
-
|
15
|
-
http://cookingandcoding.com/gcal4ruby/
|
14
|
+
### Website
|
15
|
+
http://cookingandcoding.com/gcal4ruby/ (original GCal4Ruby plugin)
|
16
|
+
|
17
|
+
### Description
|
16
18
|
|
17
|
-
==Description
|
18
19
|
GCal4Ruby has three major components: the service, calendar and event objects. Each service
|
19
20
|
has many calendars, which in turn have many events. Each service is the representation of a
|
20
21
|
google account, and thus must be successfully authenticated using valid Google Calendar
|
21
22
|
account credentials.
|
22
23
|
|
23
|
-
|
24
|
+
## Examples
|
25
|
+
|
24
26
|
Below are some common usage examples. For more examples, check the documentation.
|
25
|
-
|
26
|
-
|
27
|
+
|
28
|
+
####Service
|
29
|
+
|
30
|
+
##### Authenticate with the AuthSub service (quickest, dirtiest)
|
27
31
|
service = Service.new
|
28
32
|
service.authenticate({:username => "user@gmail.com", :password => "password"})
|
29
33
|
|
30
|
-
|
34
|
+
##### Authenticate using OAuth (more setup, easier for an app)
|
31
35
|
service = Service.new({:GData4RubyService => :OAuthService})
|
32
|
-
service.authenticate(my_oauth_accesstoken)
|
36
|
+
service.authenticate({:access_token=>my_oauth_accesstoken})
|
37
|
+
|
38
|
+
See [edave-GData4Ruby](https://github.com/edave/GData4Ruby) for more details
|
33
39
|
|
34
40
|
# Get Calendar List
|
35
41
|
calendars = service.calendars
|
36
42
|
|
37
|
-
|
43
|
+
### Calendar
|
38
44
|
All usages assume a successfully authenticated Service.
|
39
45
|
1. Create a new Calendar
|
40
46
|
cal = Calendar.new(service)
|
@@ -51,7 +57,9 @@ All usages assume a successfully authenticated Service.
|
|
51
57
|
|
52
58
|
5. Find all calendars containing a search term
|
53
59
|
cal = Calendar.find(service, "Soccer Team")
|
54
|
-
|
60
|
+
|
61
|
+
### Event
|
62
|
+
|
55
63
|
All usages assume a successfully authenticated Service and valid Calendar.
|
56
64
|
1. Create a new Event
|
57
65
|
event = Event.new(service, {:calendar => cal, :title => "Soccer Game", :start => Time.parse("12-06-2009 at 12:30 PM"), :end => Time.parse("12-06-2009 at 1:30 PM"), :where => "Merry Playfields"})
|
data/lib/gcal4ruby/calendar.rb
CHANGED
data/lib/gcal4ruby/event.rb
CHANGED
@@ -392,6 +392,9 @@ module GCal4Ruby
|
|
392
392
|
end
|
393
393
|
else
|
394
394
|
service.calendars.each do |cal|
|
395
|
+
puts "Event.find() searching calendar: " if service.debug
|
396
|
+
puts cal.content_uri if service.debug
|
397
|
+
puts args.inspect if service.debug
|
395
398
|
ret = service.send_request(GData4Ruby::Request.new(:get, cal.content_uri, nil, nil, args))
|
396
399
|
xml = REXML::Document.new(ret.body).root
|
397
400
|
xml.elements.each("entry") do |e|
|
data/lib/gcal4ruby/recurrence.rb
CHANGED
@@ -27,7 +27,7 @@ class Time
|
|
27
27
|
unless value.nil? || value.empty?
|
28
28
|
if value.include?("T")
|
29
29
|
d, h = value.split("T")
|
30
|
-
return Time.parse(d+" "+h.gsub("Z", ""))
|
30
|
+
return Time.parse(d+" "+(h || "").gsub("Z", ""))
|
31
31
|
else
|
32
32
|
value = value.to_s
|
33
33
|
return Time.parse("#{value[0..3]}-#{value[4..5]}-#{value[6..7]}")
|
data/lib/gcal4ruby/service.rb
CHANGED
@@ -53,10 +53,10 @@ module GCal4Ruby
|
|
53
53
|
attr_accessor :check_public
|
54
54
|
|
55
55
|
#Accepts an optional attributes hash for initialization values
|
56
|
-
def initialize(attributes = {}
|
56
|
+
def initialize(attributes = {})
|
57
57
|
# If the user has specified the type of GData4Ruby class they want, instantiate it
|
58
|
-
if(
|
59
|
-
@gdata_service = GData4Ruby.const_get(
|
58
|
+
if(attributes.has_key?(:GData4RubyService))
|
59
|
+
@gdata_service = GData4Ruby.const_get(attributes[:GData4RubyService]).new(attributes)
|
60
60
|
end
|
61
61
|
# Otherwise use the default service
|
62
62
|
@gdata_service ||= GData4Ruby::Service.new(attributes)
|
@@ -112,20 +112,29 @@ module GCal4Ruby
|
|
112
112
|
end
|
113
113
|
@gdata_service.send_request(request)
|
114
114
|
end
|
115
|
-
|
115
|
+
|
116
|
+
|
116
117
|
#Returns an array of Calendar objects for each calendar associated with
|
117
118
|
#the authenticated account.
|
118
|
-
|
119
|
-
|
119
|
+
# If you want to only load some attributes, you can pass in an array of
|
120
|
+
# string attributes via options[:fields], for example ["@gd:*", "id", "title"]
|
121
|
+
def calendars(options = {})
|
122
|
+
if(options[:fields])
|
123
|
+
params = "?fields=entry(#{options[:fields].join(",")})"
|
124
|
+
end
|
125
|
+
params ||= ""
|
126
|
+
ret = send_request(GData4Ruby::Request.new(:get, create_url(@@calendar_list_feed + params), nil, {"max-results" => "10000"}))
|
120
127
|
cals = []
|
121
128
|
REXML::Document.new(ret.body).root.elements.each("entry"){}.map do |entry|
|
122
129
|
entry = GData4Ruby::Utils.add_namespaces(entry)
|
123
130
|
cal = Calendar.new(self, {:debug => debug})
|
131
|
+
log(entry.inspect)
|
124
132
|
cal.load(entry.to_s)
|
125
133
|
cals << cal
|
126
134
|
end
|
127
135
|
return cals
|
128
136
|
end
|
137
|
+
|
129
138
|
|
130
139
|
#Returns an array of Event objects for each event in this account
|
131
140
|
def events
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: edave-gcal4ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 3
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
|
-
-
|
8
|
+
- 7
|
9
9
|
- 0
|
10
|
-
version: 0.
|
10
|
+
version: 0.7.0
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Mike Reich
|
@@ -17,7 +17,7 @@ autorequire:
|
|
17
17
|
bindir: bin
|
18
18
|
cert_chain: []
|
19
19
|
|
20
|
-
date: 2011-01-
|
20
|
+
date: 2011-01-25 00:00:00 -07:00
|
21
21
|
default_executable:
|
22
22
|
dependencies:
|
23
23
|
- !ruby/object:Gem::Dependency
|
@@ -46,15 +46,15 @@ executables: []
|
|
46
46
|
extensions: []
|
47
47
|
|
48
48
|
extra_rdoc_files:
|
49
|
-
- README
|
49
|
+
- README.md
|
50
50
|
files:
|
51
51
|
- CHANGELOG
|
52
|
-
- README
|
53
52
|
- lib/gcal4ruby.rb
|
54
53
|
- lib/gcal4ruby/calendar.rb
|
55
54
|
- lib/gcal4ruby/event.rb
|
56
55
|
- lib/gcal4ruby/recurrence.rb
|
57
56
|
- lib/gcal4ruby/service.rb
|
57
|
+
- README.md
|
58
58
|
- test/unit.rb
|
59
59
|
has_rdoc: true
|
60
60
|
homepage: https://github.com/edave/GData4Ruby
|