gdata-jruby-client 0.7.0 → 0.7.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.
data/README CHANGED
@@ -1,6 +1,6 @@
1
1
  GData JRuby Client
2
2
  =====================
3
- The GData JRuby Client allows you to easily access data through Google Data APIs. It uses the GData Java Client Library from Google.
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
- TBD
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
@@ -13,4 +13,5 @@ module GData
13
13
  include_package 'com.google.gdata.util'
14
14
  include_package 'com.google.gdata.client'
15
15
  include_package 'com.google.gdata.client.authn.oauth'
16
+ include_package 'com.google.gdata.client.http'
16
17
  end
data/lib/base_entry.rb CHANGED
@@ -17,4 +17,8 @@ class Java::ComGoogleGdataData::BaseEntry
17
17
  def id
18
18
  get_id
19
19
  end
20
+
21
+ def link
22
+ get_link(nil, nil)
23
+ end
20
24
  end
@@ -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 => GData::CalendarFeed}))
12
+ def find_feed(options, klass = GData::CalendarFeed)
13
+ super(options.merge({:class => klass}))
14
14
  end
15
15
 
16
- def find_entry(options)
17
- super(options.merge({:class => GData::CalendarEntry}))
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
@@ -3,6 +3,7 @@ DEFAULT_APPLICATION_NAME = "Presdo-GDataJRubyClient-0.1"
3
3
  module GData end
4
4
 
5
5
  require 'java'
6
+ require 'active_support'
6
7
  require File.dirname(__FILE__) + '/base'
7
8
  require File.dirname(__FILE__) + '/contacts_service'
8
9
  require File.dirname(__FILE__) + '/time_ext'
@@ -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=(token, private_key=nil)
9
- self.set_auth_sub_token(token, private_key)
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
- if options[:etag] or options[:modified_since]
18
- get_feed(options[:url] || options[:query],
19
- options[:class].java_class,
20
- options[:etag] || options[:modified_since])
21
- else
22
- get_feed(options[:url] || options[:query],
23
- options[:class].java_class)
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
- if options[:etag] or options[:modified_since]
33
- get_entry(options[:url] || options[:query],
34
- options[:class].java_class,
35
- options[:etag] || options[:modified_since])
36
- else
37
- get_entry(options[:url] || options[:query],
38
- options[:class].java_class)
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
- update_attributes(options)
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
- :consumer_key => CONSUMER_KEY,
287
- :consumer_secret => CONSUMER_SECRET,
288
- :token => TOKEN,
289
- :token_secret => TOKEN_SECRET }
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
- # @service.auth_sub_token = SESSION_TOKEN
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
- credentials = GData::GoogleOAuthParameters.new
140
- credentials.attributes = {
141
- :consumer_key => CONSUMER_KEY,
142
- :consumer_secret => CONSUMER_SECRET,
143
- :token => TOKEN,
144
- :token_secret => TOKEN_SECRET }
145
- @service.oauth_credentials = credentials
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
@@ -8,4 +8,4 @@ CONSUMER_SECRET = "/tO50sDR2F/8tckdObSBgJLl"
8
8
  TOKEN = "1/V1lDQFRoAgAMv-cvoIOmQmATiaQZnWPB51nTvo8n9Sw"
9
9
  TOKEN_SECRET = "uObNrVylI3S8vWeQXQboyC+8"
10
10
 
11
- SESSION_TOKEN = "CM-jpoTEHxDIxcORBg"
11
+ SESSION_TOKEN = 'CM-jpoTEHxDFnoe4-P____8B'
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.0
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-22 00:00:00 -08:00
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: []