keavy-contacts 0.2.8
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.rdoc +51 -0
- data/VERSION.yml +4 -0
- data/lib/config/contacts.yml +10 -0
- data/lib/contacts/flickr.rb +133 -0
- data/lib/contacts/google.rb +308 -0
- data/lib/contacts/google_oauth.rb +91 -0
- data/lib/contacts/version.rb +9 -0
- data/lib/contacts/windows_live.rb +165 -0
- data/lib/contacts/yahoo.rb +236 -0
- data/lib/contacts.rb +46 -0
- data/spec/contact_spec.rb +41 -0
- data/spec/feeds/contacts.yml +10 -0
- data/spec/feeds/flickr/auth.getFrob.xml +4 -0
- data/spec/feeds/flickr/auth.getToken.xml +5 -0
- data/spec/feeds/google-many.xml +48 -0
- data/spec/feeds/google-single.xml +46 -0
- data/spec/feeds/wl_contacts.xml +29 -0
- data/spec/feeds/yh_contacts.txt +119 -0
- data/spec/feeds/yh_credential.xml +28 -0
- data/spec/flickr/auth_spec.rb +80 -0
- data/spec/gmail/auth_spec.rb +70 -0
- data/spec/gmail/fetching_spec.rb +196 -0
- data/spec/rcov.opts +2 -0
- data/spec/spec.opts +2 -0
- data/spec/spec_helper.rb +84 -0
- data/spec/windows_live/windows_live_spec.rb +34 -0
- data/spec/yahoo/yahoo_spec.rb +83 -0
- metadata +90 -0
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
require 'contacts/yahoo'
|
|
3
|
+
|
|
4
|
+
describe Contacts::Yahoo do
|
|
5
|
+
|
|
6
|
+
before(:each) do
|
|
7
|
+
@path = Dir.getwd + '/spec/feeds/'
|
|
8
|
+
@yahoo = Contacts::Yahoo.new(@path + 'contacts.yml')
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
it 'should generate an athentication URL' do
|
|
12
|
+
auth_url = @yahoo.get_authentication_url()
|
|
13
|
+
auth_url.should match(/https:\/\/api.login.yahoo.com\/WSLogin\/V1\/wslogin\?appid=i%3DB%26p%3DUw70JGIdHWVRbpqYItcMw--&ts=.*&sig=.*/)
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
it 'should have a simple interface to grab the contacts' do
|
|
17
|
+
@yahoo.expects(:access_user_credentials).returns(read_file('yh_credential.xml'))
|
|
18
|
+
@yahoo.expects(:access_address_book_api).returns(read_file('yh_contacts.txt'))
|
|
19
|
+
|
|
20
|
+
redirect_path = '/?appid=i%3DB%26p%3DUw70JGIdHWVRbpqYItcMw--&token=AB.KoEg8vBwvJKFkwfcDTJEMKhGeAD6KhiDe0aZLCvoJzMeQG00-&appdata=&ts=1218501215&sig=d381fba89c7e9d3c14788720733c3fbf'
|
|
21
|
+
|
|
22
|
+
results = @yahoo.contacts(redirect_path)
|
|
23
|
+
results.should have_contact('Hugo Barauna', 'hugo.barauna@gmail.com')
|
|
24
|
+
results.should have_contact('Nina Benchimol', 'nina@hotmail.com')
|
|
25
|
+
results.should have_contact('Andrea Dimitri', 'and@yahoo.com')
|
|
26
|
+
results.should have_contact('Ricardo Fiorelli', 'ricardo@poli.usp.br')
|
|
27
|
+
results.should have_contact('Priscila', 'pizinha@yahoo.com.br')
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
it 'should validate yahoo redirect signature' do
|
|
31
|
+
redirect_path = '/?appid=i%3DB%26p%3DUw70JGIdHWVRbpqYItcMw--&token=AB.KoEg8vBwvJKFkwfcDTJEMKhGeAD6KhiDe0aZLCvoJzMeQG00-&appdata=&ts=1218501215&sig=d381fba89c7e9d3c14788720733c3fbf'
|
|
32
|
+
|
|
33
|
+
@yahoo.validate_signature(redirect_path).should be_true
|
|
34
|
+
@yahoo.token.should == 'AB.KoEg8vBwvJKFkwfcDTJEMKhGeAD6KhiDe0aZLCvoJzMeQG00-'
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
it 'should detect when the redirect is not valid' do
|
|
38
|
+
redirect_path = '/?appid=i%3DB%26p%3DUw70JGIdHWVRbpqYItcMw--&token=AB.KoEg8vBwvJKFkwfcDTJEMKhGeAD6KhiDe0aZLCvoJzMeQG00-&appdata=&ts=1218501215&sig=de4fe4ebd50a8075f75dcc23f6aca04f'
|
|
39
|
+
|
|
40
|
+
lambda{ @yahoo.validate_signature(redirect_path) }.should raise_error
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
it 'should generate the credential request URL' do
|
|
44
|
+
redirect_path = '/?appid=i%3DB%26p%3DUw70JGIdHWVRbpqYItcMw--&token=AB.KoEg8vBwvJKFkwfcDTJEMKhGeAD6KhiDe0aZLCvoJzMeQG00-&appdata=&ts=1218501215&sig=d381fba89c7e9d3c14788720733c3fbf'
|
|
45
|
+
@yahoo.validate_signature(redirect_path)
|
|
46
|
+
|
|
47
|
+
@yahoo.get_credential_url.should match(/https:\/\/api.login.yahoo.com\/WSLogin\/V1\/wspwtoken_login\?appid=i%3DB%26p%3DUw70JGIdHWVRbpqYItcMw--&ts=.*&token=.*&sig=.*/)
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
it 'should parse the credential XML' do
|
|
51
|
+
@yahoo.parse_credentials(read_file('yh_credential.xml'))
|
|
52
|
+
|
|
53
|
+
@yahoo.wssid.should == 'tr.jZsW/ulc'
|
|
54
|
+
@yahoo.cookie.should == 'Y=cdunlEx76ZEeIdWyeJNOegxfy.jkeoULJCnc7Q0Vr8D5P.u.EE2vCa7G2MwBoULuZhvDZuJNqhHwF3v5RJ4dnsWsEDGOjYV1k6snoln3RlQmx0Ggxs0zAYgbaA4BFQk5ieAkpipq19l6GoD_k8IqXRfJN0Q54BbekC_O6Tj3zl2wV3YQK6Mi2MWBQFSBsO26Tw_1yMAF8saflF9EX1fQl4N.1yBr8UXb6LLDiPQmlISq1_c6S6rFbaOhSZMgO78f2iqZmUAk9RmCHrqPJiHEo.mJlxxHaQsuqTMf7rwLEHqK__Gi_bLypGtaslqeWyS0h2J.B5xwRC8snfEs3ct_kLXT3ngP_pK3MeMf2pe1TiJ4JXVciY9br.KJFUgNd4J6rmQsSFj4wPLoMGCETfVc.M8KLiaFHasZqXDyCE7tvd1khAjQ_xLfQKlg1GlBOWmbimQ1FhdHnsVj3svXjEGquRh8JI2sHIQrzoiqAPBf9WFKQcH0t_1dxf4MOH.7gJaYDPEozCW5EcCsYjuHup9xJKxyTddh5pk8yUg5bURzA.TwPalExMKsbv.RWFBhzWKuTp5guNcqjmUHcCoT19_qFENHX41Xf3texAnsDDGj'
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
it 'should parse the contacts json response' do
|
|
58
|
+
json = read_file('yh_contacts.txt')
|
|
59
|
+
|
|
60
|
+
Contacts::Yahoo.parse_contacts(json).should have_contact('Hugo Barauna', 'hugo.barauna@gmail.com')
|
|
61
|
+
Contacts::Yahoo.parse_contacts(json).should have_contact('Nina Benchimol', 'nina@hotmail.com')
|
|
62
|
+
Contacts::Yahoo.parse_contacts(json).should have_contact('Andrea Dimitri', 'and@yahoo.com')
|
|
63
|
+
Contacts::Yahoo.parse_contacts(json).should have_contact('Ricardo Fiorelli', 'ricardo@poli.usp.br')
|
|
64
|
+
Contacts::Yahoo.parse_contacts(json).should have_contact('Priscila', 'pizinha@yahoo.com.br')
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
it 'should can be initialized by a YAML file' do
|
|
68
|
+
@yahoo.appid.should == 'i%3DB%26p%3DUw70JGIdHWVRbpqYItcMw--'
|
|
69
|
+
@yahoo.secret.should == 'a34f389cbd135de4618eed5e23409d34450'
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
def read_file(file)
|
|
73
|
+
File.open(@path + file, 'r+').read
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
def have_contact(name, email)
|
|
77
|
+
matcher_class = Class.new()
|
|
78
|
+
matcher_class.instance_eval do
|
|
79
|
+
define_method(:matches?) {|some_contacts| some_contacts.any? {|a_contact| a_contact.name == name && a_contact.emails.include?(email)}}
|
|
80
|
+
end
|
|
81
|
+
matcher_class.new
|
|
82
|
+
end
|
|
83
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: keavy-contacts
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.2.8
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- "Mislav Marohni\xC4\x87"
|
|
8
|
+
- Lukas Fittl
|
|
9
|
+
- Keavy Miller
|
|
10
|
+
autorequire:
|
|
11
|
+
bindir: bin
|
|
12
|
+
cert_chain: []
|
|
13
|
+
|
|
14
|
+
date: 2009-02-22 00:00:00 -08:00
|
|
15
|
+
default_executable:
|
|
16
|
+
dependencies: []
|
|
17
|
+
|
|
18
|
+
description: TODO
|
|
19
|
+
email: keavy@minimetre.com
|
|
20
|
+
executables: []
|
|
21
|
+
|
|
22
|
+
extensions: []
|
|
23
|
+
|
|
24
|
+
extra_rdoc_files: []
|
|
25
|
+
|
|
26
|
+
files:
|
|
27
|
+
- README.rdoc
|
|
28
|
+
- VERSION.yml
|
|
29
|
+
- lib/config
|
|
30
|
+
- lib/config/contacts.yml
|
|
31
|
+
- lib/contacts
|
|
32
|
+
- lib/contacts/flickr.rb
|
|
33
|
+
- lib/contacts/google.rb
|
|
34
|
+
- lib/contacts/google_oauth.rb
|
|
35
|
+
- lib/contacts/version.rb
|
|
36
|
+
- lib/contacts/windows_live.rb
|
|
37
|
+
- lib/contacts/yahoo.rb
|
|
38
|
+
- lib/contacts.rb
|
|
39
|
+
- spec/contact_spec.rb
|
|
40
|
+
- spec/feeds
|
|
41
|
+
- spec/feeds/contacts.yml
|
|
42
|
+
- spec/feeds/flickr
|
|
43
|
+
- spec/feeds/flickr/auth.getFrob.xml
|
|
44
|
+
- spec/feeds/flickr/auth.getToken.xml
|
|
45
|
+
- spec/feeds/google-many.xml
|
|
46
|
+
- spec/feeds/google-single.xml
|
|
47
|
+
- spec/feeds/wl_contacts.xml
|
|
48
|
+
- spec/feeds/yh_contacts.txt
|
|
49
|
+
- spec/feeds/yh_credential.xml
|
|
50
|
+
- spec/flickr
|
|
51
|
+
- spec/flickr/auth_spec.rb
|
|
52
|
+
- spec/gmail
|
|
53
|
+
- spec/gmail/auth_spec.rb
|
|
54
|
+
- spec/gmail/fetching_spec.rb
|
|
55
|
+
- spec/rcov.opts
|
|
56
|
+
- spec/spec.opts
|
|
57
|
+
- spec/spec_helper.rb
|
|
58
|
+
- spec/windows_live
|
|
59
|
+
- spec/windows_live/windows_live_spec.rb
|
|
60
|
+
- spec/yahoo
|
|
61
|
+
- spec/yahoo/yahoo_spec.rb
|
|
62
|
+
has_rdoc: true
|
|
63
|
+
homepage: http://github.com/keavy/contacts
|
|
64
|
+
post_install_message:
|
|
65
|
+
rdoc_options:
|
|
66
|
+
- --inline-source
|
|
67
|
+
- --charset=UTF-8
|
|
68
|
+
require_paths:
|
|
69
|
+
- lib
|
|
70
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
71
|
+
requirements:
|
|
72
|
+
- - ">="
|
|
73
|
+
- !ruby/object:Gem::Version
|
|
74
|
+
version: "0"
|
|
75
|
+
version:
|
|
76
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
77
|
+
requirements:
|
|
78
|
+
- - ">="
|
|
79
|
+
- !ruby/object:Gem::Version
|
|
80
|
+
version: "0"
|
|
81
|
+
version:
|
|
82
|
+
requirements: []
|
|
83
|
+
|
|
84
|
+
rubyforge_project:
|
|
85
|
+
rubygems_version: 1.2.0
|
|
86
|
+
signing_key:
|
|
87
|
+
specification_version: 2
|
|
88
|
+
summary: TODO
|
|
89
|
+
test_files: []
|
|
90
|
+
|