gmail_contacts 1.1 → 1.2
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.tar.gz.sig +0 -0
- data/History.txt +6 -0
- data/Rakefile +3 -0
- data/lib/gmail_contacts.rb +3 -3
- data/lib/gmail_contacts/test_stub.rb +4 -2
- data/test/test_gmail_contacts.rb +22 -3
- metadata +13 -3
- metadata.gz.sig +0 -0
data.tar.gz.sig
CHANGED
Binary file
|
data/History.txt
CHANGED
data/Rakefile
CHANGED
@@ -8,8 +8,11 @@ Hoe.new('gmail_contacts', GmailContacts::VERSION) do |p|
|
|
8
8
|
p.rubyforge_name = 'seattlerb' # if different than lowercase project name
|
9
9
|
p.developer 'Eric Hodel', 'drbrain@segment7.net'
|
10
10
|
|
11
|
+
p.testlib = :minitest
|
12
|
+
|
11
13
|
p.extra_deps << ['gdata', '~> 1.1']
|
12
14
|
p.extra_deps << ['nokogiri', '~> 1.2']
|
15
|
+
p.extra_dev_deps << ['minitest', '~> 1.3']
|
13
16
|
end
|
14
17
|
|
15
18
|
# vim: syntax=Ruby
|
data/lib/gmail_contacts.rb
CHANGED
@@ -10,7 +10,7 @@ require 'nokogiri'
|
|
10
10
|
|
11
11
|
class GmailContacts
|
12
12
|
|
13
|
-
VERSION = '1.
|
13
|
+
VERSION = '1.2'
|
14
14
|
|
15
15
|
Contact = Struct.new :title, :emails, :ims, :phone_numbers, :addresses,
|
16
16
|
:photo_url
|
@@ -85,7 +85,7 @@ class GmailContacts
|
|
85
85
|
##
|
86
86
|
# Fetches contacts from google for +email+.
|
87
87
|
|
88
|
-
def fetch(email)
|
88
|
+
def fetch(email, revoke = true)
|
89
89
|
get_token
|
90
90
|
|
91
91
|
uri = "http://www.google.com/m8/feeds/contacts/#{email}/full"
|
@@ -105,7 +105,7 @@ class GmailContacts
|
|
105
105
|
|
106
106
|
yield if block_given?
|
107
107
|
ensure
|
108
|
-
revoke_token if token?
|
108
|
+
revoke_token if revoke and token?
|
109
109
|
end
|
110
110
|
|
111
111
|
##
|
@@ -186,10 +186,12 @@ class GData::Client::Contacts
|
|
186
186
|
def authsub_token=(token)
|
187
187
|
@stub_token = token
|
188
188
|
auth_handler = Object.new
|
189
|
-
|
190
|
-
|
189
|
+
auth_handler.instance_variable_set :@revoked, nil
|
190
|
+
auth_handler.instance_variable_set :@upgraded, nil
|
191
191
|
def auth_handler.revoke() @revoked = true end
|
192
192
|
def auth_handler.revoked?() @revoked end
|
193
|
+
def auth_handler.upgrade() @upgraded = true end
|
194
|
+
def auth_handler.upgraded?() @upgraded end
|
193
195
|
self.auth_handler = auth_handler
|
194
196
|
end
|
195
197
|
|
data/test/test_gmail_contacts.rb
CHANGED
@@ -1,9 +1,10 @@
|
|
1
|
-
require '
|
1
|
+
require 'rubygems'
|
2
|
+
require 'minitest/autorun'
|
2
3
|
require 'gmail_contacts'
|
3
4
|
require 'gmail_contacts/test_stub'
|
4
5
|
require 'pp'
|
5
6
|
|
6
|
-
class TestGmailContacts <
|
7
|
+
class TestGmailContacts < MiniTest::Unit::TestCase
|
7
8
|
|
8
9
|
def setup
|
9
10
|
@gc = GmailContacts.new 'token'
|
@@ -43,7 +44,7 @@ class TestGmailContacts < Test::Unit::TestCase
|
|
43
44
|
raise GData::Client::AuthorizationError, res
|
44
45
|
end
|
45
46
|
|
46
|
-
|
47
|
+
assert_raises GData::Client::AuthorizationError do
|
47
48
|
@gc.fetch 'notme@example.com'
|
48
49
|
end
|
49
50
|
|
@@ -57,6 +58,24 @@ class TestGmailContacts < Test::Unit::TestCase
|
|
57
58
|
assert @api.auth_handler.revoked?
|
58
59
|
end
|
59
60
|
|
61
|
+
def test_fetch_no_revoke
|
62
|
+
@api.stub_data << GmailContacts::TestStub::CONTACTS
|
63
|
+
@api.stub_data << GmailContacts::TestStub::CONTACTS2
|
64
|
+
|
65
|
+
@gc.fetch 'eric@example.com', false
|
66
|
+
|
67
|
+
assert_equal 3, @gc.contacts.length
|
68
|
+
|
69
|
+
assert_equal 2, @api.stub_urls.length
|
70
|
+
assert_equal 'http://www.google.com/m8/feeds/contacts/eric@example.com/full',
|
71
|
+
@api.stub_urls.shift
|
72
|
+
assert_equal 'http://www.google.com/m8/feeds/contacts/eric%40example.com/full?start-index=3&max-results=2',
|
73
|
+
@api.stub_urls.shift
|
74
|
+
|
75
|
+
assert @api.auth_handler.upgraded?
|
76
|
+
refute @api.auth_handler.revoked?
|
77
|
+
end
|
78
|
+
|
60
79
|
def test_fetch_photo
|
61
80
|
@api.stub_data << 'THIS IS A PHOTO!'
|
62
81
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gmail_contacts
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: "1.
|
4
|
+
version: "1.2"
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Eric Hodel
|
@@ -30,7 +30,7 @@ cert_chain:
|
|
30
30
|
x52qPcexcYZR7w==
|
31
31
|
-----END CERTIFICATE-----
|
32
32
|
|
33
|
-
date: 2009-05-
|
33
|
+
date: 2009-05-05 00:00:00 -07:00
|
34
34
|
default_executable:
|
35
35
|
dependencies:
|
36
36
|
- !ruby/object:Gem::Dependency
|
@@ -53,6 +53,16 @@ dependencies:
|
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: "1.2"
|
55
55
|
version:
|
56
|
+
- !ruby/object:Gem::Dependency
|
57
|
+
name: minitest
|
58
|
+
type: :development
|
59
|
+
version_requirement:
|
60
|
+
version_requirements: !ruby/object:Gem::Requirement
|
61
|
+
requirements:
|
62
|
+
- - ~>
|
63
|
+
- !ruby/object:Gem::Version
|
64
|
+
version: "1.3"
|
65
|
+
version:
|
56
66
|
- !ruby/object:Gem::Dependency
|
57
67
|
name: hoe
|
58
68
|
type: :development
|
@@ -112,7 +122,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
112
122
|
requirements: []
|
113
123
|
|
114
124
|
rubyforge_project: seattlerb
|
115
|
-
rubygems_version: 1.3.
|
125
|
+
rubygems_version: 1.3.3
|
116
126
|
signing_key:
|
117
127
|
specification_version: 3
|
118
128
|
summary: Simple Gmail contacts extraction using GData
|
metadata.gz.sig
CHANGED
Binary file
|