whos_got_dirt 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +0 -3
- data/README.md +1 -1
- data/Rakefile +0 -53
- data/lib/whos_got_dirt/requests/entity/poderopedia.rb +4 -4
- data/lib/whos_got_dirt/response.rb +11 -0
- data/lib/whos_got_dirt/responses/entity/little_sis.rb +1 -1
- data/lib/whos_got_dirt/responses/entity/open_corporates.rb +7 -6
- data/lib/whos_got_dirt/responses/entity/open_duka.rb +8 -0
- data/lib/whos_got_dirt/responses/entity/poderopedia.rb +1 -1
- data/lib/whos_got_dirt/responses/helpers/little_sis.rb +19 -0
- data/lib/whos_got_dirt/responses/list/little_sis.rb +2 -2
- data/lib/whos_got_dirt/responses/list/open_corporates.rb +2 -2
- data/lib/whos_got_dirt/responses/relation/open_oil.rb +13 -3
- data/lib/whos_got_dirt/result.rb +2 -2
- data/lib/whos_got_dirt/validator.rb +1 -1
- data/lib/whos_got_dirt/version.rb +1 -1
- data/schemas/schema.json +388 -0
- data/spec/cassettes/little_sis_entity_error.yml +57 -0
- data/spec/cassettes/little_sis_list_error.yml +57 -0
- data/spec/cassettes/open_duka_entity_error.yml +37 -0
- data/spec/response_spec.rb +20 -10
- data/spec/responses/entity/little_sis_spec.rb +35 -17
- data/spec/responses/entity/open_duka_spec.rb +31 -13
- data/spec/responses/list/little_sis_spec.rb +35 -17
- data/spec/result_spec.rb +6 -6
- data/spec/validator_spec.rb +5 -5
- data/whos_got_dirt.gemspec +2 -1
- metadata +24 -4
- data/schemas/popolo.json +0 -1619
@@ -0,0 +1,57 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: get
|
5
|
+
uri: https://api.littlesis.org/entities.xml?q=bar
|
6
|
+
body:
|
7
|
+
encoding: US-ASCII
|
8
|
+
string: ''
|
9
|
+
headers:
|
10
|
+
User-Agent:
|
11
|
+
- Faraday v0.9.1
|
12
|
+
response:
|
13
|
+
status:
|
14
|
+
code: 401
|
15
|
+
message:
|
16
|
+
headers:
|
17
|
+
server:
|
18
|
+
- cloudflare-nginx
|
19
|
+
date:
|
20
|
+
- Sun, 10 Jan 2016 23:54:18 GMT
|
21
|
+
content-type:
|
22
|
+
- text/html; charset=utf-8
|
23
|
+
transfer-encoding:
|
24
|
+
- chunked
|
25
|
+
connection:
|
26
|
+
- close
|
27
|
+
set-cookie:
|
28
|
+
- __cfduid=d0a1f180fbcab07f10a20a0e51d9152601452470058; expires=Mon, 09-Jan-17
|
29
|
+
23:54:18 GMT; path=/; domain=.littlesis.org; HttpOnly, symfony=rjsiompvljpg9goqudp16ina83;
|
30
|
+
path=/
|
31
|
+
x-powered-by:
|
32
|
+
- PHP/5.5.9-1ubuntu4.6
|
33
|
+
expires:
|
34
|
+
- Thu, 19 Nov 1981 08:52:00 GMT
|
35
|
+
cache-control:
|
36
|
+
- no-store, no-cache, must-revalidate, post-check=0, pre-check=0
|
37
|
+
pragma:
|
38
|
+
- no-cache
|
39
|
+
www-authenticate:
|
40
|
+
- Your request must include a query parameter named "_key" with a valid API
|
41
|
+
key value. To obtain an API key, visit http://api.littlesis.org/register
|
42
|
+
vary:
|
43
|
+
- Accept-Encoding
|
44
|
+
access-control-allow-origin:
|
45
|
+
- "*"
|
46
|
+
cf-ray:
|
47
|
+
- 262c4e69e5463fa7-YUL
|
48
|
+
body:
|
49
|
+
encoding: UTF-8
|
50
|
+
string: |-
|
51
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
52
|
+
<Response>
|
53
|
+
Your request must include a query parameter named "_key" with a valid API key value. To obtain an API key, visit http://api.littlesis.org/register.
|
54
|
+
</Response>
|
55
|
+
http_version:
|
56
|
+
recorded_at: Sun, 10 Jan 2016 23:54:18 GMT
|
57
|
+
recorded_with: VCR 3.0.1
|
@@ -0,0 +1,57 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: get
|
5
|
+
uri: https://api.littlesis.org/lists.xml?q=united
|
6
|
+
body:
|
7
|
+
encoding: US-ASCII
|
8
|
+
string: ''
|
9
|
+
headers:
|
10
|
+
User-Agent:
|
11
|
+
- Faraday v0.9.1
|
12
|
+
response:
|
13
|
+
status:
|
14
|
+
code: 401
|
15
|
+
message:
|
16
|
+
headers:
|
17
|
+
server:
|
18
|
+
- cloudflare-nginx
|
19
|
+
date:
|
20
|
+
- Sun, 10 Jan 2016 23:54:54 GMT
|
21
|
+
content-type:
|
22
|
+
- text/html; charset=utf-8
|
23
|
+
transfer-encoding:
|
24
|
+
- chunked
|
25
|
+
connection:
|
26
|
+
- close
|
27
|
+
set-cookie:
|
28
|
+
- __cfduid=df94c524808fd39878295eeaf1d4bd7c81452470094; expires=Mon, 09-Jan-17
|
29
|
+
23:54:54 GMT; path=/; domain=.littlesis.org; HttpOnly, symfony=q9culrvo85c6qrk56or8vo0eq3;
|
30
|
+
path=/
|
31
|
+
x-powered-by:
|
32
|
+
- PHP/5.5.9-1ubuntu4.6
|
33
|
+
expires:
|
34
|
+
- Thu, 19 Nov 1981 08:52:00 GMT
|
35
|
+
cache-control:
|
36
|
+
- no-store, no-cache, must-revalidate, post-check=0, pre-check=0
|
37
|
+
pragma:
|
38
|
+
- no-cache
|
39
|
+
www-authenticate:
|
40
|
+
- Your request must include a query parameter named "_key" with a valid API
|
41
|
+
key value. To obtain an API key, visit http://api.littlesis.org/register
|
42
|
+
vary:
|
43
|
+
- Accept-Encoding
|
44
|
+
access-control-allow-origin:
|
45
|
+
- "*"
|
46
|
+
cf-ray:
|
47
|
+
- 262c4f4b1d493fa1-YUL
|
48
|
+
body:
|
49
|
+
encoding: UTF-8
|
50
|
+
string: |-
|
51
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
52
|
+
<Response>
|
53
|
+
Your request must include a query parameter named "_key" with a valid API key value. To obtain an API key, visit http://api.littlesis.org/register.
|
54
|
+
</Response>
|
55
|
+
http_version:
|
56
|
+
recorded_at: Sun, 10 Jan 2016 23:54:54 GMT
|
57
|
+
recorded_with: VCR 3.0.1
|
@@ -0,0 +1,37 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: get
|
5
|
+
uri: http://www.openduka.org/index.php/api/search?term=the
|
6
|
+
body:
|
7
|
+
encoding: US-ASCII
|
8
|
+
string: ''
|
9
|
+
headers:
|
10
|
+
User-Agent:
|
11
|
+
- Faraday v0.9.1
|
12
|
+
response:
|
13
|
+
status:
|
14
|
+
code: 200
|
15
|
+
message:
|
16
|
+
headers:
|
17
|
+
date:
|
18
|
+
- Mon, 11 Jan 2016 01:50:10 GMT
|
19
|
+
server:
|
20
|
+
- Apache
|
21
|
+
set-cookie:
|
22
|
+
- ci_session=a%3A5%3A%7Bs%3A10%3A%22session_id%22%3Bs%3A32%3A%225ee5f19c568590f29ec547cf0cbb15fc%22%3Bs%3A10%3A%22ip_address%22%3Bs%3A14%3A%22198.48.204.118%22%3Bs%3A10%3A%22user_agent%22%3Bs%3A14%3A%22Faraday+v0.9.1%22%3Bs%3A13%3A%22last_activity%22%3Bi%3A1452477010%3Bs%3A9%3A%22user_data%22%3Bs%3A0%3A%22%22%3B%7Da4e6d71e7310fa2b434a1efda6aa9267;
|
23
|
+
expires=Mon, 11-Jan-2016 03:50:10 GMT; Max-Age=7200; path=/
|
24
|
+
vary:
|
25
|
+
- Accept-Encoding
|
26
|
+
content-length:
|
27
|
+
- '62'
|
28
|
+
connection:
|
29
|
+
- close
|
30
|
+
content-type:
|
31
|
+
- text/html
|
32
|
+
body:
|
33
|
+
encoding: ASCII-8BIT
|
34
|
+
string: '{"error":"missing key and or search term"}'
|
35
|
+
http_version:
|
36
|
+
recorded_at: Mon, 11 Jan 2016 01:50:11 GMT
|
37
|
+
recorded_with: VCR 3.0.1
|
data/spec/response_spec.rb
CHANGED
@@ -11,9 +11,9 @@ module WhosGotDirt
|
|
11
11
|
end
|
12
12
|
|
13
13
|
@template = {
|
14
|
-
'@type' => '
|
15
|
-
'id' => 123,
|
14
|
+
'@type' => 'Entity',
|
16
15
|
'name' => '/fn',
|
16
|
+
'birth_date' => 2015,
|
17
17
|
'identifiers' => [{
|
18
18
|
'identifier' => '/id',
|
19
19
|
'scheme' => 'ACME',
|
@@ -26,16 +26,20 @@ module WhosGotDirt
|
|
26
26
|
|
27
27
|
def to_a
|
28
28
|
parsed_body.map do |data|
|
29
|
-
Result.new('
|
29
|
+
Result.new('Entity', renderer.result(data), self).finalize!
|
30
30
|
end
|
31
31
|
end
|
32
32
|
end
|
33
33
|
end
|
34
34
|
|
35
|
+
let :body do
|
36
|
+
'[{"fn":"John Smith","id":"john-smith"},{"fn":"John Aaron Smith","id":"john-aaron-smith"}]'
|
37
|
+
end
|
38
|
+
|
35
39
|
let :response do
|
36
40
|
env = Faraday::Env.new
|
37
41
|
env.url = 'https://api.example.com/endpoint?name~=John+Smith'
|
38
|
-
env.body =
|
42
|
+
env.body = body
|
39
43
|
Faraday::Response.new(env)
|
40
44
|
end
|
41
45
|
|
@@ -45,9 +49,9 @@ module WhosGotDirt
|
|
45
49
|
|
46
50
|
let :template do
|
47
51
|
{
|
48
|
-
'@type' => '
|
49
|
-
'id' => 123,
|
52
|
+
'@type' => 'Entity',
|
50
53
|
'name' => '/fn',
|
54
|
+
'birth_date' => 2015,
|
51
55
|
'identifiers' => [{
|
52
56
|
'identifier' => '/id',
|
53
57
|
'scheme' => 'ACME',
|
@@ -89,9 +93,9 @@ module WhosGotDirt
|
|
89
93
|
describe '#to_a' do
|
90
94
|
it 'should return the results' do
|
91
95
|
expect(instance.to_a).to eq([{
|
92
|
-
'@type' => '
|
93
|
-
'id' => '123',
|
96
|
+
'@type' => 'Entity',
|
94
97
|
'name' => 'John Smith',
|
98
|
+
'birth_date' => '2015',
|
95
99
|
'identifiers' => [{
|
96
100
|
'identifier' => 'john-smith',
|
97
101
|
'scheme' => 'ACME',
|
@@ -101,9 +105,9 @@ module WhosGotDirt
|
|
101
105
|
'note' => 'MyResponse',
|
102
106
|
}],
|
103
107
|
}, {
|
104
|
-
'@type' => '
|
105
|
-
'id' => '123',
|
108
|
+
'@type' => 'Entity',
|
106
109
|
'name' => 'John Aaron Smith',
|
110
|
+
'birth_date' => '2015',
|
107
111
|
'identifiers' => [{
|
108
112
|
'identifier' => 'john-aaron-smith',
|
109
113
|
'scheme' => 'ACME',
|
@@ -115,5 +119,11 @@ module WhosGotDirt
|
|
115
119
|
}])
|
116
120
|
end
|
117
121
|
end
|
122
|
+
|
123
|
+
describe '#error_message' do
|
124
|
+
it 'should return the parsed response body' do
|
125
|
+
expect(instance.error_message).to eq(body)
|
126
|
+
end
|
127
|
+
end
|
118
128
|
end
|
119
129
|
end
|
@@ -1,30 +1,48 @@
|
|
1
1
|
require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
|
2
2
|
|
3
3
|
module WhosGotDirt::Responses::Entity
|
4
|
-
RSpec.describe LittleSis
|
5
|
-
|
6
|
-
|
7
|
-
|
4
|
+
RSpec.describe LittleSis do
|
5
|
+
context 'when successful', vcr: {cassette_name: 'little_sis_entity'} do
|
6
|
+
let :response do
|
7
|
+
Faraday.get("https://api.littlesis.org/entities.xml?q=bar&_key=#{ENV['LITTLE_SIS_API_KEY']}")
|
8
|
+
end
|
8
9
|
|
9
|
-
|
10
|
-
|
11
|
-
|
10
|
+
let :instance do
|
11
|
+
LittleSis.new(response)
|
12
|
+
end
|
12
13
|
|
13
|
-
|
14
|
-
|
15
|
-
|
14
|
+
describe '#to_a' do
|
15
|
+
it 'should return the results' do
|
16
|
+
expect{instance.to_a}.to_not raise_error
|
17
|
+
end
|
16
18
|
end
|
17
|
-
end
|
18
19
|
|
19
|
-
|
20
|
-
|
21
|
-
|
20
|
+
describe '#count' do
|
21
|
+
it 'should return the number of results' do
|
22
|
+
expect(instance.count).to be > 1_000
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
describe '#page' do
|
27
|
+
it 'should return the current page number' do
|
28
|
+
expect(instance.page).to eq(1)
|
29
|
+
end
|
22
30
|
end
|
23
31
|
end
|
24
32
|
|
25
|
-
|
26
|
-
|
27
|
-
|
33
|
+
context 'when unsuccessful', vcr: {cassette_name: 'little_sis_entity_error'} do
|
34
|
+
let :response do
|
35
|
+
Faraday.get("https://api.littlesis.org/entities.xml?q=bar")
|
36
|
+
end
|
37
|
+
|
38
|
+
let :instance do
|
39
|
+
LittleSis.new(response)
|
40
|
+
end
|
41
|
+
|
42
|
+
describe '#error_message' do
|
43
|
+
it 'should return the error message' do
|
44
|
+
expect(instance.error_message).to eq('Your request must include a query parameter named "_key" with a valid API key value. To obtain an API key, visit http://api.littlesis.org/register.')
|
45
|
+
end
|
28
46
|
end
|
29
47
|
end
|
30
48
|
end
|
@@ -1,24 +1,42 @@
|
|
1
1
|
require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
|
2
2
|
|
3
3
|
module WhosGotDirt::Responses::Entity
|
4
|
-
RSpec.describe OpenDuka
|
5
|
-
|
6
|
-
|
7
|
-
|
4
|
+
RSpec.describe OpenDuka do
|
5
|
+
context 'when successful', vcr: {cassette_name: 'open_duka_entity'} do
|
6
|
+
let :response do
|
7
|
+
Faraday.get("http://www.openduka.org/index.php/api/search?term=the&key=#{ENV['OPEN_DUKA_API_KEY']}")
|
8
|
+
end
|
8
9
|
|
9
|
-
|
10
|
-
|
11
|
-
|
10
|
+
let :instance do
|
11
|
+
OpenDuka.new(response)
|
12
|
+
end
|
13
|
+
|
14
|
+
describe '#to_a' do
|
15
|
+
it 'should return the results' do
|
16
|
+
expect{instance.to_a}.to_not raise_error
|
17
|
+
end
|
18
|
+
end
|
12
19
|
|
13
|
-
|
14
|
-
|
15
|
-
|
20
|
+
describe '#count' do
|
21
|
+
it 'should return the number of results' do
|
22
|
+
expect(instance.count).to be > 1_000
|
23
|
+
end
|
16
24
|
end
|
17
25
|
end
|
18
26
|
|
19
|
-
|
20
|
-
|
21
|
-
|
27
|
+
context 'when unsuccessful', vcr: {cassette_name: 'open_duka_entity_error'} do
|
28
|
+
let :response do
|
29
|
+
Faraday.get("http://www.openduka.org/index.php/api/search?term=the")
|
30
|
+
end
|
31
|
+
|
32
|
+
let :instance do
|
33
|
+
OpenDuka.new(response)
|
34
|
+
end
|
35
|
+
|
36
|
+
describe '#error_message' do
|
37
|
+
it 'should return the error message' do
|
38
|
+
expect(instance.error_message).to eq('missing key and or search term')
|
39
|
+
end
|
22
40
|
end
|
23
41
|
end
|
24
42
|
end
|
@@ -1,30 +1,48 @@
|
|
1
1
|
require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
|
2
2
|
|
3
3
|
module WhosGotDirt::Responses::List
|
4
|
-
RSpec.describe LittleSis
|
5
|
-
|
6
|
-
|
7
|
-
|
4
|
+
RSpec.describe LittleSis do
|
5
|
+
context 'when successful', vcr: {cassette_name: 'little_sis_list'} do
|
6
|
+
let :response do
|
7
|
+
Faraday.get("https://api.littlesis.org/lists.xml?q=united&_key=#{ENV['LITTLE_SIS_API_KEY']}")
|
8
|
+
end
|
8
9
|
|
9
|
-
|
10
|
-
|
11
|
-
|
10
|
+
let :instance do
|
11
|
+
LittleSis.new(response)
|
12
|
+
end
|
12
13
|
|
13
|
-
|
14
|
-
|
15
|
-
|
14
|
+
describe '#to_a' do
|
15
|
+
it 'should return the results' do
|
16
|
+
expect{instance.to_a}.to_not raise_error
|
17
|
+
end
|
16
18
|
end
|
17
|
-
end
|
18
19
|
|
19
|
-
|
20
|
-
|
21
|
-
|
20
|
+
describe '#count' do
|
21
|
+
it 'should return the number of results' do
|
22
|
+
expect(instance.count).to be > 10
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
describe '#page' do
|
27
|
+
it 'should return the current page number' do
|
28
|
+
expect(instance.page).to eq(1)
|
29
|
+
end
|
22
30
|
end
|
23
31
|
end
|
24
32
|
|
25
|
-
|
26
|
-
|
27
|
-
|
33
|
+
context 'when unsuccessful', vcr: {cassette_name: 'little_sis_list_error'} do
|
34
|
+
let :response do
|
35
|
+
Faraday.get("https://api.littlesis.org/lists.xml?q=united")
|
36
|
+
end
|
37
|
+
|
38
|
+
let :instance do
|
39
|
+
LittleSis.new(response)
|
40
|
+
end
|
41
|
+
|
42
|
+
describe '#error_message' do
|
43
|
+
it 'should return the error message' do
|
44
|
+
expect(instance.error_message).to eq('Your request must include a query parameter named "_key" with a valid API key value. To obtain an API key, visit http://api.littlesis.org/register.')
|
45
|
+
end
|
28
46
|
end
|
29
47
|
end
|
30
48
|
end
|
data/spec/result_spec.rb
CHANGED
@@ -4,8 +4,8 @@ module WhosGotDirt
|
|
4
4
|
RSpec.describe Result do
|
5
5
|
let :result do
|
6
6
|
{
|
7
|
-
'id' => 123,
|
8
7
|
'name' => 'John Smith',
|
8
|
+
'birth_date' => 2015,
|
9
9
|
'identifiers' => [{
|
10
10
|
'scheme' => 'ACME',
|
11
11
|
}, {
|
@@ -24,12 +24,12 @@ module WhosGotDirt
|
|
24
24
|
end
|
25
25
|
|
26
26
|
let :instance do
|
27
|
-
Result.new('
|
27
|
+
Result.new('Entity', result, response)
|
28
28
|
end
|
29
29
|
|
30
30
|
describe '#initialize' do
|
31
31
|
it 'should set the type, result and response' do
|
32
|
-
expect(instance.type).to eq('
|
32
|
+
expect(instance.type).to eq('Entity')
|
33
33
|
expect(instance.result).to eq(result)
|
34
34
|
expect(instance.response).to eq(response)
|
35
35
|
end
|
@@ -38,8 +38,8 @@ module WhosGotDirt
|
|
38
38
|
describe '#add_source!' do
|
39
39
|
it 'should add a source to a result' do
|
40
40
|
expect(instance.add_source!).to eq({
|
41
|
-
'id' => 123,
|
42
41
|
'name' => 'John Smith',
|
42
|
+
'birth_date' => 2015,
|
43
43
|
'identifiers' => [{
|
44
44
|
'scheme' => 'ACME',
|
45
45
|
}, {
|
@@ -58,8 +58,8 @@ module WhosGotDirt
|
|
58
58
|
describe 'validate!' do
|
59
59
|
it 'should validate the result' do
|
60
60
|
expect(instance.validate!).to eq({
|
61
|
-
'id' => '123',
|
62
61
|
'name' => 'John Smith',
|
62
|
+
'birth_date' => '2015',
|
63
63
|
'identifiers' => [{
|
64
64
|
'identifier' => 'john-smith',
|
65
65
|
}],
|
@@ -74,8 +74,8 @@ module WhosGotDirt
|
|
74
74
|
describe '#finalize!' do
|
75
75
|
it 'should finalize the result' do
|
76
76
|
expect(instance.finalize!).to eq({
|
77
|
-
'id' => '123',
|
78
77
|
'name' => 'John Smith',
|
78
|
+
'birth_date' => '2015',
|
79
79
|
'identifiers' => [{
|
80
80
|
'identifier' => 'john-smith',
|
81
81
|
}],
|