google_contacts_api 0.5.0 → 0.5.1

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.5.0
1
+ 0.5.1
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "google_contacts_api"
8
- s.version = "0.5.0"
8
+ s.version = "0.5.1"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Alvin Liang"]
12
- s.date = "2014-09-27"
12
+ s.date = "2015-05-07"
13
13
  s.description = "Lets you read from the Google Contacts API. Posting to come later."
14
14
  s.email = "ayliang@gmail.com"
15
15
  s.extra_rdoc_files = [
@@ -114,6 +114,8 @@ module GoogleContactsApi
114
114
  def relations
115
115
  self['gContact$relation'] ? self['gContact$relation'] : []
116
116
  end
117
+
118
+ # Returns the spouse of the contact. (Assumes there's only one.)
117
119
  def spouse
118
120
  spouse_rel = relations.find {|r| r.rel = 'spouse'}
119
121
  spouse_rel['$t'] if spouse_rel
@@ -10,13 +10,7 @@ module GoogleContactsApi
10
10
  # orderby, showdeleted, requirealldeleted, sortorder
11
11
  params["max-results"] = 100000 unless params.key?("max-results")
12
12
 
13
- # Set the version, for some reason the header is not effective on its own?
14
- params["v"] = 2
15
-
16
13
  url = "groups/default/full"
17
- # TODO: So weird thing, version 3 doesn't return system groups
18
- # When it does, uncomment this line and use it to request instead
19
- # response = @api.get(url, params)
20
14
  response = @api.get(url, params)
21
15
 
22
16
  case GoogleContactsApi::Api.parse_response_code(response)
@@ -18,7 +18,7 @@ module GoogleContactsApi
18
18
  def contacts!(params = {})
19
19
  # contacts in this group
20
20
  @contacts = nil
21
- contacts
21
+ contacts(params)
22
22
  end
23
23
 
24
24
  # Return the groups for this user and cache them.
@@ -29,7 +29,7 @@ module GoogleContactsApi
29
29
  # Return the groups for this user, retrieving them again from the server.
30
30
  def groups!(params = {})
31
31
  @groups = nil
32
- groups
32
+ groups(params)
33
33
  end
34
34
  end
35
- end
35
+ end
@@ -109,7 +109,7 @@ describe "GoogleContactsApi" do
109
109
  }
110
110
  describe ".get_groups" do
111
111
  it "should get the groups using the internal @api object" do
112
- expect(api).to receive(:get).with("groups/default/full", hash_including(:v => 2)).and_return(Hashie::Mash.new({
112
+ expect(api).to receive(:get).with("groups/default/full", kind_of(Hash)).and_return(Hashie::Mash.new({
113
113
  "body" => "some response", # could use example response here
114
114
  "code" => 200
115
115
  }))
@@ -130,6 +130,22 @@ describe "GoogleContactsApi" do
130
130
  expect(user.groups).to eq("group set")
131
131
  end
132
132
  end
133
+ describe ".groups!" do
134
+ it "should be able to get groups" do
135
+ expect(user).to receive(:get_groups).and_return("group set")
136
+ expect(user.groups!).to eq("group set")
137
+ end
138
+ it "should pass query params along to get_groups" do
139
+ expect(user).to receive(:get_groups).with("something" => "important").and_return("group set")
140
+ expect(user.groups!("something" => "important")).to eq("group set")
141
+ end
142
+ it "should reload the groups" do
143
+ expect(user).to receive(:get_groups).and_return("group set").twice
144
+ user.groups
145
+ groups = user.groups!
146
+ expect(groups).to eq("group set")
147
+ end
148
+ end
133
149
  describe ".contacts" do
134
150
  it "should be able to get contacts" do
135
151
  expect(user).to receive(:get_contacts).and_return("contact set")
@@ -147,6 +163,10 @@ describe "GoogleContactsApi" do
147
163
  expect(user).to receive(:get_contacts).and_return("contact set")
148
164
  expect(user.contacts!).to eq("contact set")
149
165
  end
166
+ it "should pass query params along to get_contacts" do
167
+ expect(user).to receive(:get_contacts).with("something" => "important").and_return("contact set")
168
+ expect(user.contacts!("something" => "important")).to eq("contact set")
169
+ end
150
170
  it "should reload the contacts" do
151
171
  expect(user).to receive(:get_contacts).and_return("contact set").twice
152
172
  user.contacts
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: google_contacts_api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.5.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-09-27 00:00:00.000000000 Z
12
+ date: 2015-05-07 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activesupport
@@ -236,7 +236,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
236
236
  version: '0'
237
237
  segments:
238
238
  - 0
239
- hash: 1433605714673791610
239
+ hash: -2026181777139974429
240
240
  required_rubygems_version: !ruby/object:Gem::Requirement
241
241
  none: false
242
242
  requirements: