contact-data 0.2.2 → 0.2.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +3 -0
- data/.hound.yml +4 -0
- data/.ruby-version +1 -1
- data/contact-data.gemspec +1 -1
- data/lib/contact-data/contact.rb +6 -0
- data/lib/contact-data/fetcher.rb +12 -5
- data/lib/contact-data/version.rb +1 -1
- data/spec/contact-data_contact_spec.rb +12 -1
- data/spec/fetcher_spec.rb +16 -1
- data/spec/support/cassettes/name_search.yml +1 -1
- data/spec/support/cassettes/source_slug.yml +49 -0
- metadata +7 -12
- data/Gemfile.lock +0 -73
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f710aaded7b29a23aeeaba066b6ab44a3dccf35e
|
4
|
+
data.tar.gz: 92d0d640a4b6dea1c394a459b51e1cef687b2415
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ee1f83d6fc779a5c811ed36115c66104b8ac1d9578325883ae0413c7529926bf8552645457d0a98708f4033f0ad2ad4a6acbebc3c616ea185d30c97cd98b6d63
|
7
|
+
data.tar.gz: 1cac72dde7c016f3936d0d6d9491c037890f447c2b3050964a8b6fa94a97da8a9cbfccb909a7893c31d3631ac972344fa041fcfac2f011b39a473a2037160918
|
data/.gitignore
CHANGED
data/.hound.yml
CHANGED
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.1.
|
1
|
+
2.1.5
|
data/contact-data.gemspec
CHANGED
@@ -24,7 +24,7 @@ Gem::Specification.new do |spec|
|
|
24
24
|
spec.add_development_dependency 'rake', '~> 10'
|
25
25
|
spec.add_development_dependency 'rspec', '~> 2'
|
26
26
|
spec.add_development_dependency 'gem-release', '~> 0'
|
27
|
-
spec.add_development_dependency 'simplecov', '~> 0.
|
27
|
+
spec.add_development_dependency 'simplecov', '~> 0.9'
|
28
28
|
spec.add_development_dependency 'coveralls', '~> 0'
|
29
29
|
spec.add_development_dependency 'vcr', '~> 2'
|
30
30
|
spec.add_development_dependency 'webmock', '~> 1'
|
data/lib/contact-data/contact.rb
CHANGED
@@ -9,6 +9,12 @@ module ContactData
|
|
9
9
|
options[:params] = { name: name }
|
10
10
|
Fetcher.get(:search, options)
|
11
11
|
end
|
12
|
+
|
13
|
+
def from(source, slug, options = {})
|
14
|
+
options[:base] = BASE
|
15
|
+
options[:params] = { source: source, slug: slug }
|
16
|
+
Fetcher.get(:from, options)
|
17
|
+
end
|
12
18
|
end
|
13
19
|
end
|
14
20
|
end
|
data/lib/contact-data/fetcher.rb
CHANGED
@@ -50,7 +50,18 @@ module ContactData
|
|
50
50
|
end
|
51
51
|
|
52
52
|
def fetch(url, method = :get, options = {})
|
53
|
+
args = args_from url, method, options
|
53
54
|
logger.info { "Using #{method.to_s.upcase} for #{url}" }
|
55
|
+
logger.info { "Args: #{args}" }
|
56
|
+
|
57
|
+
begin
|
58
|
+
RestClient::Request.new(args).execute
|
59
|
+
rescue RestClient::Exception => e
|
60
|
+
raise ContactData::FetchError, "#{e.message} when trying to #{method.to_s.upcase} url: #{url}", e.backtrace
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
def args_from(url, method, options)
|
54
65
|
args = { url: url, method: method }
|
55
66
|
args[:headers] = { params: options[:params] } if options.key? :params
|
56
67
|
|
@@ -62,11 +73,7 @@ module ContactData
|
|
62
73
|
:ssl_verify_callback_warnings, :ssl_version, :ssl_ciphers
|
63
74
|
].each { |key| args[key] = options[key] if options.key? key }
|
64
75
|
|
65
|
-
|
66
|
-
RestClient::Request.new(args).execute
|
67
|
-
rescue RestClient::Exception => e
|
68
|
-
raise ContactData::FetchError, "#{e.message} when trying to #{method.to_s.upcase} url: #{url}", e.backtrace
|
69
|
-
end
|
76
|
+
args
|
70
77
|
end
|
71
78
|
|
72
79
|
def parse(json)
|
data/lib/contact-data/version.rb
CHANGED
@@ -3,7 +3,9 @@ require 'spec_helper'
|
|
3
3
|
require 'contact-data'
|
4
4
|
|
5
5
|
describe ContactData::Contact do
|
6
|
-
let(:name)
|
6
|
+
let(:name) { 'Derek Jones III' }
|
7
|
+
let(:source) { 'angel_list' }
|
8
|
+
let(:slug) { 'derek-jones' }
|
7
9
|
|
8
10
|
it 'searches for a contact by name' do
|
9
11
|
VCR.use_cassette('name_search') do
|
@@ -13,4 +15,13 @@ describe ContactData::Contact do
|
|
13
15
|
expect(result[:identities].count).to eq(15)
|
14
16
|
end
|
15
17
|
end
|
18
|
+
|
19
|
+
it 'retrieves a contact from a source' do
|
20
|
+
VCR.use_cassette('source_slug') do
|
21
|
+
result = ContactData::Contact.from(source, slug, verbose: true)
|
22
|
+
expect(result).to be_a(Hash)
|
23
|
+
expect(result[:slug]).to eq(slug)
|
24
|
+
expect(result[:data].first[:source_identities].count).to eq(5)
|
25
|
+
end
|
26
|
+
end
|
16
27
|
end
|
data/spec/fetcher_spec.rb
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
require 'spec_helper'
|
3
3
|
require 'contact-data'
|
4
|
-
require 'byebug'
|
5
4
|
|
6
5
|
describe ContactData::Fetcher do
|
7
6
|
let(:method) { 'method' }
|
7
|
+
let(:url) { ContactData::Fetcher::URL }
|
8
8
|
|
9
9
|
it 'adds diagnostic information to a RestClient exception' do
|
10
10
|
RestClient::Request.any_instance.stub(:execute).and_raise RestClient::InternalServerError.new(nil, 500)
|
@@ -15,4 +15,19 @@ describe ContactData::Fetcher do
|
|
15
15
|
expect(e.message).to eq(message)
|
16
16
|
}
|
17
17
|
end
|
18
|
+
|
19
|
+
it 'forms the expected URL' do
|
20
|
+
[
|
21
|
+
{ method: method, options: {}, url: "#{url}/method.json" },
|
22
|
+
{ method: :method, options: {}, url: "#{url}/api/v2/method.json" },
|
23
|
+
{ method: :method, options: { base: 'base' }, url: "#{url}/api/v2/base/method.json" }
|
24
|
+
].each do |url_data|
|
25
|
+
puts "#{url_data[:method].class}\t#{url_data[:options]}"
|
26
|
+
expect(
|
27
|
+
ContactData::Fetcher.__send__(
|
28
|
+
:get_url_from, url_data[:method], url_data[:options]
|
29
|
+
)
|
30
|
+
).to eq(url_data[:url])
|
31
|
+
end
|
32
|
+
end
|
18
33
|
end
|
@@ -53,6 +53,6 @@ http_interactions:
|
|
53
53
|
Jones","identity_slug":"dxj00029","service":"fsa","url":"http://www.fsa.gov.uk/register//indivbasicdetails.do?sid=282759"},{"contact_type":"person","description":"Derek
|
54
54
|
Jones","identity_slug":"dxj01164","service":"fsa","url":"http://www.fsa.gov.uk/register//indivbasicdetails.do?sid=490042"},{"contact_type":"person","description":"Derek
|
55
55
|
Jones","identity_slug":"dxj01321","service":"fsa","url":"http://www.fsa.gov.uk/register//indivbasicdetails.do?sid=729794"},{"contact_type":"person","description":null,"identity_slug":"pub/derek-jones/15/b2/55b","service":"linked_in","url":"http://www.linkedin.com/pub/derek-jones/15/b2/55b"},{"contact_type":"person","description":null,"identity_slug":"http://www.dereknakano.com","service":"url","url":"http://www.dereknakano.com"}],"relationships":[],"links":[]}'
|
56
|
-
http_version:
|
56
|
+
http_version:
|
57
57
|
recorded_at: Tue, 11 Nov 2014 16:28:14 GMT
|
58
58
|
recorded_with: VCR 2.9.3
|
@@ -0,0 +1,49 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: get
|
5
|
+
uri: http://public.xenapto.com/api/v2/contacts/from.json?slug=derek-jones&source=angel_list
|
6
|
+
body:
|
7
|
+
encoding: US-ASCII
|
8
|
+
string: ''
|
9
|
+
headers:
|
10
|
+
Accept:
|
11
|
+
- "*/*; q=0.5, application/xml"
|
12
|
+
Accept-Encoding:
|
13
|
+
- gzip, deflate
|
14
|
+
User-Agent:
|
15
|
+
- Ruby
|
16
|
+
response:
|
17
|
+
status:
|
18
|
+
code: 200
|
19
|
+
message: OK
|
20
|
+
headers:
|
21
|
+
Date:
|
22
|
+
- Fri, 06 Feb 2015 17:38:54 GMT
|
23
|
+
Status:
|
24
|
+
- 200 OK
|
25
|
+
Connection:
|
26
|
+
- close
|
27
|
+
Content-Type:
|
28
|
+
- application/json; charset=utf-8
|
29
|
+
Content-Length:
|
30
|
+
- '1184'
|
31
|
+
X-Ua-Compatible:
|
32
|
+
- IE=Edge,chrome=1
|
33
|
+
Etag:
|
34
|
+
- '"f242c0a293365c9aaaa79c1754b8d7ea"'
|
35
|
+
Cache-Control:
|
36
|
+
- max-age=0, private, must-revalidate
|
37
|
+
X-Request-Id:
|
38
|
+
- 8b6f60e98e1bd645ee159f7a3a2ad056
|
39
|
+
X-Runtime:
|
40
|
+
- '0.232381'
|
41
|
+
X-Rack-Cache:
|
42
|
+
- miss
|
43
|
+
body:
|
44
|
+
encoding: UTF-8
|
45
|
+
string: '{"version":"v2","source":"angel_list","slug":"derek-jones","data":[{"api_link":"/users/165075","canonical_slug":"derek-jones","contact_type":"person","description":null,"last_fetched":"2015-01-30T20:05:46Z","name":"Derek
|
46
|
+
Thomas Edward Jones","page_link":"/derek-jones","source_created_at":null,"source_id":165075,"source_namespace":"users","source_slug":"derek-jones","source_updated_at":null,"website":null,"source_links":[],"source_funding_rounds":[],"source_relationships":[],"source_identities":[{"description":null,"service":"angel_list","slug":"derek-jones","url":"https://angel.co/derek-jones"},{"description":null,"service":"avatar","slug":"https://d1qb2nb5cznatu.cloudfront.net/users/165075-medium_jpg?1405505118","url":"https://d1qb2nb5cznatu.cloudfront.net/users/165075-medium_jpg?1405505118"},{"description":null,"service":"linked_in","slug":"pub/derek-jones/15/b2/55b","url":"http://www.linkedin.com/pub/derek-jones/15/b2/55b"},{"description":null,"service":"domain","slug":"dereknakano.com","url":"http://www.dereknakano.com"},{"description":null,"service":"url","slug":"http://www.dereknakano.com","url":"http://www.dereknakano.com"}],"counterparty_relationships":[]}]}'
|
47
|
+
http_version:
|
48
|
+
recorded_at: Fri, 06 Feb 2015 17:38:54 GMT
|
49
|
+
recorded_with: VCR 2.9.3
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: contact-data
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Xenapto
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2015-02-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rest-client
|
@@ -100,20 +100,14 @@ dependencies:
|
|
100
100
|
requirements:
|
101
101
|
- - "~>"
|
102
102
|
- !ruby/object:Gem::Version
|
103
|
-
version: '0.
|
104
|
-
- - ">="
|
105
|
-
- !ruby/object:Gem::Version
|
106
|
-
version: 0.7.1
|
103
|
+
version: '0.9'
|
107
104
|
type: :development
|
108
105
|
prerelease: false
|
109
106
|
version_requirements: !ruby/object:Gem::Requirement
|
110
107
|
requirements:
|
111
108
|
- - "~>"
|
112
109
|
- !ruby/object:Gem::Version
|
113
|
-
version: '0.
|
114
|
-
- - ">="
|
115
|
-
- !ruby/object:Gem::Version
|
116
|
-
version: 0.7.1
|
110
|
+
version: '0.9'
|
117
111
|
- !ruby/object:Gem::Dependency
|
118
112
|
name: coveralls
|
119
113
|
requirement: !ruby/object:Gem::Requirement
|
@@ -184,7 +178,6 @@ files:
|
|
184
178
|
- ".ruby-gemset"
|
185
179
|
- ".ruby-version"
|
186
180
|
- Gemfile
|
187
|
-
- Gemfile.lock
|
188
181
|
- LICENSE
|
189
182
|
- README.md
|
190
183
|
- Rakefile
|
@@ -207,6 +200,7 @@ files:
|
|
207
200
|
- spec/support/cassettes/links_info_search.yml
|
208
201
|
- spec/support/cassettes/links_latest.yml
|
209
202
|
- spec/support/cassettes/name_search.yml
|
203
|
+
- spec/support/cassettes/source_slug.yml
|
210
204
|
- spec/support/vcr_setup.rb
|
211
205
|
homepage: https://github.com/Xenapto/contact-data
|
212
206
|
licenses:
|
@@ -228,7 +222,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
228
222
|
version: '0'
|
229
223
|
requirements: []
|
230
224
|
rubyforge_project:
|
231
|
-
rubygems_version: 2.
|
225
|
+
rubygems_version: 2.4.4
|
232
226
|
signing_key:
|
233
227
|
specification_version: 4
|
234
228
|
summary: 'Example: ContactData.search(''John Smith III'')'
|
@@ -244,4 +238,5 @@ test_files:
|
|
244
238
|
- spec/support/cassettes/links_info_search.yml
|
245
239
|
- spec/support/cassettes/links_latest.yml
|
246
240
|
- spec/support/cassettes/name_search.yml
|
241
|
+
- spec/support/cassettes/source_slug.yml
|
247
242
|
- spec/support/vcr_setup.rb
|
data/Gemfile.lock
DELETED
@@ -1,73 +0,0 @@
|
|
1
|
-
PATH
|
2
|
-
remote: .
|
3
|
-
specs:
|
4
|
-
contact-data (0.2.1)
|
5
|
-
addressable (~> 2.3)
|
6
|
-
rest-client (~> 1)
|
7
|
-
|
8
|
-
GEM
|
9
|
-
remote: https://rubygems.org/
|
10
|
-
specs:
|
11
|
-
addressable (2.3.6)
|
12
|
-
byebug (3.5.1)
|
13
|
-
columnize (~> 0.8)
|
14
|
-
debugger-linecache (~> 1.2)
|
15
|
-
slop (~> 3.6)
|
16
|
-
columnize (0.8.9)
|
17
|
-
coveralls (0.7.1)
|
18
|
-
multi_json (~> 1.3)
|
19
|
-
rest-client
|
20
|
-
simplecov (>= 0.7)
|
21
|
-
term-ansicolor
|
22
|
-
thor
|
23
|
-
crack (0.4.2)
|
24
|
-
safe_yaml (~> 1.0.0)
|
25
|
-
debugger-linecache (1.2.0)
|
26
|
-
diff-lcs (1.2.5)
|
27
|
-
docile (1.1.5)
|
28
|
-
gem-release (0.7.3)
|
29
|
-
mime-types (2.4.3)
|
30
|
-
multi_json (1.10.1)
|
31
|
-
netrc (0.8.0)
|
32
|
-
rake (10.3.2)
|
33
|
-
rest-client (1.7.2)
|
34
|
-
mime-types (>= 1.16, < 3.0)
|
35
|
-
netrc (~> 0.7)
|
36
|
-
rspec (2.99.0)
|
37
|
-
rspec-core (~> 2.99.0)
|
38
|
-
rspec-expectations (~> 2.99.0)
|
39
|
-
rspec-mocks (~> 2.99.0)
|
40
|
-
rspec-core (2.99.2)
|
41
|
-
rspec-expectations (2.99.2)
|
42
|
-
diff-lcs (>= 1.1.3, < 2.0)
|
43
|
-
rspec-mocks (2.99.2)
|
44
|
-
safe_yaml (1.0.4)
|
45
|
-
simplecov (0.9.1)
|
46
|
-
docile (~> 1.1.0)
|
47
|
-
multi_json (~> 1.0)
|
48
|
-
simplecov-html (~> 0.8.0)
|
49
|
-
simplecov-html (0.8.0)
|
50
|
-
slop (3.6.0)
|
51
|
-
term-ansicolor (1.3.0)
|
52
|
-
tins (~> 1.0)
|
53
|
-
thor (0.19.1)
|
54
|
-
tins (1.3.3)
|
55
|
-
vcr (2.9.3)
|
56
|
-
webmock (1.20.4)
|
57
|
-
addressable (>= 2.3.6)
|
58
|
-
crack (>= 0.3.2)
|
59
|
-
|
60
|
-
PLATFORMS
|
61
|
-
ruby
|
62
|
-
|
63
|
-
DEPENDENCIES
|
64
|
-
bundler (~> 1)
|
65
|
-
byebug (~> 3)
|
66
|
-
contact-data!
|
67
|
-
coveralls (~> 0)
|
68
|
-
gem-release (~> 0)
|
69
|
-
rake (~> 10)
|
70
|
-
rspec (~> 2)
|
71
|
-
simplecov (~> 0.7, >= 0.7.1)
|
72
|
-
vcr (~> 2)
|
73
|
-
webmock (~> 1)
|