google_apps_api 0.2.1 → 0.2.2

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.1
1
+ 0.2.2
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{google_apps_api}
8
- s.version = "0.2.1"
8
+ s.version = "0.2.2"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["James Stuart"]
@@ -62,6 +62,16 @@ module GoogleAppsApi #:nodoc:
62
62
  @id = xml.at_css("id").content.gsub(/^.+\/base\//,"")
63
63
  @domain = xml.at_css("id").content.gsub(/^.+\/contacts\/([^\/]+)\/.+$/,"\\1")
64
64
  @name = xml.at_css("title").content
65
+
66
+ xml.css("gd|email").each do |email_node|
67
+ loc = email_node.attribute("rel").content.gsub(/^.+\#/,"").to_sym
68
+ email = email_node.attribute("address").content
69
+ primary = email_node.attribute("primary") && email_node.attribute("primary").content == "true"
70
+
71
+ @primary_email = loc if primary
72
+ @emails[loc] = email
73
+
74
+ end
65
75
  else
66
76
  if args.first.kind_of?(String)
67
77
  super(:contact => args.first)
@@ -5,56 +5,29 @@ class GoogleAppsApiContactsTest < Test::Unit::TestCase
5
5
 
6
6
  context "given a connection to apps.cul" do
7
7
  setup do
8
- gapps_config =YAML::load_file("private/gapps-config.yml")["apps_cul"].symbolize_keys!
8
+ gapps_config =YAML::load_file("private/gapps-config.yml")["apps_ocelot"].symbolize_keys!
9
9
  @co_api = Contacts::Api.new(gapps_config)
10
10
  end
11
11
 
12
12
  should "have a token" do
13
13
  assert @co_api.token
14
14
  end
15
- #
16
- # should "be able to retrieve user" do
17
- # resp = @api.retrieve_user("jws2135")
18
- #
19
- # assert_kind_of UserEntity, resp
20
- #
21
- # assert_equal resp.id, "jws2135"
22
- # end
23
- #
24
- # should "throw an error if given an invalid user" do
25
- # assert_raises GDataError do
26
- # resp = @api.retrieve_user("xx_jws2135")
27
- # end
28
- # end
29
- #
30
- #
15
+
31
16
  should "be able to retrieve all contacts" do
32
17
  cons = @co_api.retrieve_all_contacts
33
18
  assert_kind_of Array, cons
34
19
 
35
20
  end
36
-
37
- # should "be able to remove all contacts" do
38
- # cons = @co_api.retrieve_all_contacts
39
- #
40
- # cons.each do |con|
41
- # @co_api.remove_contact(con, :debug => true)
42
- # end
43
- # end
44
-
45
- #
46
- # should "be able to create a contact" do
47
- # contact = ContactEntity.new(:id => "_new_", :name => "Bizarre Test", :emails => {:work => "james.stuart+bizarretest@columbia.edu", :home => "james.stuart+bizarretest@gmail.com"}, :primary_email => :work)
48
- # res = @co_api.create_contact(contact, :debug => true)
49
- #
50
- # assert_kind_of ContactEntity, res
51
- #
52
- # puts res.inspect
53
- #
54
- # # @co_api.remove_contact(res, :debug => true)
55
- #
56
- # end
57
- #
21
+
22
+ should "be able to create a contact" do
23
+ contact = ContactEntity.new(:id => "_new_", :name => "Bizarre Test", :emails => {:work => "james.stuart+bizarretest@columbia.edu", :home => "james.stuart+bizarretest@gmail.com"}, :primary_email => :work)
24
+ res = @co_api.create_contact(contact)
25
+
26
+ assert_kind_of ContactEntity, res
27
+
28
+ @co_api.remove_contact(res)
29
+ end
30
+
58
31
 
59
32
 
60
33
  #
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: google_apps_api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Stuart