gdata-jruby-client 0.7.0 → 0.7.1
Sign up to get free protection for your applications and to get access to all the features.
- data/README +15 -2
- data/lib/base.rb +1 -0
- data/lib/base_entry.rb +4 -0
- data/lib/calendar_service.rb +20 -4
- data/lib/gdata_jruby_client.rb +1 -0
- data/lib/google_service.rb +35 -16
- data/lib/query.rb +15 -1
- data/spec/google_calendar_service_spec.rb +8 -8
- data/spec/google_contacts_service_spec.rb +10 -7
- data/spec/google_keys.rb +1 -1
- metadata +13 -4
data/README
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
GData JRuby Client
|
2
2
|
=====================
|
3
|
-
|
3
|
+
Written at Presdo, the GData JRuby Client allows you to easily access data through Google Data APIs. It uses the GData Java Client Library from Google.
|
4
4
|
|
5
5
|
See more at http://code.google.com/apis/gdata/docs/client-libraries.html
|
6
6
|
The jar files are based on gdata-java-client v1.40.0
|
@@ -22,4 +22,17 @@ SESSION_TOKEN = "auth_sub_token"
|
|
22
22
|
|
23
23
|
Usage
|
24
24
|
=======
|
25
|
-
|
25
|
+
# To get contacts from Google:
|
26
|
+
service = GData::ContactsService.new YOUR_APPLICATION_NAME
|
27
|
+
# Use OAuth
|
28
|
+
credentials = GData::GoogleOAuthParameters.new
|
29
|
+
credentials.attributes = {
|
30
|
+
:consumer_key => CONSUMER_KEY,
|
31
|
+
:consumer_secret => CONSUMER_SECRET,
|
32
|
+
:token => TOKEN,
|
33
|
+
:token_secret => TOKEN_SECRET }
|
34
|
+
service.oauth_credentials = credentials
|
35
|
+
# Use AuthSubToken
|
36
|
+
service.auth_sub_token = { :token => SESSION_TOKEN }
|
37
|
+
feed = service.find_feed(:url => GData::ContactsService::DEFAULT_CONTACTS_URI)
|
38
|
+
contacts = feed.entries
|
data/lib/base.rb
CHANGED
data/lib/base_entry.rb
CHANGED
data/lib/calendar_service.rb
CHANGED
@@ -9,11 +9,27 @@ class Java::ComGoogleGdataClientCalendar::CalendarService
|
|
9
9
|
OWN_CALENDAR_URL = 'http://www.google.com/calendar/feeds/default/owncalendars/full'
|
10
10
|
DEFAULT_CALENDAR_URI = 'http://www.google.com/calendar/feeds/default/private/full'
|
11
11
|
|
12
|
-
def find_feed(options)
|
13
|
-
super(options.merge({:class =>
|
12
|
+
def find_feed(options, klass = GData::CalendarFeed)
|
13
|
+
super(options.merge({:class => klass}))
|
14
14
|
end
|
15
15
|
|
16
|
-
def
|
17
|
-
|
16
|
+
def find_calendars_feed(options)
|
17
|
+
find_feed(options, GData::CalendarFeed)
|
18
|
+
end
|
19
|
+
|
20
|
+
def find_events_feed(options)
|
21
|
+
find_feed(options, GData::CalendarEventFeed)
|
22
|
+
end
|
23
|
+
|
24
|
+
def find_entry(options, klass = GData::CalendarEntry)
|
25
|
+
super(options.merge({:class => klass}))
|
26
|
+
end
|
27
|
+
|
28
|
+
def find_calendar_entry(options)
|
29
|
+
find_entry(options, GData::CalendarEntry)
|
30
|
+
end
|
31
|
+
|
32
|
+
def find_event_entry(options)
|
33
|
+
find_entry(options, GData::CalendarEventEntry)
|
18
34
|
end
|
19
35
|
end
|
data/lib/gdata_jruby_client.rb
CHANGED
data/lib/google_service.rb
CHANGED
@@ -5,8 +5,9 @@ class Java::ComGoogleGdataClient::GoogleService
|
|
5
5
|
self.set_oauth_credentials(credientials, signer)
|
6
6
|
end
|
7
7
|
|
8
|
-
def auth_sub_token=(
|
9
|
-
|
8
|
+
def auth_sub_token=(options)
|
9
|
+
options = {:private_key => nil}.merge(options)
|
10
|
+
self.set_auth_sub_token(options[:token], options[:private_key])
|
10
11
|
end
|
11
12
|
|
12
13
|
def find_feed(options={})
|
@@ -14,13 +15,18 @@ class Java::ComGoogleGdataClient::GoogleService
|
|
14
15
|
raise "Feed Class is required" unless options[:class]
|
15
16
|
options[:url] = url_for(options[:url]) if options[:url]
|
16
17
|
|
17
|
-
|
18
|
-
|
19
|
-
options[:
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
options[:
|
18
|
+
begin
|
19
|
+
if options[:etag] or options[:modified_since]
|
20
|
+
get_feed(options[:url] || options[:query],
|
21
|
+
options[:class].java_class,
|
22
|
+
options[:etag] || options[:modified_since])
|
23
|
+
else
|
24
|
+
get_feed(options[:url] || options[:query],
|
25
|
+
options[:class].java_class)
|
26
|
+
end
|
27
|
+
rescue NativeException => e
|
28
|
+
return nil if e.message =~ /NotFound/
|
29
|
+
raise e
|
24
30
|
end
|
25
31
|
end
|
26
32
|
|
@@ -29,13 +35,18 @@ class Java::ComGoogleGdataClient::GoogleService
|
|
29
35
|
raise "Entry Class is required" unless options[:class]
|
30
36
|
options[:url] = url_for(options[:url]) if options[:url]
|
31
37
|
|
32
|
-
|
33
|
-
|
34
|
-
options[:
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
options[:
|
38
|
+
begin
|
39
|
+
if options[:etag] or options[:modified_since]
|
40
|
+
get_entry(options[:url] || options[:query],
|
41
|
+
options[:class].java_class,
|
42
|
+
options[:etag] || options[:modified_since])
|
43
|
+
else
|
44
|
+
get_entry(options[:url] || options[:query],
|
45
|
+
options[:class].java_class)
|
46
|
+
end
|
47
|
+
rescue NativeException => e
|
48
|
+
return nil if e.message =~ /NotFound/
|
49
|
+
raise e
|
39
50
|
end
|
40
51
|
end
|
41
52
|
|
@@ -47,6 +58,14 @@ class Java::ComGoogleGdataClient::GoogleService
|
|
47
58
|
insert(options[:url], options[:entry])
|
48
59
|
end
|
49
60
|
|
61
|
+
def delete_entry(options={})
|
62
|
+
raise "Feed URL is required" unless options[:url]
|
63
|
+
raise "Entry is required" unless options[:entry]
|
64
|
+
options[:url] = url_for(options[:url]) if options[:url]
|
65
|
+
|
66
|
+
delete(options[:url], options[:entry])
|
67
|
+
end
|
68
|
+
|
50
69
|
def create_batch(options={})
|
51
70
|
raise "Feed URL is required" unless options[:url]
|
52
71
|
raise "Feed is required" unless options[:feed]
|
data/lib/query.rb
CHANGED
@@ -4,7 +4,21 @@ class Java::ComGoogleGdataClient::Query
|
|
4
4
|
def initialize(options)
|
5
5
|
if options.is_a? Hash
|
6
6
|
super url_for(options.delete(:url))
|
7
|
-
|
7
|
+
options.each do |k, v|
|
8
|
+
if self.respond_to? "#{k}=".to_sym
|
9
|
+
self.send("#{k}=".to_sym, (v.kind_of? Time)? v.to_joda_time : v)
|
10
|
+
else
|
11
|
+
name = k.to_s.dasherize
|
12
|
+
case v
|
13
|
+
when Fixnum
|
14
|
+
self.set_integer_custom_parameter(name, v)
|
15
|
+
when Time
|
16
|
+
self.set_string_custom_parameter(name, v.xmlschema)
|
17
|
+
else
|
18
|
+
self.set_string_custom_parameter(name, v.to_s)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
8
22
|
else
|
9
23
|
super url_for(options)
|
10
24
|
end
|
@@ -281,15 +281,15 @@ describe GData::CalendarService do
|
|
281
281
|
def create_service
|
282
282
|
@service = GData::CalendarService.new DEFAULT_APPLICATION_NAME
|
283
283
|
# Use OAuth
|
284
|
-
credentials = GData::GoogleOAuthParameters.new
|
285
|
-
credentials.attributes = {
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
@service.oauth_credentials = credentials
|
284
|
+
# credentials = GData::GoogleOAuthParameters.new
|
285
|
+
# credentials.attributes = {
|
286
|
+
# :consumer_key => CONSUMER_KEY,
|
287
|
+
# :consumer_secret => CONSUMER_SECRET,
|
288
|
+
# :token => TOKEN,
|
289
|
+
# :token_secret => TOKEN_SECRET }
|
290
|
+
# @service.oauth_credentials = credentials
|
291
291
|
# Use AuthSubToken
|
292
|
-
|
292
|
+
@service.auth_sub_token = { :token => SESSION_TOKEN }
|
293
293
|
@service
|
294
294
|
end
|
295
295
|
|
@@ -136,13 +136,16 @@ describe GData::ContactsService do
|
|
136
136
|
|
137
137
|
def create_service
|
138
138
|
@service = GData::ContactsService.new DEFAULT_APPLICATION_NAME
|
139
|
-
|
140
|
-
credentials
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
139
|
+
# Use OAuth
|
140
|
+
# credentials = GData::GoogleOAuthParameters.new
|
141
|
+
# credentials.attributes = {
|
142
|
+
# :consumer_key => CONSUMER_KEY,
|
143
|
+
# :consumer_secret => CONSUMER_SECRET,
|
144
|
+
# :token => TOKEN,
|
145
|
+
# :token_secret => TOKEN_SECRET }
|
146
|
+
# @service.oauth_credentials = credentials
|
147
|
+
# Use AuthSubToken
|
148
|
+
@service.auth_sub_token = { :token => SESSION_TOKEN }
|
146
149
|
@service
|
147
150
|
end
|
148
151
|
|
data/spec/google_keys.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gdata-jruby-client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.7.
|
4
|
+
version: 0.7.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jerry Luk
|
@@ -9,10 +9,19 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2010-01-
|
12
|
+
date: 2010-01-28 00:00:00 -08:00
|
13
13
|
default_executable:
|
14
|
-
dependencies:
|
15
|
-
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: activesupport
|
17
|
+
type: :runtime
|
18
|
+
version_requirement:
|
19
|
+
version_requirements: !ruby/object:Gem::Requirement
|
20
|
+
requirements:
|
21
|
+
- - ">="
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: 2.2.2
|
24
|
+
version:
|
16
25
|
description: The GData JRuby Client allows you to easily access data through Google Data APIs. It uses the GData Java Client Library from Google.
|
17
26
|
email: jerry@presdo.com
|
18
27
|
executables: []
|