wikidata-client 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.rspec +2 -0
- data/.travis.yml +7 -0
- data/Gemfile +7 -0
- data/Gemfile.lock +69 -0
- data/LICENCE +21 -0
- data/README.md +180 -0
- data/Rakefile +5 -0
- data/config/mapping.yml +19 -0
- data/config/settings.yml +4 -0
- data/lib/wikidata.rb +39 -0
- data/lib/wikidata/client.rb +36 -0
- data/lib/wikidata/config.rb +23 -0
- data/lib/wikidata/entity.rb +83 -0
- data/lib/wikidata/item.rb +41 -0
- data/lib/wikidata/property.rb +29 -0
- data/lib/wikidata/property/base.rb +16 -0
- data/lib/wikidata/property/globe_coordinate.rb +13 -0
- data/lib/wikidata/property/string.rb +6 -0
- data/lib/wikidata/property/time.rb +66 -0
- data/lib/wikidata/property/url.rb +6 -0
- data/lib/wikidata/resource.rb +69 -0
- data/lib/wikidata/response.rb +31 -0
- data/lib/wikidata/search_response.rb +35 -0
- data/lib/wikidata/version.rb +3 -0
- data/spec/fixtures/vcr/Wikidata_Entity/properties/entities/should_allow_to_return_only_entities_ids_from_a_key.yml +160 -0
- data/spec/fixtures/vcr/Wikidata_Entity/properties/entities/should_allow_to_return_only_entities_ids_from_an_id.yml +160 -0
- data/spec/fixtures/vcr/Wikidata_Entity/properties/entities/should_return_entities_property_from_a_key_children_here_.yml +518 -0
- data/spec/fixtures/vcr/Wikidata_Entity/properties/entities/should_return_entities_property_from_an_id_P40_for_children_here_.yml +516 -0
- data/spec/fixtures/vcr/Wikidata_Entity/properties/properties/of_type_date/should_return_Time_from_a_a_key_date_of_birth_here_.yml +162 -0
- data/spec/fixtures/vcr/Wikidata_Entity/properties/properties/of_type_date/should_return_Time_from_a_property_id_P569_for_date_of_birth_here_.yml +162 -0
- data/spec/fixtures/vcr/Wikidata_Entity/properties/properties/of_type_globe_coordinate/should_return_GlobeCoordinate_from_a_key_coordinate_location_here_.yml +58 -0
- data/spec/fixtures/vcr/Wikidata_Entity/properties/properties/of_type_globe_coordinate/should_return_GlobeCoordinate_from_a_property_id_P625_for_coordinate_location_here_.yml +58 -0
- data/spec/fixtures/vcr/Wikidata_Entity/properties/properties/of_type_string/should_return_String_from_a_key_freebase_identifier_here_.yml +160 -0
- data/spec/fixtures/vcr/Wikidata_Entity/properties/properties/of_type_string/should_return_String_from_a_property_id_P646_for_freebase_identifier_here_.yml +160 -0
- data/spec/fixtures/vcr/Wikidata_Entity/properties/properties/of_type_url/should_return_Url_from_a_key_official_website_here_.yml +78 -0
- data/spec/fixtures/vcr/Wikidata_Entity/properties/properties/of_type_url/should_return_Url_from_a_property_id_P856_for_official_website_here_.yml +78 -0
- data/spec/fixtures/vcr/Wikidata_Entity/properties/should_return_aliases.yml +176 -0
- data/spec/fixtures/vcr/Wikidata_Entity/properties/should_return_descriptions.yml +178 -0
- data/spec/fixtures/vcr/Wikidata_Entity/properties/should_return_id.yml +176 -0
- data/spec/fixtures/vcr/Wikidata_Entity/properties/should_return_labels.yml +176 -0
- data/spec/fixtures/vcr/Wikidata_Entity/properties/should_return_sitelinks.yml +176 -0
- data/spec/fixtures/vcr/Wikidata_Entity/properties/should_return_url.yml +178 -0
- data/spec/fixtures/vcr/Wikidata_Item/_find_/should_find_by_id.yml +319 -0
- data/spec/fixtures/vcr/Wikidata_Item/_find_/should_find_by_ids.yml +441 -0
- data/spec/fixtures/vcr/Wikidata_Item/_find_/should_find_by_title.yml +319 -0
- data/spec/fixtures/vcr/Wikidata_Item/_find_/should_find_by_titles.yml +441 -0
- data/spec/fixtures/vcr/Wikidata_Item/_find_/should_return_nil_if_item_not_found.yml +58 -0
- data/spec/fixtures/vcr/Wikidata_Item/_search/should_fetch_all_all_items_of_the_collection.yml +656 -0
- data/spec/fixtures/vcr/Wikidata_Item/_search/should_return_a_response_with_an_empty_array_of_results_if_search_missing.yml +57 -0
- data/spec/fixtures/vcr/Wikidata_Item/_search/should_return_an_array_of_Wikidata_Item.yml +654 -0
- data/spec/fixtures/vcr/Wikidata_Item/_search/should_return_the_next_page_offset.yml +123 -0
- data/spec/fixtures/vcr/Wikidata_Item/_search/should_return_the_total_number_of_hits.yml +123 -0
- data/spec/spec_helper.rb +28 -0
- data/spec/wikidata/client_spec.rb +4 -0
- data/spec/wikidata/entity_spec.rb +139 -0
- data/spec/wikidata/item_spec.rb +64 -0
- data/spec/wikidata/property/time_spec.rb +61 -0
- data/spec/wikidata_spec.rb +20 -0
- data/wikidata-client.gemspec +27 -0
- metadata +262 -0
@@ -0,0 +1,123 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: get
|
5
|
+
uri: http://www.wikidata.org/w/api.php?action=query&format=json&list=search&srlimit=10&sroffset=0&srsearch=Michael%20Jackson
|
6
|
+
body:
|
7
|
+
encoding: US-ASCII
|
8
|
+
string: ''
|
9
|
+
headers:
|
10
|
+
User-Agent:
|
11
|
+
- Faraday v0.9.0
|
12
|
+
Expect:
|
13
|
+
- ''
|
14
|
+
response:
|
15
|
+
status:
|
16
|
+
code: 200
|
17
|
+
message: OK
|
18
|
+
headers:
|
19
|
+
Server:
|
20
|
+
- Apache
|
21
|
+
X-Content-Type-Options:
|
22
|
+
- nosniff
|
23
|
+
Cache-Control:
|
24
|
+
- private
|
25
|
+
X-Frame-Options:
|
26
|
+
- DENY
|
27
|
+
Content-Type:
|
28
|
+
- application/json; charset=utf-8
|
29
|
+
Vary:
|
30
|
+
- Accept-Encoding,X-Forwarded-Proto,X-Use-HHVM
|
31
|
+
X-Varnish:
|
32
|
+
- 1526867630, 3175927500, 2581305905
|
33
|
+
Via:
|
34
|
+
- 1.1 varnish, 1.1 varnish, 1.1 varnish
|
35
|
+
Transfer-Encoding:
|
36
|
+
- chunked
|
37
|
+
Date:
|
38
|
+
- Mon, 29 Sep 2014 09:07:30 GMT
|
39
|
+
Age:
|
40
|
+
- '0'
|
41
|
+
Connection:
|
42
|
+
- keep-alive
|
43
|
+
X-Cache:
|
44
|
+
- cp1065 miss (0), amssq52 miss (0), amssq59 frontend miss (0)
|
45
|
+
X-Analytics:
|
46
|
+
- php=zend
|
47
|
+
Set-Cookie:
|
48
|
+
- GeoIP=FR:Sainte-luce-sur-loire:47.2500:-1.5000:v4; Path=/; Domain=.wikidata.org
|
49
|
+
body:
|
50
|
+
encoding: ASCII-8BIT
|
51
|
+
string: '{"query-continue":{"search":{"sroffset":10}},"query":{"searchinfo":{"totalhits":416},"search":[{"ns":0,"title":"Q2831","snippet":"<span
|
52
|
+
class=\"searchmatch\">Michael</span> <span class=\"searchmatch\">Jackson</span>
|
53
|
+
<span class=\"searchmatch\">Michael</span> <span class=\"searchmatch\">Jackson</span>
|
54
|
+
<span class=\"searchmatch\">Michael</span> <span class=\"searchmatch\">Jackson</span>
|
55
|
+
<span class=\"searchmatch\">Michael</span> <span class=\"searchmatch\">Jackson</span>
|
56
|
+
<span class=\"searchmatch\">Michael</span> <span class=\"searchmatch\">Jackson</span>
|
57
|
+
<span class=\"searchmatch\">Michael</span> <span class=\"searchmatch\">Jackson</span>
|
58
|
+
<span class=\"searchmatch\">Michael</span> <span class=\"searchmatch\">Jackson</span>
|
59
|
+
\u121b\u12ed\u12ad\u120d \u1303\u12ad\u1230\u1295 <span class=\"searchmatch\">Michael</span>
|
60
|
+
<span class=\"searchmatch\">Jackson</span> \u0645\u0627\u064a\u0643\u0644
|
61
|
+
\u062c\u0627\u0643\u0633\u0648\u0646","size":8234,"wordcount":890,"timestamp":"2014-09-18T07:35:04Z"},{"ns":0,"title":"Q167877","snippet":"<span
|
62
|
+
class=\"searchmatch\">Michael</span> <span class=\"searchmatch\">Jackson</span>
|
63
|
+
<span class=\"searchmatch\">Michael</span> <span class=\"searchmatch\">Jackson</span>
|
64
|
+
<span class=\"searchmatch\">Michael</span> <span class=\"searchmatch\">Jackson</span>
|
65
|
+
\u041c\u0430\u0439\u043a\u044a\u043b \u0414\u0436\u0430\u043a\u0441\u044a\u043d
|
66
|
+
<span class=\"searchmatch\">Michael</span> <span class=\"searchmatch\">Jackson</span>
|
67
|
+
<span class=\"searchmatch\">Michael</span> <span class=\"searchmatch\">Jackson</span>
|
68
|
+
<span class=\"searchmatch\">Michael</span> <span class=\"searchmatch\">Jackson</span>
|
69
|
+
<span class=\"searchmatch\">Michael</span> <span class=\"searchmatch\">Jackson</span>
|
70
|
+
<span class=\"searchmatch\">Michael</span> <span class=\"searchmatch\">Jackson</span>
|
71
|
+
Michael","size":1216,"wordcount":132,"timestamp":"2014-09-14T15:28:24Z"},{"ns":0,"title":"Q507175","snippet":"<span
|
72
|
+
class=\"searchmatch\">Michael</span> <span class=\"searchmatch\">Jackson</span>
|
73
|
+
The Best of <span class=\"searchmatch\">Michael</span> <span class=\"searchmatch\">Jackson</span>
|
74
|
+
The Best of <span class=\"searchmatch\">Michael</span> <span class=\"searchmatch\">Jackson</span>
|
75
|
+
The Best of <span class=\"searchmatch\">Michael</span> <span class=\"searchmatch\">Jackson</span>
|
76
|
+
The Best of <span class=\"searchmatch\">Michael</span> <span class=\"searchmatch\">Jackson</span>
|
77
|
+
The Best of <span class=\"searchmatch\">Michael</span> Jackson","size":1503,"wordcount":233,"timestamp":"2014-06-04T10:27:12Z"},{"ns":0,"title":"Q956149","snippet":"\u0e2a\u0e1b\u0e35\u0e0a\u0e40\u0e25\u0e2a\u0e2a\u0e4c
|
78
|
+
<span class=\"searchmatch\">Michael</span> <span class=\"searchmatch\">Jackson</span>
|
79
|
+
Single von <span class=\"searchmatch\">Michael</span> <span class=\"searchmatch\">Jackson</span>
|
80
|
+
<span class=\"searchmatch\">Michael</span> <span class=\"searchmatch\">Jackson</span>
|
81
|
+
song chanson de <span class=\"searchmatch\">Michael</span> <span class=\"searchmatch\">Jackson</span>
|
82
|
+
Speechless (chanson de <span class=\"searchmatch\">Michael</span> <span class=\"searchmatch\">Jackson</span>)
|
83
|
+
Speechless","size":720,"wordcount":73,"timestamp":"2014-08-20T02:07:57Z"},{"ns":0,"title":"Q25158","snippet":"<span
|
84
|
+
class=\"searchmatch\">Michael</span> <span class=\"searchmatch\">Jackson</span>
|
85
|
+
del 2002 Album von <span class=\"searchmatch\">Michael</span> <span class=\"searchmatch\">Jackson</span>
|
86
|
+
<span class=\"searchmatch\">Michael</span> <span class=\"searchmatch\">Jackson</span>:
|
87
|
+
Love Songs Love Songs (<span class=\"searchmatch\">Michael</span> <span class=\"searchmatch\">Jackson</span>
|
88
|
+
album) Love Songs (album, <span class=\"searchmatch\">Michael</span> <span
|
89
|
+
class=\"searchmatch\">Jackson</span>)","size":368,"wordcount":55,"timestamp":"2014-05-09T22:51:53Z"},{"ns":0,"title":"Q1308224","snippet":"Experience
|
90
|
+
<span class=\"searchmatch\">Michael</span> <span class=\"searchmatch\">Jackson</span>:
|
91
|
+
The Experience <span class=\"searchmatch\">Michael</span> <span class=\"searchmatch\">Jackson</span>:
|
92
|
+
The Experience <span class=\"searchmatch\">Michael</span> <span class=\"searchmatch\">Jackson</span>:
|
93
|
+
The Experience <span class=\"searchmatch\">Michael</span> <span class=\"searchmatch\">Jackson</span>:
|
94
|
+
The Experience <span class=\"searchmatch\">Michael</span> <span class=\"searchmatch\">Jackson</span>:
|
95
|
+
The","size":1131,"wordcount":124,"timestamp":"2014-05-05T08:15:06Z"},{"ns":0,"title":"Q7244161","snippet":"Prince
|
96
|
+
<span class=\"searchmatch\">Michael</span> <span class=\"searchmatch\">Jackson</span>
|
97
|
+
I Prince <span class=\"searchmatch\">Michael</span> <span class=\"searchmatch\">Jackson</span>
|
98
|
+
I Prince <span class=\"searchmatch\">Michael</span> <span class=\"searchmatch\">Jackson</span>
|
99
|
+
I Prince <span class=\"searchmatch\">Michael</span> <span class=\"searchmatch\">Jackson</span>
|
100
|
+
I Prince <span class=\"searchmatch\">Michael</span> <span class=\"searchmatch\">Jackson</span>
|
101
|
+
I Prince <span class=\"searchmatch\">Michael</span> <span class=\"searchmatch\">Jackson</span>
|
102
|
+
I \u067e\u0631\u0646\u0633","size":447,"wordcount":60,"timestamp":"2014-08-22T21:39:22Z"},{"ns":0,"title":"Q756785","snippet":"Cry
|
103
|
+
Cry Cry (b\u00e0i h\u00e1t c\u1ee7a <span class=\"searchmatch\">Michael</span>
|
104
|
+
<span class=\"searchmatch\">Jackson</span>) \u0e04\u0e23\u0e32\u0e22 chanson
|
105
|
+
de <span class=\"searchmatch\">Michael</span> <span class=\"searchmatch\">Jackson</span>
|
106
|
+
singolo di <span class=\"searchmatch\">Michael</span> <span class=\"searchmatch\">Jackson</span>
|
107
|
+
del 2001 <span class=\"searchmatch\">Michael</span> <span class=\"searchmatch\">Jackson</span>
|
108
|
+
song recorded by American","size":835,"wordcount":117,"timestamp":"2014-08-20T02:40:03Z"},{"ns":0,"title":"Q1638445","snippet":"di
|
109
|
+
<span class=\"searchmatch\">Michael</span> <span class=\"searchmatch\">Jackson</span>
|
110
|
+
del 2012 <span class=\"searchmatch\">Michael</span> <span class=\"searchmatch\">Jackson</span>
|
111
|
+
album Kompilationsalbum von <span class=\"searchmatch\">Michael</span> <span
|
112
|
+
class=\"searchmatch\">Jackson</span> Icon (<span class=\"searchmatch\">Michael</span>-<span
|
113
|
+
class=\"searchmatch\">Jackson</span>-Album) Icon (album c\u1ee7a <span class=\"searchmatch\">Michael</span>
|
114
|
+
<span class=\"searchmatch\">Jackson</span>) Icon","size":287,"wordcount":43,"timestamp":"2014-05-07T03:24:35Z"},{"ns":0,"title":"Q44376","snippet":"<span
|
115
|
+
class=\"searchmatch\">Michael</span> <span class=\"searchmatch\">Jackson</span>
|
116
|
+
album album di <span class=\"searchmatch\">Michael</span> <span class=\"searchmatch\">Jackson</span>
|
117
|
+
del 2001 album by <span class=\"searchmatch\">Michael</span> <span class=\"searchmatch\">Jackson</span>
|
118
|
+
Album von <span class=\"searchmatch\">Michael</span> <span class=\"searchmatch\">Jackson</span>
|
119
|
+
\u00e1lbum de <span class=\"searchmatch\">Michael</span> <span class=\"searchmatch\">Jackson</span>
|
120
|
+
\u00e1lbum de <span class=\"searchmatch\">Michael</span> Jackson","size":2167,"wordcount":217,"timestamp":"2014-08-27T21:11:08Z"}]}}'
|
121
|
+
http_version:
|
122
|
+
recorded_at: Mon, 29 Sep 2014 09:07:30 GMT
|
123
|
+
recorded_with: VCR 2.9.3
|
@@ -0,0 +1,123 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: get
|
5
|
+
uri: http://www.wikidata.org/w/api.php?action=query&format=json&list=search&srlimit=10&sroffset=0&srsearch=Michael%20Jackson
|
6
|
+
body:
|
7
|
+
encoding: US-ASCII
|
8
|
+
string: ''
|
9
|
+
headers:
|
10
|
+
User-Agent:
|
11
|
+
- Faraday v0.9.0
|
12
|
+
Expect:
|
13
|
+
- ''
|
14
|
+
response:
|
15
|
+
status:
|
16
|
+
code: 200
|
17
|
+
message: OK
|
18
|
+
headers:
|
19
|
+
Server:
|
20
|
+
- Apache
|
21
|
+
X-Content-Type-Options:
|
22
|
+
- nosniff
|
23
|
+
Cache-Control:
|
24
|
+
- private
|
25
|
+
X-Frame-Options:
|
26
|
+
- DENY
|
27
|
+
Content-Type:
|
28
|
+
- application/json; charset=utf-8
|
29
|
+
Vary:
|
30
|
+
- Accept-Encoding,X-Forwarded-Proto,X-Use-HHVM
|
31
|
+
X-Varnish:
|
32
|
+
- 1526867147, 3175927351, 2469776956
|
33
|
+
Via:
|
34
|
+
- 1.1 varnish, 1.1 varnish, 1.1 varnish
|
35
|
+
Transfer-Encoding:
|
36
|
+
- chunked
|
37
|
+
Date:
|
38
|
+
- Mon, 29 Sep 2014 09:07:30 GMT
|
39
|
+
Age:
|
40
|
+
- '0'
|
41
|
+
Connection:
|
42
|
+
- keep-alive
|
43
|
+
X-Cache:
|
44
|
+
- cp1065 miss (0), amssq52 miss (0), amssq38 frontend miss (0)
|
45
|
+
X-Analytics:
|
46
|
+
- php=zend
|
47
|
+
Set-Cookie:
|
48
|
+
- GeoIP=FR:Sainte-luce-sur-loire:47.2500:-1.5000:v4; Path=/; Domain=.wikidata.org
|
49
|
+
body:
|
50
|
+
encoding: ASCII-8BIT
|
51
|
+
string: '{"query-continue":{"search":{"sroffset":10}},"query":{"searchinfo":{"totalhits":416},"search":[{"ns":0,"title":"Q2831","snippet":"<span
|
52
|
+
class=\"searchmatch\">Michael</span> <span class=\"searchmatch\">Jackson</span>
|
53
|
+
<span class=\"searchmatch\">Michael</span> <span class=\"searchmatch\">Jackson</span>
|
54
|
+
<span class=\"searchmatch\">Michael</span> <span class=\"searchmatch\">Jackson</span>
|
55
|
+
<span class=\"searchmatch\">Michael</span> <span class=\"searchmatch\">Jackson</span>
|
56
|
+
<span class=\"searchmatch\">Michael</span> <span class=\"searchmatch\">Jackson</span>
|
57
|
+
<span class=\"searchmatch\">Michael</span> <span class=\"searchmatch\">Jackson</span>
|
58
|
+
<span class=\"searchmatch\">Michael</span> <span class=\"searchmatch\">Jackson</span>
|
59
|
+
\u121b\u12ed\u12ad\u120d \u1303\u12ad\u1230\u1295 <span class=\"searchmatch\">Michael</span>
|
60
|
+
<span class=\"searchmatch\">Jackson</span> \u0645\u0627\u064a\u0643\u0644
|
61
|
+
\u062c\u0627\u0643\u0633\u0648\u0646","size":8234,"wordcount":890,"timestamp":"2014-09-18T07:35:04Z"},{"ns":0,"title":"Q167877","snippet":"<span
|
62
|
+
class=\"searchmatch\">Michael</span> <span class=\"searchmatch\">Jackson</span>
|
63
|
+
<span class=\"searchmatch\">Michael</span> <span class=\"searchmatch\">Jackson</span>
|
64
|
+
<span class=\"searchmatch\">Michael</span> <span class=\"searchmatch\">Jackson</span>
|
65
|
+
\u041c\u0430\u0439\u043a\u044a\u043b \u0414\u0436\u0430\u043a\u0441\u044a\u043d
|
66
|
+
<span class=\"searchmatch\">Michael</span> <span class=\"searchmatch\">Jackson</span>
|
67
|
+
<span class=\"searchmatch\">Michael</span> <span class=\"searchmatch\">Jackson</span>
|
68
|
+
<span class=\"searchmatch\">Michael</span> <span class=\"searchmatch\">Jackson</span>
|
69
|
+
<span class=\"searchmatch\">Michael</span> <span class=\"searchmatch\">Jackson</span>
|
70
|
+
<span class=\"searchmatch\">Michael</span> <span class=\"searchmatch\">Jackson</span>
|
71
|
+
Michael","size":1216,"wordcount":132,"timestamp":"2014-09-14T15:28:24Z"},{"ns":0,"title":"Q507175","snippet":"<span
|
72
|
+
class=\"searchmatch\">Michael</span> <span class=\"searchmatch\">Jackson</span>
|
73
|
+
The Best of <span class=\"searchmatch\">Michael</span> <span class=\"searchmatch\">Jackson</span>
|
74
|
+
The Best of <span class=\"searchmatch\">Michael</span> <span class=\"searchmatch\">Jackson</span>
|
75
|
+
The Best of <span class=\"searchmatch\">Michael</span> <span class=\"searchmatch\">Jackson</span>
|
76
|
+
The Best of <span class=\"searchmatch\">Michael</span> <span class=\"searchmatch\">Jackson</span>
|
77
|
+
The Best of <span class=\"searchmatch\">Michael</span> Jackson","size":1503,"wordcount":233,"timestamp":"2014-06-04T10:27:12Z"},{"ns":0,"title":"Q956149","snippet":"\u0e2a\u0e1b\u0e35\u0e0a\u0e40\u0e25\u0e2a\u0e2a\u0e4c
|
78
|
+
<span class=\"searchmatch\">Michael</span> <span class=\"searchmatch\">Jackson</span>
|
79
|
+
Single von <span class=\"searchmatch\">Michael</span> <span class=\"searchmatch\">Jackson</span>
|
80
|
+
<span class=\"searchmatch\">Michael</span> <span class=\"searchmatch\">Jackson</span>
|
81
|
+
song chanson de <span class=\"searchmatch\">Michael</span> <span class=\"searchmatch\">Jackson</span>
|
82
|
+
Speechless (chanson de <span class=\"searchmatch\">Michael</span> <span class=\"searchmatch\">Jackson</span>)
|
83
|
+
Speechless","size":720,"wordcount":73,"timestamp":"2014-08-20T02:07:57Z"},{"ns":0,"title":"Q25158","snippet":"<span
|
84
|
+
class=\"searchmatch\">Michael</span> <span class=\"searchmatch\">Jackson</span>
|
85
|
+
del 2002 Album von <span class=\"searchmatch\">Michael</span> <span class=\"searchmatch\">Jackson</span>
|
86
|
+
<span class=\"searchmatch\">Michael</span> <span class=\"searchmatch\">Jackson</span>:
|
87
|
+
Love Songs Love Songs (<span class=\"searchmatch\">Michael</span> <span class=\"searchmatch\">Jackson</span>
|
88
|
+
album) Love Songs (album, <span class=\"searchmatch\">Michael</span> <span
|
89
|
+
class=\"searchmatch\">Jackson</span>)","size":368,"wordcount":55,"timestamp":"2014-05-09T22:51:53Z"},{"ns":0,"title":"Q1308224","snippet":"Experience
|
90
|
+
<span class=\"searchmatch\">Michael</span> <span class=\"searchmatch\">Jackson</span>:
|
91
|
+
The Experience <span class=\"searchmatch\">Michael</span> <span class=\"searchmatch\">Jackson</span>:
|
92
|
+
The Experience <span class=\"searchmatch\">Michael</span> <span class=\"searchmatch\">Jackson</span>:
|
93
|
+
The Experience <span class=\"searchmatch\">Michael</span> <span class=\"searchmatch\">Jackson</span>:
|
94
|
+
The Experience <span class=\"searchmatch\">Michael</span> <span class=\"searchmatch\">Jackson</span>:
|
95
|
+
The","size":1131,"wordcount":124,"timestamp":"2014-05-05T08:15:06Z"},{"ns":0,"title":"Q7244161","snippet":"Prince
|
96
|
+
<span class=\"searchmatch\">Michael</span> <span class=\"searchmatch\">Jackson</span>
|
97
|
+
I Prince <span class=\"searchmatch\">Michael</span> <span class=\"searchmatch\">Jackson</span>
|
98
|
+
I Prince <span class=\"searchmatch\">Michael</span> <span class=\"searchmatch\">Jackson</span>
|
99
|
+
I Prince <span class=\"searchmatch\">Michael</span> <span class=\"searchmatch\">Jackson</span>
|
100
|
+
I Prince <span class=\"searchmatch\">Michael</span> <span class=\"searchmatch\">Jackson</span>
|
101
|
+
I Prince <span class=\"searchmatch\">Michael</span> <span class=\"searchmatch\">Jackson</span>
|
102
|
+
I \u067e\u0631\u0646\u0633","size":447,"wordcount":60,"timestamp":"2014-08-22T21:39:22Z"},{"ns":0,"title":"Q756785","snippet":"Cry
|
103
|
+
Cry Cry (b\u00e0i h\u00e1t c\u1ee7a <span class=\"searchmatch\">Michael</span>
|
104
|
+
<span class=\"searchmatch\">Jackson</span>) \u0e04\u0e23\u0e32\u0e22 chanson
|
105
|
+
de <span class=\"searchmatch\">Michael</span> <span class=\"searchmatch\">Jackson</span>
|
106
|
+
singolo di <span class=\"searchmatch\">Michael</span> <span class=\"searchmatch\">Jackson</span>
|
107
|
+
del 2001 <span class=\"searchmatch\">Michael</span> <span class=\"searchmatch\">Jackson</span>
|
108
|
+
song recorded by American","size":835,"wordcount":117,"timestamp":"2014-08-20T02:40:03Z"},{"ns":0,"title":"Q1638445","snippet":"di
|
109
|
+
<span class=\"searchmatch\">Michael</span> <span class=\"searchmatch\">Jackson</span>
|
110
|
+
del 2012 <span class=\"searchmatch\">Michael</span> <span class=\"searchmatch\">Jackson</span>
|
111
|
+
album Kompilationsalbum von <span class=\"searchmatch\">Michael</span> <span
|
112
|
+
class=\"searchmatch\">Jackson</span> Icon (<span class=\"searchmatch\">Michael</span>-<span
|
113
|
+
class=\"searchmatch\">Jackson</span>-Album) Icon (album c\u1ee7a <span class=\"searchmatch\">Michael</span>
|
114
|
+
<span class=\"searchmatch\">Jackson</span>) Icon","size":287,"wordcount":43,"timestamp":"2014-05-07T03:24:35Z"},{"ns":0,"title":"Q44376","snippet":"<span
|
115
|
+
class=\"searchmatch\">Michael</span> <span class=\"searchmatch\">Jackson</span>
|
116
|
+
album album di <span class=\"searchmatch\">Michael</span> <span class=\"searchmatch\">Jackson</span>
|
117
|
+
del 2001 album by <span class=\"searchmatch\">Michael</span> <span class=\"searchmatch\">Jackson</span>
|
118
|
+
Album von <span class=\"searchmatch\">Michael</span> <span class=\"searchmatch\">Jackson</span>
|
119
|
+
\u00e1lbum de <span class=\"searchmatch\">Michael</span> <span class=\"searchmatch\">Jackson</span>
|
120
|
+
\u00e1lbum de <span class=\"searchmatch\">Michael</span> Jackson","size":2167,"wordcount":217,"timestamp":"2014-08-27T21:11:08Z"}]}}'
|
121
|
+
http_version:
|
122
|
+
recorded_at: Mon, 29 Sep 2014 09:07:30 GMT
|
123
|
+
recorded_with: VCR 2.9.3
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
require "codeclimate-test-reporter"
|
2
|
+
CodeClimate::TestReporter.start
|
3
|
+
|
4
|
+
require 'wikidata'
|
5
|
+
require 'vcr'
|
6
|
+
require 'pry'
|
7
|
+
|
8
|
+
RSpec.configure do |config|
|
9
|
+
config.expect_with :rspec do |expectations|
|
10
|
+
expectations.syntax = [:should, :expect]
|
11
|
+
expectations.include_chain_clauses_in_custom_matcher_descriptions = true
|
12
|
+
end
|
13
|
+
|
14
|
+
config.mock_with :rspec do |mocks|
|
15
|
+
mocks.verify_partial_doubles = true
|
16
|
+
end
|
17
|
+
|
18
|
+
config.filter_run focus: true
|
19
|
+
config.run_all_when_everything_filtered = true
|
20
|
+
|
21
|
+
VCR.configure do |c|
|
22
|
+
c.cassette_library_dir = 'spec/fixtures/vcr'
|
23
|
+
c.default_cassette_options = { record: :new_episodes }
|
24
|
+
c.hook_into :webmock
|
25
|
+
c.allow_http_connections_when_no_cassette = true
|
26
|
+
c.configure_rspec_metadata!
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,139 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Wikidata::Entity, :vcr do
|
4
|
+
let(:sid) { Wikidata::Item.find_by_title 'Sid Vicious' }
|
5
|
+
let(:homer) { Wikidata::Item.find_by_title 'Homer Simpson' }
|
6
|
+
let(:batofar) { Wikidata::Item.find_by_title 'Le Batofar' }
|
7
|
+
let(:github) { Wikidata::Item.find_by_title 'GitHub' }
|
8
|
+
|
9
|
+
describe 'properties' do
|
10
|
+
|
11
|
+
it 'should return id' do
|
12
|
+
sid.id.should eq 'Q47878'
|
13
|
+
end
|
14
|
+
|
15
|
+
it 'should return url' do
|
16
|
+
sid.url.should eq 'http://www.wikidata.org/wiki/Q47878'
|
17
|
+
end
|
18
|
+
|
19
|
+
it 'should return labels' do
|
20
|
+
sid.labels.en.value.should eq 'Sid Vicious'
|
21
|
+
sid.labels.ja.value.should eq 'シド・ヴィシャス'
|
22
|
+
end
|
23
|
+
|
24
|
+
it 'should return aliases' do
|
25
|
+
sid.aliases.en.map(&:value).should eq ['John Simon Ritchie', 'Здох через шлюху'] # ?!?
|
26
|
+
sid.aliases.ja.map(&:value).should eq ['シド・ビシャス']
|
27
|
+
end
|
28
|
+
|
29
|
+
it 'should return descriptions' do
|
30
|
+
sid.descriptions.en.value.should eq 'Bassist, songwriter, composer'
|
31
|
+
end
|
32
|
+
|
33
|
+
it 'should return sitelinks' do
|
34
|
+
sid.sitelinks.frwiki.should eq({"site"=>"frwiki", "title"=>"Sid Vicious", "badges"=>[]})
|
35
|
+
end
|
36
|
+
|
37
|
+
describe 'entities' do
|
38
|
+
|
39
|
+
it 'should return entities property from an id (P40 for children here)' do
|
40
|
+
homer.properties('P40').tap do |children|
|
41
|
+
children.size.should eq 3
|
42
|
+
children.each{|c| c.should be_kind_of Wikidata::Item }
|
43
|
+
children.map{|c| c.labels['en']['value'] }.should eq ['Bart Simpson', 'Lisa Simpson', 'Maggie Simpson']
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
it 'should return entities property from a key (children here)' do
|
48
|
+
homer.children.tap do |children|
|
49
|
+
children.size.should eq 3
|
50
|
+
children.each{|c| c.should be_kind_of Wikidata::Item }
|
51
|
+
children.map{|c| c.labels['en']['value'] }.should eq ['Bart Simpson', 'Lisa Simpson', 'Maggie Simpson']
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
it 'should allow to return only entities ids from an id' do
|
56
|
+
homer.property_ids('P40').should eq ["Q5480", "Q5846", "Q7834"]
|
57
|
+
end
|
58
|
+
|
59
|
+
it 'should allow to return only entities ids from a key' do
|
60
|
+
homer.children_ids.should eq ["Q5480", "Q5846", "Q7834"]
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
describe 'properties' do
|
65
|
+
|
66
|
+
context 'of type date' do
|
67
|
+
it 'should return Time from a property id (P569 for date of birth here)' do
|
68
|
+
homer.property('P569').tap do |date|
|
69
|
+
date.should be_kind_of Wikidata::Property::Time
|
70
|
+
date.date.should eq DateTime.new(1956, 6, 18)
|
71
|
+
date.range.should eq(
|
72
|
+
(DateTime.new(1956, 6, 18, 0, 0, 0)..DateTime.new(1956, 6, 19, 23, 59, 59))
|
73
|
+
)
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
it 'should return Time from a a key (date_of_birth here)' do
|
78
|
+
homer.date_of_birth.tap do |date|
|
79
|
+
date.should be_kind_of Wikidata::Property::Time
|
80
|
+
date.date.should eq DateTime.new(1956, 6, 18)
|
81
|
+
date.range.should eq(
|
82
|
+
(DateTime.new(1956, 6, 18, 0, 0, 0)..DateTime.new(1956, 6, 19, 23, 59, 59))
|
83
|
+
)
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
context 'of type globe coordinate' do
|
89
|
+
it 'should return GlobeCoordinate from a property id (P625 for coordinate location here)' do
|
90
|
+
batofar.property('P625').tap do |c|
|
91
|
+
c.should be_kind_of Wikidata::Property::GlobeCoordinate
|
92
|
+
c.latitude.should eq 48.83337778
|
93
|
+
c.longitude.should eq 2.37925278
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
97
|
+
it 'should return GlobeCoordinate from a key (coordinate_location here)' do
|
98
|
+
batofar.coordinate_location.tap do |c|
|
99
|
+
c.should be_kind_of Wikidata::Property::GlobeCoordinate
|
100
|
+
c.latitude.should eq 48.83337778
|
101
|
+
c.longitude.should eq 2.37925278
|
102
|
+
end
|
103
|
+
end
|
104
|
+
end
|
105
|
+
|
106
|
+
context 'of type string' do
|
107
|
+
it 'should return String from a property id (P646 for freebase identifier here)' do
|
108
|
+
homer.property('P646').tap do |c|
|
109
|
+
c.should be_kind_of Wikidata::Property::String
|
110
|
+
c.value.should eq '/m/0h545'
|
111
|
+
end
|
112
|
+
end
|
113
|
+
|
114
|
+
it 'should return String from a key (freebase_identifier here)' do
|
115
|
+
homer.freebase_identifier.tap do |c|
|
116
|
+
c.should be_kind_of Wikidata::Property::String
|
117
|
+
c.value.should eq '/m/0h545'
|
118
|
+
end
|
119
|
+
end
|
120
|
+
end
|
121
|
+
|
122
|
+
context 'of type url' do
|
123
|
+
it 'should return Url from a property id (P856 for official website here)' do
|
124
|
+
github.property('P856').tap do |c|
|
125
|
+
c.should be_kind_of Wikidata::Property::Url
|
126
|
+
c.value.should eq 'https://github.com'
|
127
|
+
end
|
128
|
+
end
|
129
|
+
|
130
|
+
it 'should return Url from a key (official_website here)' do
|
131
|
+
github.official_website.tap do |c|
|
132
|
+
c.should be_kind_of Wikidata::Property::Url
|
133
|
+
c.value.should eq 'https://github.com'
|
134
|
+
end
|
135
|
+
end
|
136
|
+
end
|
137
|
+
end
|
138
|
+
end
|
139
|
+
end
|
@@ -0,0 +1,64 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Wikidata::Item, :vcr do
|
4
|
+
|
5
|
+
describe '#find:' do
|
6
|
+
let(:entity_by_id) { Wikidata::Item.find 'Q2831' }
|
7
|
+
let(:entity_by_title) { Wikidata::Item.find_by_title 'Michael Jackson' }
|
8
|
+
let(:collection_by_id) { Wikidata::Item.find ['Q2831', 'Q47878'] }
|
9
|
+
let(:collection_by_title) { Wikidata::Item.find_by_title ['Michael Jackson', 'Sid Vicious'] }
|
10
|
+
|
11
|
+
it 'should return nil if item not found' do
|
12
|
+
Wikidata::Item.find('THISISNOTAVALIDID').should be_nil
|
13
|
+
end
|
14
|
+
|
15
|
+
it 'should find by id' do
|
16
|
+
entity_by_id.should be_kind_of Wikidata::Item
|
17
|
+
end
|
18
|
+
|
19
|
+
it 'should find by title' do
|
20
|
+
entity_by_title.should be_kind_of Wikidata::Item
|
21
|
+
end
|
22
|
+
|
23
|
+
it 'should find by ids' do
|
24
|
+
collection_by_id.size.should eq 2
|
25
|
+
collection_by_id.should be_kind_of Wikidata::Response
|
26
|
+
collection_by_id.results.each{|i| i.should be_kind_of Wikidata::Item }
|
27
|
+
end
|
28
|
+
|
29
|
+
it 'should find by titles' do
|
30
|
+
collection_by_title.size.should eq 2
|
31
|
+
collection_by_title.should be_kind_of Wikidata::Response
|
32
|
+
collection_by_title.results.each{|i| i.should be_kind_of Wikidata::Item }
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
describe '#search' do
|
37
|
+
let(:search) { Wikidata::Item.search 'Michael Jackson' }
|
38
|
+
|
39
|
+
it 'should return a response with an empty array of results if search missing' do
|
40
|
+
Wikidata::Item.search('').tap do |s|
|
41
|
+
s.should be_kind_of Wikidata::Response
|
42
|
+
s.results.should be_empty
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
it 'should return an array of Wikidata::Item' do
|
47
|
+
search.size.should eq 10
|
48
|
+
search.should be_kind_of Wikidata::SearchResponse
|
49
|
+
search.results.each{|i| i.should be_kind_of Wikidata::Item }
|
50
|
+
end
|
51
|
+
|
52
|
+
it 'should return the total number of hits' do
|
53
|
+
search.total_hits.should eq 416
|
54
|
+
end
|
55
|
+
|
56
|
+
it 'should return the next page offset' do
|
57
|
+
search.next_page_offset.should eq 10
|
58
|
+
end
|
59
|
+
|
60
|
+
it 'should fetch all all items of the collection' do
|
61
|
+
search.results.first.descriptions.pl.value.should eq 'amerykański muzyk, kompozytor i autor tekstów'
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|