wikidata-client 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 176a5af4ed352f7b9647a8ee712c5dcc98314abe
4
- data.tar.gz: 4a1bbc872493aaeb43f0c374de9aac2244e445fe
3
+ metadata.gz: 574fa6611ad2c28edfe22c33ef380ac5126f6b0e
4
+ data.tar.gz: 629b49700bb84e330bbd798d0a98acb3c034aada
5
5
  SHA512:
6
- metadata.gz: 4e88633911b243de244e13a694cef8ad33dcd3fc3442f78e4e3c9bd1b61b2a6e10b1edbfb656c5d87f09abfc1e4468640d9e0b070c1fccabbb64fb1363e612c1
7
- data.tar.gz: 318598d5c79876629b2bf334a1c60a3d5a16ff544e669335908ad61d7e26cee1594899dfe2cce27d8aff1d2014dee5f24fc46f6d636ff5ae762c4631adfcbea1
6
+ metadata.gz: 0d23c328efba521a691be46048e82f8fe7912683f130583dc4297057ae3b106a395cf37c56005580eccda19160cbfbeae399d820af16327ef85923d6721b0e1a
7
+ data.tar.gz: 09de214a928f2886b2d4eaffc75199ac01b16325434f052752066db31528ce58f34a08b3dac72dc0ed2aa22b7e6a8535d30fb466c2663c673268733472a270b8
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- wikidata-client (0.0.1)
4
+ wikidata-client (0.0.2)
5
5
  faraday (~> 0.9)
6
6
  faraday_middleware (~> 0.9)
7
7
  hashie (~> 3.3)
@@ -11,7 +11,7 @@ GEM
11
11
  remote: https://rubygems.org/
12
12
  specs:
13
13
  addressable (2.3.6)
14
- codeclimate-test-reporter (0.4.0)
14
+ codeclimate-test-reporter (0.4.1)
15
15
  simplecov (>= 0.7.1, < 1.0.0)
16
16
  coderay (1.1.0)
17
17
  crack (0.4.2)
@@ -44,7 +44,7 @@ GEM
44
44
  rspec-mocks (3.1.1)
45
45
  rspec-support (~> 3.1.0)
46
46
  rspec-support (3.1.0)
47
- safe_yaml (1.0.3)
47
+ safe_yaml (1.0.4)
48
48
  simplecov (0.9.1)
49
49
  docile (~> 1.1.0)
50
50
  multi_json (~> 1.0)
@@ -52,7 +52,7 @@ GEM
52
52
  simplecov-html (0.8.0)
53
53
  slop (3.6.0)
54
54
  vcr (2.9.3)
55
- webmock (1.18.0)
55
+ webmock (1.19.0)
56
56
  addressable (>= 2.3.6)
57
57
  crack (>= 0.3.2)
58
58
 
data/README.md CHANGED
@@ -1,5 +1,6 @@
1
1
  # Wikidata API Client
2
2
 
3
+ [![Gem Version](https://badge.fury.io/rb/wikidata-client.svg)](http://badge.fury.io/rb/wikidata-client)
3
4
  [![Build Status](https://travis-ci.org/klacointe/wikidata-client.svg?branch=master)](https://travis-ci.org/klacointe/wikidata-client)
4
5
  [![Code Climate](https://codeclimate.com/github/klacointe/wikidata-client/badges/gpa.svg)](https://codeclimate.com/github/klacointe/wikidata-client)
5
6
  [![Test Coverage](https://codeclimate.com/github/klacointe/wikidata-client/badges/coverage.svg)](https://codeclimate.com/github/klacointe/wikidata-client)
@@ -25,21 +25,15 @@ module Wikidata
25
25
  Wikidata.settings.item.url.gsub(':id', id)
26
26
  end
27
27
 
28
- Wikidata.mapping.resources.each do |k, code|
29
- define_method k do
30
- property code
31
- end
32
- define_method "#{k}_id" do
33
- property_id code
34
- end
35
- end
36
-
37
- Wikidata.mapping.collections.each do |k, code|
38
- define_method k do
39
- properties code
40
- end
41
- define_method "#{k}_ids" do
42
- property_ids code
28
+ Wikidata.mapping.each do |type, mappings|
29
+ resource = (type.to_sym == :resources)
30
+ mappings.each do |k, code|
31
+ define_method k do
32
+ resource ? property(code) : properties(code)
33
+ end
34
+ define_method (resource ? "#{k}_id" : "#{k}_ids") do
35
+ resource ? property_id(code) : property_ids(code)
36
+ end
43
37
  end
44
38
  end
45
39
 
@@ -49,16 +43,8 @@ module Wikidata
49
43
 
50
44
  def property_ids code
51
45
  Array(raw_property(code)).map do |attribute|
52
- # TODO Handle other types
53
- # http://www.wikidata.org/wiki/Wikidata:Glossary#Entities.2C_items.2C_properties_and_queries
54
- case attribute.mainsnak.datavalue.value['entity-type']
55
- when 'item'
56
- prefix = 'Q'
57
- else
58
- raise "Unkown wikibase-item entity-type #{attribute.mainsnak.datatype.value['entity-type']}"
59
- end
60
- "#{prefix}#{attribute.mainsnak.datavalue.value['numeric-id']}"
61
- end
46
+ self.class.entity_id attribute
47
+ end.compact
62
48
  end
63
49
 
64
50
  def property code
@@ -73,6 +59,22 @@ module Wikidata
73
59
  "<#{self.class} id: #{id}, title: \"#{title}\">"
74
60
  end
75
61
 
62
+ class << self
63
+
64
+ # TODO Handle other types
65
+ # http://www.wikidata.org/wiki/Wikidata:Glossary#Entities.2C_items.2C_properties_and_queries
66
+ def entity_id attribute
67
+ attribute.mainsnak.datavalue.value.tap do |h|
68
+ case h['entity-type']
69
+ when 'item'
70
+ return "Q#{h['numeric-id']}"
71
+ else
72
+ return nil
73
+ end
74
+ end
75
+ end
76
+ end
77
+
76
78
  private
77
79
 
78
80
  def raw_property code
data/lib/wikidata/item.rb CHANGED
@@ -15,20 +15,19 @@ module Wikidata
15
15
 
16
16
  class << self
17
17
  def find ids, query = {}
18
- q = DEFAULT_QUERIES[:find]
19
- .merge( query )
20
- .merge( ids: Array(ids).join('|') )
21
- Wikidata::Client.new( q ).response.tap do |resp|
22
- return resp.results.first unless ids.is_a?(Array)
23
- end
18
+ _find :ids, ids, query
24
19
  end
25
20
 
26
21
  def find_by_title titles, query = {}
22
+ _find :titles, titles, query
23
+ end
24
+
25
+ def _find finder = :ids, list = '', query = {}
27
26
  q = DEFAULT_QUERIES[:find]
28
27
  .merge( query )
29
- .merge( titles: Array(titles).join('|') )
28
+ .merge( finder => Array(list).join('|') )
30
29
  Wikidata::Client.new( q ).response.tap do |resp|
31
- return resp.results.first unless titles.is_a?(Array)
30
+ return resp.results.first unless list.is_a?(Array)
32
31
  end
33
32
  end
34
33
 
@@ -12,15 +12,7 @@ module Wikidata
12
12
  when 'url'
13
13
  Wikidata::Property::Url.new attribute
14
14
  when 'wikibase-item'
15
- # TODO Handle other types
16
- # http://www.wikidata.org/wiki/Wikidata:Glossary#Entities.2C_items.2C_properties_and_queries
17
- case attribute.mainsnak.datavalue.value['entity-type']
18
- when 'item'
19
- prefix = 'Q'
20
- else
21
- raise "Unkown wikibase-item entity-type #{attribute.mainsnak.datatype.value['entity-type']}"
22
- end
23
- Wikidata::Item.find "#{prefix}#{attribute.mainsnak.datavalue.value['numeric-id']}"
15
+ Wikidata::Item.find Wikidata::Entity.entity_id(attribute)
24
16
  else
25
17
  raise "Unkown property type #{attribute.mainsnak.datatype}"
26
18
  end
@@ -1,3 +1,3 @@
1
1
  module Wikidata
2
- VERSION = "0.0.1".freeze
2
+ VERSION = "0.0.2".freeze
3
3
  end
@@ -0,0 +1,160 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: http://www.wikidata.org/w/api.php?action=wbgetentities&format=json&sites=enwiki&titles=Homer%20Simpson
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-Use-HHVM
31
+ X-Varnish:
32
+ - 2282365090, 3231348047, 2153710035
33
+ Via:
34
+ - 1.1 varnish, 1.1 varnish, 1.1 varnish
35
+ Transfer-Encoding:
36
+ - chunked
37
+ Date:
38
+ - Wed, 01 Oct 2014 15:12:16 GMT
39
+ Age:
40
+ - '0'
41
+ Connection:
42
+ - keep-alive
43
+ X-Cache:
44
+ - cp1068 miss (0), amssq48 miss (0), amssq37 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: '{"entities":{"Q7810":{"pageid":9056,"ns":0,"title":"Q7810","lastrevid":159661784,"modified":"2014-09-25T12:26:51Z","id":"Q7810","type":"item","aliases":{"de":[{"language":"de","value":"Homer
52
+ J. Simpsons"},{"language":"de","value":"Homer Jay Simpson"},{"language":"de","value":"Captain
53
+ Albern"},{"language":"de","value":"Max Power"},{"language":"de","value":"Dancin\u2019
54
+ Homer"},{"language":"de","value":"Andreas T. aus Happyhill"},{"language":"de","value":"Colonel
55
+ Homer"},{"language":"de","value":"Mr. Schneepflug"},{"language":"de","value":"Brian
56
+ McGee"},{"language":"de","value":"Mr. Thompson"},{"language":"de","value":"der
57
+ Bierbaron"},{"language":"de","value":"Arthur N. aus Rosenburg"},{"language":"de","value":"Mr.
58
+ X"},{"language":"de","value":"El Homo"},{"language":"de","value":"Elvis Jagger
59
+ Abdul-Jabbar"},{"language":"de","value":"Tortenmann"},{"language":"de","value":"Homer
60
+ Sanchez"},{"language":"de","value":"Homie"},{"language":"de","value":"Admiral
61
+ Adonis"},{"language":"de","value":"Commander Cool"}],"en":[{"language":"en","value":"Homer
62
+ Jay Simpson"}],"it":[{"language":"it","value":"Homer J. Simpson"}]},"labels":{"it":{"language":"it","value":"Homer
63
+ Simpson"},"fr":{"language":"fr","value":"Homer Simpson"},"en":{"language":"en","value":"Homer
64
+ Simpson"},"de":{"language":"de","value":"Homer Simpson"},"af":{"language":"af","value":"Homer
65
+ Simpson"},"ast":{"language":"ast","value":"Homer Simpson"},"az":{"language":"az","value":"Homer
66
+ Simpson"},"bar":{"language":"bar","value":"Homer Simpson"},"be":{"language":"be","value":"\u0413\u0430\u043c\u0435\u0440
67
+ \u0421\u0456\u043c\u043f\u0441\u0430\u043d"},"bg":{"language":"bg","value":"\u0425\u043e\u0443\u043c\u044a\u0440
68
+ \u0421\u0438\u043c\u043f\u0441\u044a\u043d"},"bo":{"language":"bo","value":"\u0f67\u0f7c\u0f60\u0f7c\u0f0b\u0f58\u0f62\u0f0b\u0f66\u0f72\u0f58\u0f0b\u0f56\u0f74\u0f0b\u0f66\u0f53\u0f0d"},"bs":{"language":"bs","value":"Homer
69
+ Simpson"},"ca":{"language":"ca","value":"Homer Simpson"},"cs":{"language":"cs","value":"Homer
70
+ Simpson"},"cy":{"language":"cy","value":"Homer Simpson"},"da":{"language":"da","value":"Homer
71
+ Simpson"},"en-ca":{"language":"en-ca","value":"Homer Simpson"},"en-gb":{"language":"en-gb","value":"Homer
72
+ Simpson"},"es":{"language":"es","value":"Homer Simpson"},"et":{"language":"et","value":"Homer
73
+ Simpson"},"eu":{"language":"eu","value":"Homer Simpson"},"fa":{"language":"fa","value":"\u0647\u0648\u0645\u0631
74
+ \u0633\u06cc\u0645\u067e\u0633\u0648\u0646"},"fi":{"language":"fi","value":"Homer
75
+ Simpson"},"ga":{"language":"ga","value":"Homer Simpson"},"gl":{"language":"gl","value":"Homer
76
+ Simpson"},"he":{"language":"he","value":"\u05d4\u05d5\u05de\u05e8 \u05e1\u05d9\u05de\u05e4\u05e1\u05d5\u05df"},"hr":{"language":"hr","value":"Homer
77
+ Simpson"},"hu":{"language":"hu","value":"Homer Simpson"},"hy":{"language":"hy","value":"\u0540\u0578\u0574\u0565\u0580
78
+ \u054d\u056b\u0574\u057a\u057d\u0578\u0576"},"id":{"language":"id","value":"Homer
79
+ Simpson"},"is":{"language":"is","value":"H\u00f3mer Simpson"},"ja":{"language":"ja","value":"\u30db\u30fc\u30de\u30fc\u30fb\u30b7\u30f3\u30d7\u30bd\u30f3"},"ka":{"language":"ka","value":"\u10f0\u10dd\u10db\u10d4\u10e0
80
+ \u10e1\u10d8\u10db\u10de\u10e1\u10dd\u10dc\u10d8"},"ko":{"language":"ko","value":"\ud638\uba38
81
+ \uc2ec\uc2a8"},"lb":{"language":"lb","value":"Homer Simpson"},"lv":{"language":"lv","value":"Hom\u0113rs
82
+ Simpsons"},"mr":{"language":"mr","value":"\u0939\u094b\u092e\u0930 \u0938\u093f\u092e\u094d\u092a\u094d\u0938\u0928"},"nah":{"language":"nah","value":"Homer
83
+ Simpson"},"ne":{"language":"ne","value":"\u0939\u094b\u092e\u0930 \u0938\u093f\u092e\u094d\u092a\u094d\u0938\u0928"},"nl":{"language":"nl","value":"Homer
84
+ Simpson"},"oc":{"language":"oc","value":"Homer Simpson"},"pi":{"language":"pi","value":"\u0939\u094b\u092e\u0930
85
+ \u0938\u093f\u092e\u094d\u092a\u094d\u0938\u0928"},"pl":{"language":"pl","value":"Homer
86
+ Simpson"},"pt":{"language":"pt","value":"Homer Simpson"},"pt-br":{"language":"pt-br","value":"Homer
87
+ Simpson"},"ro":{"language":"ro","value":"Homer Simpson"},"ru":{"language":"ru","value":"\u0413\u043e\u043c\u0435\u0440
88
+ \u0421\u0438\u043c\u043f\u0441\u043e\u043d"},"sa":{"language":"sa","value":"\u0939\u094b\u092e\u0930
89
+ \u0938\u093f\u092e\u094d\u092a\u094d\u0938\u0928"},"scn":{"language":"scn","value":"Homer
90
+ Simpson"},"sh":{"language":"sh","value":"Homer Simpson"},"sk":{"language":"sk","value":"Homer
91
+ Simpson"},"sq":{"language":"sq","value":"Homer Simpson"},"sr":{"language":"sr","value":"\u0425\u043e\u043c\u0435\u0440
92
+ \u040f\u0435\u0458 \u0421\u0438\u043c\u043f\u0441\u043e\u043d"},"sv":{"language":"sv","value":"Homer
93
+ Simpson"},"th":{"language":"th","value":"\u0e42\u0e2e\u0e40\u0e21\u0e2d\u0e23\u0e4c
94
+ \u0e0b\u0e34\u0e21\u0e1b\u0e4c\u0e2a\u0e31\u0e19"},"tr":{"language":"tr","value":"Homer
95
+ Simpson"},"uk":{"language":"uk","value":"\u0413\u043e\u043c\u0435\u0440 \u0421\u0456\u043c\u043f\u0441\u043e\u043d"},"vi":{"language":"vi","value":"Homer
96
+ Simpson"},"war":{"language":"war","value":"Homer Simpson"},"zh":{"language":"zh","value":"\u970d\u9ed8\u00b7\u8f9b\u666e\u68ee"},"gn":{"language":"gn","value":"Homer
97
+ Simpson"},"lt":{"language":"lt","value":"Homer Simpson"},"nb":{"language":"nb","value":"Homer
98
+ Simpson"},"ar":{"language":"ar","value":"\u0647\u0648\u0645\u0631 \u0633\u064a\u0645\u0628\u0633\u0648\u0646"},"ckb":{"language":"ckb","value":"\u06be\u06c6\u0645\u06d5\u0631
99
+ \u0633\u06cc\u0645\u067e\u0633\u06c6\u0646"},"nn":{"language":"nn","value":"Homer
100
+ Simpson"},"eo":{"language":"eo","value":"Homer Simpson"}},"descriptions":{"it":{"language":"it","value":"protagonista
101
+ della serie I Simpson"},"de":{"language":"de","value":"Figur der Simpsons"},"ru":{"language":"ru","value":"\u0433\u043b\u0430\u0432\u043d\u044b\u0439
102
+ \u0433\u0435\u0440\u043e\u0439 \u043c\u0443\u043b\u044c\u0442\u0441\u0435\u0440\u0438\u0430\u043b\u0430
103
+ \u00ab\u0421\u0438\u043c\u043f\u0441\u043e\u043d\u044b\u00bb"},"es":{"language":"es","value":"personaje
104
+ de dibujos animados"},"en":{"language":"en","value":"fictional character from
105
+ The Simpsons franchise"},"fr":{"language":"fr","value":"personnage de la s\u00e9rie
106
+ t\u00e9l\u00e9vis\u00e9e Les Simpson"},"nl":{"language":"nl","value":"personage
107
+ uit The Simpsons"}},"claims":{"P7":[{"id":"Q7810$2eb0aa51-40cb-3312-5b5d-777a34b3be23","mainsnak":{"snaktype":"value","property":"P7","datatype":"wikibase-item","datavalue":{"value":{"entity-type":"item","numeric-id":2340973},"type":"wikibase-entityid"}},"type":"statement","rank":"normal"}],"P345":[{"id":"q7810$D52517F8-64C0-498F-BD1F-2665DADE3A34","mainsnak":{"snaktype":"value","property":"P345","datatype":"string","datavalue":{"value":"ch0003002","type":"string"}},"type":"statement","rank":"preferred"}],"P26":[{"id":"q7810$7A080AE2-BE0B-4D9E-8B8C-6C1D5FD5C838","mainsnak":{"snaktype":"value","property":"P26","datatype":"wikibase-item","datavalue":{"value":{"entity-type":"item","numeric-id":7828},"type":"wikibase-entityid"}},"type":"statement","rank":"normal"}],"P21":[{"id":"q7810$EBCB4B01-C592-44E7-9DB8-F090E62074E2","mainsnak":{"snaktype":"value","property":"P21","datatype":"wikibase-item","datavalue":{"value":{"entity-type":"item","numeric-id":6581097},"type":"wikibase-entityid"}},"type":"statement","rank":"normal"}],"P40":[{"id":"q7810$2B9F1E2C-7583-4DD8-8CEB-F367FC0641E1","mainsnak":{"snaktype":"value","property":"P40","datatype":"wikibase-item","datavalue":{"value":{"entity-type":"item","numeric-id":5480},"type":"wikibase-entityid"}},"type":"statement","rank":"normal"},{"id":"q7810$A6DC727E-3642-470C-BD93-6707640CD90C","mainsnak":{"snaktype":"value","property":"P40","datatype":"wikibase-item","datavalue":{"value":{"entity-type":"item","numeric-id":5846},"type":"wikibase-entityid"}},"type":"statement","rank":"normal"},{"id":"q7810$E580F297-F30A-4680-BA5C-3559041E3B0F","mainsnak":{"snaktype":"value","property":"P40","datatype":"wikibase-item","datavalue":{"value":{"entity-type":"item","numeric-id":7834},"type":"wikibase-entityid"}},"type":"statement","rank":"normal"}],"P22":[{"id":"q7810$571A84C2-93C0-48E3-8DD3-A92A7D57BEA9","mainsnak":{"snaktype":"value","property":"P22","datatype":"wikibase-item","datavalue":{"value":{"entity-type":"item","numeric-id":842104},"type":"wikibase-entityid"}},"type":"statement","rank":"normal"}],"P25":[{"id":"q7810$46038435-4D85-46AB-90CE-5555ACD71760","mainsnak":{"snaktype":"value","property":"P25","datatype":"wikibase-item","datavalue":{"value":{"entity-type":"item","numeric-id":1641818},"type":"wikibase-entityid"}},"type":"statement","rank":"normal"}],"P19":[{"id":"q7810$F3E8C187-B8F2-4096-B15E-C4168F90CE42","mainsnak":{"snaktype":"value","property":"P19","datatype":"wikibase-item","datavalue":{"value":{"entity-type":"item","numeric-id":151076},"type":"wikibase-entityid"}},"type":"statement","rank":"normal"}],"P434":[{"id":"q7810$7604e6cb-443a-65f9-2ab3-70db024360af","mainsnak":{"snaktype":"value","property":"P434","datatype":"string","datavalue":{"value":"109a53ec-73e7-44e8-81cd-484114849a02","type":"string"}},"type":"statement","rank":"normal"}],"P373":[{"id":"q7810$1511B4E7-E94C-45FA-8DF5-07616B0B2A86","mainsnak":{"snaktype":"novalue","property":"P373"},"type":"statement","rank":"normal"}],"P27":[{"id":"Q7810$3C8AEBB8-9F14-4E4C-B386-FFAFBDBC9F46","mainsnak":{"snaktype":"value","property":"P27","datatype":"wikibase-item","datavalue":{"value":{"entity-type":"item","numeric-id":30},"type":"wikibase-entityid"}},"type":"statement","rank":"normal"}],"P646":[{"id":"Q7810$8F38CA22-CBE7-45D0-A02D-B2D5950B6648","mainsnak":{"snaktype":"value","property":"P646","datatype":"string","datavalue":{"value":"/m/0h545","type":"string"}},"type":"statement","rank":"normal","references":[{"hash":"b923b0d68beb300866b87ead39f61e63ec30d8af","snaks":{"P248":[{"snaktype":"value","property":"P248","datatype":"wikibase-item","datavalue":{"value":{"entity-type":"item","numeric-id":15241312},"type":"wikibase-entityid"}}],"P577":[{"snaktype":"value","property":"P577","datatype":"time","datavalue":{"value":{"time":"+00000002013-10-28T00:00:00Z","timezone":0,"before":0,"after":0,"precision":11,"calendarmodel":"http://www.wikidata.org/entity/Q1985727"},"type":"time"}}]},"snaks-order":["P248","P577"]}]}],"P569":[{"id":"Q7810$B87E9E15-38ED-4A83-B7A5-0EA872EC98EE","mainsnak":{"snaktype":"value","property":"P569","datatype":"time","datavalue":{"value":{"time":"+00000001956-06-18T00:00:00Z","timezone":0,"before":0,"after":0,"precision":11,"calendarmodel":"http://www.wikidata.org/entity/Q1985727"},"type":"time"}},"type":"statement","rank":"normal"}],"P31":[{"id":"Q7810$ae77588c-491b-63c1-7bc0-3f902811f72a","mainsnak":{"snaktype":"value","property":"P31","datatype":"wikibase-item","datavalue":{"value":{"entity-type":"item","numeric-id":15632617},"type":"wikibase-entityid"}},"type":"statement","rank":"normal"}],"P1441":[{"id":"Q7810$0B70914E-EA32-4B54-AF9F-08CA8716557C","mainsnak":{"snaktype":"value","property":"P1441","datatype":"wikibase-item","datavalue":{"value":{"entity-type":"item","numeric-id":886},"type":"wikibase-entityid"}},"type":"statement","rank":"normal"}]},"sitelinks":{"afwiki":{"site":"afwiki","title":"Homer
108
+ Simpson","badges":[]},"arwiki":{"site":"arwiki","title":"\u0647\u0648\u0645\u0631
109
+ \u0633\u064a\u0645\u0628\u0633\u0648\u0646","badges":[]},"astwiki":{"site":"astwiki","title":"Homer
110
+ Simpson","badges":[]},"azwiki":{"site":"azwiki","title":"Homer Simpson","badges":[]},"azwikiquote":{"site":"azwikiquote","title":"Homer
111
+ Simpson","badges":[]},"barwiki":{"site":"barwiki","title":"Homer Simpson","badges":[]},"bewiki":{"site":"bewiki","title":"\u0413\u0430\u043c\u0435\u0440
112
+ \u0421\u0456\u043c\u043f\u0441\u0430\u043d","badges":[]},"bgwiki":{"site":"bgwiki","title":"\u0425\u043e\u0443\u043c\u044a\u0440
113
+ \u0421\u0438\u043c\u043f\u0441\u044a\u043d","badges":[]},"bowiki":{"site":"bowiki","title":"\u0f67\u0f7c\u0f60\u0f7c\u0f0b\u0f58\u0f62\u0f0b\u0f66\u0f72\u0f58\u0f0b\u0f56\u0f74\u0f0b\u0f66\u0f53\u0f0d","badges":[]},"bswiki":{"site":"bswiki","title":"Homer
114
+ Simpson","badges":[]},"bswikiquote":{"site":"bswikiquote","title":"Homer Simpson","badges":[]},"cawiki":{"site":"cawiki","title":"Homer
115
+ Simpson","badges":[]},"ckbwiki":{"site":"ckbwiki","title":"\u06be\u06c6\u0645\u06d5\u0631
116
+ \u0633\u06cc\u0645\u067e\u0633\u06c6\u0646","badges":[]},"cswiki":{"site":"cswiki","title":"Homer
117
+ Simpson","badges":[]},"cywiki":{"site":"cywiki","title":"Homer Simpson","badges":[]},"dawiki":{"site":"dawiki","title":"Homer
118
+ Simpson","badges":[]},"dawikiquote":{"site":"dawikiquote","title":"Homer Simpson","badges":[]},"dewiki":{"site":"dewiki","title":"Homer
119
+ Simpson","badges":[]},"enwiki":{"site":"enwiki","title":"Homer Simpson","badges":["Q17437796"]},"eowikiquote":{"site":"eowikiquote","title":"Homer
120
+ Simpson","badges":[]},"eswiki":{"site":"eswiki","title":"Homer Simpson","badges":["Q17437796"]},"eswikiquote":{"site":"eswikiquote","title":"Homer
121
+ J. Simpson","badges":[]},"etwiki":{"site":"etwiki","title":"Homer Simpson","badges":[]},"euwiki":{"site":"euwiki","title":"Homer
122
+ Simpson","badges":[]},"fawiki":{"site":"fawiki","title":"\u0647\u0648\u0645\u0631
123
+ \u0633\u06cc\u0645\u067e\u0633\u0648\u0646","badges":[]},"fiwiki":{"site":"fiwiki","title":"Homer
124
+ Simpson","badges":[]},"fiwikiquote":{"site":"fiwikiquote","title":"Homer Simpson","badges":[]},"frwiki":{"site":"frwiki","title":"Homer
125
+ Simpson","badges":["Q17437798"]},"gawiki":{"site":"gawiki","title":"Homer
126
+ Simpson","badges":[]},"glwiki":{"site":"glwiki","title":"Homer Simpson","badges":[]},"gnwiki":{"site":"gnwiki","title":"Homer
127
+ Simpson","badges":[]},"hewiki":{"site":"hewiki","title":"\u05d4\u05d5\u05de\u05e8
128
+ \u05e1\u05d9\u05de\u05e4\u05e1\u05d5\u05df","badges":[]},"hewikiquote":{"site":"hewikiquote","title":"\u05d4\u05d5\u05de\u05e8
129
+ \u05e1\u05d9\u05de\u05e4\u05e1\u05d5\u05df","badges":[]},"hrwiki":{"site":"hrwiki","title":"Homer
130
+ Simpson","badges":[]},"huwiki":{"site":"huwiki","title":"Homer Simpson","badges":[]},"hywiki":{"site":"hywiki","title":"\u0540\u0578\u0574\u0565\u0580
131
+ \u054d\u056b\u0574\u057a\u057d\u0578\u0576","badges":[]},"idwiki":{"site":"idwiki","title":"Homer
132
+ Simpson","badges":[]},"iswiki":{"site":"iswiki","title":"H\u00f3mer Simpson","badges":[]},"itwiki":{"site":"itwiki","title":"Homer
133
+ Simpson","badges":["Q17437796"]},"itwikiquote":{"site":"itwikiquote","title":"Homer
134
+ Simpson","badges":[]},"jawiki":{"site":"jawiki","title":"\u30db\u30fc\u30de\u30fc\u30fb\u30b7\u30f3\u30d7\u30bd\u30f3","badges":[]},"kawiki":{"site":"kawiki","title":"\u10f0\u10dd\u10db\u10d4\u10e0
135
+ \u10e1\u10d8\u10db\u10de\u10e1\u10dd\u10dc\u10d8","badges":[]},"kowiki":{"site":"kowiki","title":"\ud638\uba38
136
+ \uc2ec\uc2a8","badges":[]},"lbwiki":{"site":"lbwiki","title":"Homer Simpson","badges":[]},"ltwiki":{"site":"ltwiki","title":"Homer
137
+ Simpson","badges":[]},"lvwiki":{"site":"lvwiki","title":"Hom\u0113rs Simpsons","badges":[]},"mrwiki":{"site":"mrwiki","title":"\u0939\u094b\u092e\u0930
138
+ \u0938\u093f\u092e\u094d\u092a\u094d\u0938\u0928","badges":[]},"nahwiki":{"site":"nahwiki","title":"Homer
139
+ Simpson","badges":[]},"newiki":{"site":"newiki","title":"\u0939\u094b\u092e\u0930
140
+ \u0938\u093f\u092e\u094d\u092a\u094d\u0938\u0928","badges":[]},"nlwiki":{"site":"nlwiki","title":"Homer
141
+ Simpson","badges":[]},"nowiki":{"site":"nowiki","title":"Homer Simpson","badges":[]},"nowikiquote":{"site":"nowikiquote","title":"Homer
142
+ Simpson","badges":[]},"ocwiki":{"site":"ocwiki","title":"Homer Simpson","badges":[]},"piwiki":{"site":"piwiki","title":"\u0939\u094b\u092e\u0930
143
+ \u0938\u093f\u092e\u094d\u092a\u094d\u0938\u0928","badges":[]},"plwiki":{"site":"plwiki","title":"Homer
144
+ Simpson","badges":[]},"plwikiquote":{"site":"plwikiquote","title":"Homer Simpson","badges":[]},"ptwiki":{"site":"ptwiki","title":"Homer
145
+ Simpson","badges":[]},"rowiki":{"site":"rowiki","title":"Homer Simpson","badges":[]},"ruwiki":{"site":"ruwiki","title":"\u0413\u043e\u043c\u0435\u0440
146
+ \u0421\u0438\u043c\u043f\u0441\u043e\u043d","badges":[]},"ruwikiquote":{"site":"ruwikiquote","title":"\u0413\u043e\u043c\u0435\u0440
147
+ \u0421\u0438\u043c\u043f\u0441\u043e\u043d","badges":[]},"sawiki":{"site":"sawiki","title":"\u0939\u094b\u092e\u0930
148
+ \u0938\u093f\u092e\u094d\u092a\u094d\u0938\u0928","badges":[]},"scnwiki":{"site":"scnwiki","title":"Homer
149
+ Simpson","badges":[]},"shwiki":{"site":"shwiki","title":"Homer Simpson","badges":[]},"simplewiki":{"site":"simplewiki","title":"Homer
150
+ Simpson","badges":[]},"skwiki":{"site":"skwiki","title":"Homer Simpson","badges":[]},"sqwiki":{"site":"sqwiki","title":"Homer
151
+ Simpson","badges":[]},"srwiki":{"site":"srwiki","title":"\u0425\u043e\u043c\u0435\u0440
152
+ \u040f\u0435\u0458 \u0421\u0438\u043c\u043f\u0441\u043e\u043d","badges":["Q17437798"]},"svwiki":{"site":"svwiki","title":"Homer
153
+ Simpson","badges":[]},"svwikiquote":{"site":"svwikiquote","title":"Homer Simpson","badges":[]},"thwiki":{"site":"thwiki","title":"\u0e42\u0e2e\u0e40\u0e21\u0e2d\u0e23\u0e4c
154
+ \u0e0b\u0e34\u0e21\u0e1b\u0e4c\u0e2a\u0e31\u0e19","badges":[]},"trwiki":{"site":"trwiki","title":"Homer
155
+ Simpson","badges":[]},"trwikiquote":{"site":"trwikiquote","title":"Homer Simpson","badges":[]},"ukwiki":{"site":"ukwiki","title":"\u0413\u043e\u043c\u0435\u0440
156
+ \u0421\u0456\u043c\u043f\u0441\u043e\u043d","badges":[]},"viwiki":{"site":"viwiki","title":"Homer
157
+ Simpson","badges":[]},"warwiki":{"site":"warwiki","title":"Homer Simpson","badges":[]},"zhwiki":{"site":"zhwiki","title":"\u970d\u9ed8\u00b7\u8f9b\u666e\u68ee","badges":["Q17437798"]}}}},"success":1}'
158
+ http_version:
159
+ recorded_at: Wed, 01 Oct 2014 15:12:16 GMT
160
+ recorded_with: VCR 2.9.3
@@ -0,0 +1,160 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: http://www.wikidata.org/w/api.php?action=wbgetentities&format=json&sites=enwiki&titles=Homer%20Simpson
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-Use-HHVM
31
+ X-Varnish:
32
+ - 2282079673, 3231260063, 1032008906
33
+ Via:
34
+ - 1.1 varnish, 1.1 varnish, 1.1 varnish
35
+ Transfer-Encoding:
36
+ - chunked
37
+ Date:
38
+ - Wed, 01 Oct 2014 15:08:43 GMT
39
+ Age:
40
+ - '0'
41
+ Connection:
42
+ - keep-alive
43
+ X-Cache:
44
+ - cp1068 miss (0), amssq48 miss (0), amssq54 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: '{"entities":{"Q7810":{"pageid":9056,"ns":0,"title":"Q7810","lastrevid":159661784,"modified":"2014-09-25T12:26:51Z","id":"Q7810","type":"item","aliases":{"de":[{"language":"de","value":"Homer
52
+ J. Simpsons"},{"language":"de","value":"Homer Jay Simpson"},{"language":"de","value":"Captain
53
+ Albern"},{"language":"de","value":"Max Power"},{"language":"de","value":"Dancin\u2019
54
+ Homer"},{"language":"de","value":"Andreas T. aus Happyhill"},{"language":"de","value":"Colonel
55
+ Homer"},{"language":"de","value":"Mr. Schneepflug"},{"language":"de","value":"Brian
56
+ McGee"},{"language":"de","value":"Mr. Thompson"},{"language":"de","value":"der
57
+ Bierbaron"},{"language":"de","value":"Arthur N. aus Rosenburg"},{"language":"de","value":"Mr.
58
+ X"},{"language":"de","value":"El Homo"},{"language":"de","value":"Elvis Jagger
59
+ Abdul-Jabbar"},{"language":"de","value":"Tortenmann"},{"language":"de","value":"Homer
60
+ Sanchez"},{"language":"de","value":"Homie"},{"language":"de","value":"Admiral
61
+ Adonis"},{"language":"de","value":"Commander Cool"}],"en":[{"language":"en","value":"Homer
62
+ Jay Simpson"}],"it":[{"language":"it","value":"Homer J. Simpson"}]},"labels":{"it":{"language":"it","value":"Homer
63
+ Simpson"},"fr":{"language":"fr","value":"Homer Simpson"},"en":{"language":"en","value":"Homer
64
+ Simpson"},"de":{"language":"de","value":"Homer Simpson"},"af":{"language":"af","value":"Homer
65
+ Simpson"},"ast":{"language":"ast","value":"Homer Simpson"},"az":{"language":"az","value":"Homer
66
+ Simpson"},"bar":{"language":"bar","value":"Homer Simpson"},"be":{"language":"be","value":"\u0413\u0430\u043c\u0435\u0440
67
+ \u0421\u0456\u043c\u043f\u0441\u0430\u043d"},"bg":{"language":"bg","value":"\u0425\u043e\u0443\u043c\u044a\u0440
68
+ \u0421\u0438\u043c\u043f\u0441\u044a\u043d"},"bo":{"language":"bo","value":"\u0f67\u0f7c\u0f60\u0f7c\u0f0b\u0f58\u0f62\u0f0b\u0f66\u0f72\u0f58\u0f0b\u0f56\u0f74\u0f0b\u0f66\u0f53\u0f0d"},"bs":{"language":"bs","value":"Homer
69
+ Simpson"},"ca":{"language":"ca","value":"Homer Simpson"},"cs":{"language":"cs","value":"Homer
70
+ Simpson"},"cy":{"language":"cy","value":"Homer Simpson"},"da":{"language":"da","value":"Homer
71
+ Simpson"},"en-ca":{"language":"en-ca","value":"Homer Simpson"},"en-gb":{"language":"en-gb","value":"Homer
72
+ Simpson"},"es":{"language":"es","value":"Homer Simpson"},"et":{"language":"et","value":"Homer
73
+ Simpson"},"eu":{"language":"eu","value":"Homer Simpson"},"fa":{"language":"fa","value":"\u0647\u0648\u0645\u0631
74
+ \u0633\u06cc\u0645\u067e\u0633\u0648\u0646"},"fi":{"language":"fi","value":"Homer
75
+ Simpson"},"ga":{"language":"ga","value":"Homer Simpson"},"gl":{"language":"gl","value":"Homer
76
+ Simpson"},"he":{"language":"he","value":"\u05d4\u05d5\u05de\u05e8 \u05e1\u05d9\u05de\u05e4\u05e1\u05d5\u05df"},"hr":{"language":"hr","value":"Homer
77
+ Simpson"},"hu":{"language":"hu","value":"Homer Simpson"},"hy":{"language":"hy","value":"\u0540\u0578\u0574\u0565\u0580
78
+ \u054d\u056b\u0574\u057a\u057d\u0578\u0576"},"id":{"language":"id","value":"Homer
79
+ Simpson"},"is":{"language":"is","value":"H\u00f3mer Simpson"},"ja":{"language":"ja","value":"\u30db\u30fc\u30de\u30fc\u30fb\u30b7\u30f3\u30d7\u30bd\u30f3"},"ka":{"language":"ka","value":"\u10f0\u10dd\u10db\u10d4\u10e0
80
+ \u10e1\u10d8\u10db\u10de\u10e1\u10dd\u10dc\u10d8"},"ko":{"language":"ko","value":"\ud638\uba38
81
+ \uc2ec\uc2a8"},"lb":{"language":"lb","value":"Homer Simpson"},"lv":{"language":"lv","value":"Hom\u0113rs
82
+ Simpsons"},"mr":{"language":"mr","value":"\u0939\u094b\u092e\u0930 \u0938\u093f\u092e\u094d\u092a\u094d\u0938\u0928"},"nah":{"language":"nah","value":"Homer
83
+ Simpson"},"ne":{"language":"ne","value":"\u0939\u094b\u092e\u0930 \u0938\u093f\u092e\u094d\u092a\u094d\u0938\u0928"},"nl":{"language":"nl","value":"Homer
84
+ Simpson"},"oc":{"language":"oc","value":"Homer Simpson"},"pi":{"language":"pi","value":"\u0939\u094b\u092e\u0930
85
+ \u0938\u093f\u092e\u094d\u092a\u094d\u0938\u0928"},"pl":{"language":"pl","value":"Homer
86
+ Simpson"},"pt":{"language":"pt","value":"Homer Simpson"},"pt-br":{"language":"pt-br","value":"Homer
87
+ Simpson"},"ro":{"language":"ro","value":"Homer Simpson"},"ru":{"language":"ru","value":"\u0413\u043e\u043c\u0435\u0440
88
+ \u0421\u0438\u043c\u043f\u0441\u043e\u043d"},"sa":{"language":"sa","value":"\u0939\u094b\u092e\u0930
89
+ \u0938\u093f\u092e\u094d\u092a\u094d\u0938\u0928"},"scn":{"language":"scn","value":"Homer
90
+ Simpson"},"sh":{"language":"sh","value":"Homer Simpson"},"sk":{"language":"sk","value":"Homer
91
+ Simpson"},"sq":{"language":"sq","value":"Homer Simpson"},"sr":{"language":"sr","value":"\u0425\u043e\u043c\u0435\u0440
92
+ \u040f\u0435\u0458 \u0421\u0438\u043c\u043f\u0441\u043e\u043d"},"sv":{"language":"sv","value":"Homer
93
+ Simpson"},"th":{"language":"th","value":"\u0e42\u0e2e\u0e40\u0e21\u0e2d\u0e23\u0e4c
94
+ \u0e0b\u0e34\u0e21\u0e1b\u0e4c\u0e2a\u0e31\u0e19"},"tr":{"language":"tr","value":"Homer
95
+ Simpson"},"uk":{"language":"uk","value":"\u0413\u043e\u043c\u0435\u0440 \u0421\u0456\u043c\u043f\u0441\u043e\u043d"},"vi":{"language":"vi","value":"Homer
96
+ Simpson"},"war":{"language":"war","value":"Homer Simpson"},"zh":{"language":"zh","value":"\u970d\u9ed8\u00b7\u8f9b\u666e\u68ee"},"gn":{"language":"gn","value":"Homer
97
+ Simpson"},"lt":{"language":"lt","value":"Homer Simpson"},"nb":{"language":"nb","value":"Homer
98
+ Simpson"},"ar":{"language":"ar","value":"\u0647\u0648\u0645\u0631 \u0633\u064a\u0645\u0628\u0633\u0648\u0646"},"ckb":{"language":"ckb","value":"\u06be\u06c6\u0645\u06d5\u0631
99
+ \u0633\u06cc\u0645\u067e\u0633\u06c6\u0646"},"nn":{"language":"nn","value":"Homer
100
+ Simpson"},"eo":{"language":"eo","value":"Homer Simpson"}},"descriptions":{"it":{"language":"it","value":"protagonista
101
+ della serie I Simpson"},"de":{"language":"de","value":"Figur der Simpsons"},"ru":{"language":"ru","value":"\u0433\u043b\u0430\u0432\u043d\u044b\u0439
102
+ \u0433\u0435\u0440\u043e\u0439 \u043c\u0443\u043b\u044c\u0442\u0441\u0435\u0440\u0438\u0430\u043b\u0430
103
+ \u00ab\u0421\u0438\u043c\u043f\u0441\u043e\u043d\u044b\u00bb"},"es":{"language":"es","value":"personaje
104
+ de dibujos animados"},"en":{"language":"en","value":"fictional character from
105
+ The Simpsons franchise"},"fr":{"language":"fr","value":"personnage de la s\u00e9rie
106
+ t\u00e9l\u00e9vis\u00e9e Les Simpson"},"nl":{"language":"nl","value":"personage
107
+ uit The Simpsons"}},"claims":{"P7":[{"id":"Q7810$2eb0aa51-40cb-3312-5b5d-777a34b3be23","mainsnak":{"snaktype":"value","property":"P7","datatype":"wikibase-item","datavalue":{"value":{"entity-type":"item","numeric-id":2340973},"type":"wikibase-entityid"}},"type":"statement","rank":"normal"}],"P345":[{"id":"q7810$D52517F8-64C0-498F-BD1F-2665DADE3A34","mainsnak":{"snaktype":"value","property":"P345","datatype":"string","datavalue":{"value":"ch0003002","type":"string"}},"type":"statement","rank":"preferred"}],"P26":[{"id":"q7810$7A080AE2-BE0B-4D9E-8B8C-6C1D5FD5C838","mainsnak":{"snaktype":"value","property":"P26","datatype":"wikibase-item","datavalue":{"value":{"entity-type":"item","numeric-id":7828},"type":"wikibase-entityid"}},"type":"statement","rank":"normal"}],"P21":[{"id":"q7810$EBCB4B01-C592-44E7-9DB8-F090E62074E2","mainsnak":{"snaktype":"value","property":"P21","datatype":"wikibase-item","datavalue":{"value":{"entity-type":"item","numeric-id":6581097},"type":"wikibase-entityid"}},"type":"statement","rank":"normal"}],"P40":[{"id":"q7810$2B9F1E2C-7583-4DD8-8CEB-F367FC0641E1","mainsnak":{"snaktype":"value","property":"P40","datatype":"wikibase-item","datavalue":{"value":{"entity-type":"item","numeric-id":5480},"type":"wikibase-entityid"}},"type":"statement","rank":"normal"},{"id":"q7810$A6DC727E-3642-470C-BD93-6707640CD90C","mainsnak":{"snaktype":"value","property":"P40","datatype":"wikibase-item","datavalue":{"value":{"entity-type":"item","numeric-id":5846},"type":"wikibase-entityid"}},"type":"statement","rank":"normal"},{"id":"q7810$E580F297-F30A-4680-BA5C-3559041E3B0F","mainsnak":{"snaktype":"value","property":"P40","datatype":"wikibase-item","datavalue":{"value":{"entity-type":"item","numeric-id":7834},"type":"wikibase-entityid"}},"type":"statement","rank":"normal"}],"P22":[{"id":"q7810$571A84C2-93C0-48E3-8DD3-A92A7D57BEA9","mainsnak":{"snaktype":"value","property":"P22","datatype":"wikibase-item","datavalue":{"value":{"entity-type":"item","numeric-id":842104},"type":"wikibase-entityid"}},"type":"statement","rank":"normal"}],"P25":[{"id":"q7810$46038435-4D85-46AB-90CE-5555ACD71760","mainsnak":{"snaktype":"value","property":"P25","datatype":"wikibase-item","datavalue":{"value":{"entity-type":"item","numeric-id":1641818},"type":"wikibase-entityid"}},"type":"statement","rank":"normal"}],"P19":[{"id":"q7810$F3E8C187-B8F2-4096-B15E-C4168F90CE42","mainsnak":{"snaktype":"value","property":"P19","datatype":"wikibase-item","datavalue":{"value":{"entity-type":"item","numeric-id":151076},"type":"wikibase-entityid"}},"type":"statement","rank":"normal"}],"P434":[{"id":"q7810$7604e6cb-443a-65f9-2ab3-70db024360af","mainsnak":{"snaktype":"value","property":"P434","datatype":"string","datavalue":{"value":"109a53ec-73e7-44e8-81cd-484114849a02","type":"string"}},"type":"statement","rank":"normal"}],"P373":[{"id":"q7810$1511B4E7-E94C-45FA-8DF5-07616B0B2A86","mainsnak":{"snaktype":"novalue","property":"P373"},"type":"statement","rank":"normal"}],"P27":[{"id":"Q7810$3C8AEBB8-9F14-4E4C-B386-FFAFBDBC9F46","mainsnak":{"snaktype":"value","property":"P27","datatype":"wikibase-item","datavalue":{"value":{"entity-type":"item","numeric-id":30},"type":"wikibase-entityid"}},"type":"statement","rank":"normal"}],"P646":[{"id":"Q7810$8F38CA22-CBE7-45D0-A02D-B2D5950B6648","mainsnak":{"snaktype":"value","property":"P646","datatype":"string","datavalue":{"value":"/m/0h545","type":"string"}},"type":"statement","rank":"normal","references":[{"hash":"b923b0d68beb300866b87ead39f61e63ec30d8af","snaks":{"P248":[{"snaktype":"value","property":"P248","datatype":"wikibase-item","datavalue":{"value":{"entity-type":"item","numeric-id":15241312},"type":"wikibase-entityid"}}],"P577":[{"snaktype":"value","property":"P577","datatype":"time","datavalue":{"value":{"time":"+00000002013-10-28T00:00:00Z","timezone":0,"before":0,"after":0,"precision":11,"calendarmodel":"http://www.wikidata.org/entity/Q1985727"},"type":"time"}}]},"snaks-order":["P248","P577"]}]}],"P569":[{"id":"Q7810$B87E9E15-38ED-4A83-B7A5-0EA872EC98EE","mainsnak":{"snaktype":"value","property":"P569","datatype":"time","datavalue":{"value":{"time":"+00000001956-06-18T00:00:00Z","timezone":0,"before":0,"after":0,"precision":11,"calendarmodel":"http://www.wikidata.org/entity/Q1985727"},"type":"time"}},"type":"statement","rank":"normal"}],"P31":[{"id":"Q7810$ae77588c-491b-63c1-7bc0-3f902811f72a","mainsnak":{"snaktype":"value","property":"P31","datatype":"wikibase-item","datavalue":{"value":{"entity-type":"item","numeric-id":15632617},"type":"wikibase-entityid"}},"type":"statement","rank":"normal"}],"P1441":[{"id":"Q7810$0B70914E-EA32-4B54-AF9F-08CA8716557C","mainsnak":{"snaktype":"value","property":"P1441","datatype":"wikibase-item","datavalue":{"value":{"entity-type":"item","numeric-id":886},"type":"wikibase-entityid"}},"type":"statement","rank":"normal"}]},"sitelinks":{"afwiki":{"site":"afwiki","title":"Homer
108
+ Simpson","badges":[]},"arwiki":{"site":"arwiki","title":"\u0647\u0648\u0645\u0631
109
+ \u0633\u064a\u0645\u0628\u0633\u0648\u0646","badges":[]},"astwiki":{"site":"astwiki","title":"Homer
110
+ Simpson","badges":[]},"azwiki":{"site":"azwiki","title":"Homer Simpson","badges":[]},"azwikiquote":{"site":"azwikiquote","title":"Homer
111
+ Simpson","badges":[]},"barwiki":{"site":"barwiki","title":"Homer Simpson","badges":[]},"bewiki":{"site":"bewiki","title":"\u0413\u0430\u043c\u0435\u0440
112
+ \u0421\u0456\u043c\u043f\u0441\u0430\u043d","badges":[]},"bgwiki":{"site":"bgwiki","title":"\u0425\u043e\u0443\u043c\u044a\u0440
113
+ \u0421\u0438\u043c\u043f\u0441\u044a\u043d","badges":[]},"bowiki":{"site":"bowiki","title":"\u0f67\u0f7c\u0f60\u0f7c\u0f0b\u0f58\u0f62\u0f0b\u0f66\u0f72\u0f58\u0f0b\u0f56\u0f74\u0f0b\u0f66\u0f53\u0f0d","badges":[]},"bswiki":{"site":"bswiki","title":"Homer
114
+ Simpson","badges":[]},"bswikiquote":{"site":"bswikiquote","title":"Homer Simpson","badges":[]},"cawiki":{"site":"cawiki","title":"Homer
115
+ Simpson","badges":[]},"ckbwiki":{"site":"ckbwiki","title":"\u06be\u06c6\u0645\u06d5\u0631
116
+ \u0633\u06cc\u0645\u067e\u0633\u06c6\u0646","badges":[]},"cswiki":{"site":"cswiki","title":"Homer
117
+ Simpson","badges":[]},"cywiki":{"site":"cywiki","title":"Homer Simpson","badges":[]},"dawiki":{"site":"dawiki","title":"Homer
118
+ Simpson","badges":[]},"dawikiquote":{"site":"dawikiquote","title":"Homer Simpson","badges":[]},"dewiki":{"site":"dewiki","title":"Homer
119
+ Simpson","badges":[]},"enwiki":{"site":"enwiki","title":"Homer Simpson","badges":["Q17437796"]},"eowikiquote":{"site":"eowikiquote","title":"Homer
120
+ Simpson","badges":[]},"eswiki":{"site":"eswiki","title":"Homer Simpson","badges":["Q17437796"]},"eswikiquote":{"site":"eswikiquote","title":"Homer
121
+ J. Simpson","badges":[]},"etwiki":{"site":"etwiki","title":"Homer Simpson","badges":[]},"euwiki":{"site":"euwiki","title":"Homer
122
+ Simpson","badges":[]},"fawiki":{"site":"fawiki","title":"\u0647\u0648\u0645\u0631
123
+ \u0633\u06cc\u0645\u067e\u0633\u0648\u0646","badges":[]},"fiwiki":{"site":"fiwiki","title":"Homer
124
+ Simpson","badges":[]},"fiwikiquote":{"site":"fiwikiquote","title":"Homer Simpson","badges":[]},"frwiki":{"site":"frwiki","title":"Homer
125
+ Simpson","badges":["Q17437798"]},"gawiki":{"site":"gawiki","title":"Homer
126
+ Simpson","badges":[]},"glwiki":{"site":"glwiki","title":"Homer Simpson","badges":[]},"gnwiki":{"site":"gnwiki","title":"Homer
127
+ Simpson","badges":[]},"hewiki":{"site":"hewiki","title":"\u05d4\u05d5\u05de\u05e8
128
+ \u05e1\u05d9\u05de\u05e4\u05e1\u05d5\u05df","badges":[]},"hewikiquote":{"site":"hewikiquote","title":"\u05d4\u05d5\u05de\u05e8
129
+ \u05e1\u05d9\u05de\u05e4\u05e1\u05d5\u05df","badges":[]},"hrwiki":{"site":"hrwiki","title":"Homer
130
+ Simpson","badges":[]},"huwiki":{"site":"huwiki","title":"Homer Simpson","badges":[]},"hywiki":{"site":"hywiki","title":"\u0540\u0578\u0574\u0565\u0580
131
+ \u054d\u056b\u0574\u057a\u057d\u0578\u0576","badges":[]},"idwiki":{"site":"idwiki","title":"Homer
132
+ Simpson","badges":[]},"iswiki":{"site":"iswiki","title":"H\u00f3mer Simpson","badges":[]},"itwiki":{"site":"itwiki","title":"Homer
133
+ Simpson","badges":["Q17437796"]},"itwikiquote":{"site":"itwikiquote","title":"Homer
134
+ Simpson","badges":[]},"jawiki":{"site":"jawiki","title":"\u30db\u30fc\u30de\u30fc\u30fb\u30b7\u30f3\u30d7\u30bd\u30f3","badges":[]},"kawiki":{"site":"kawiki","title":"\u10f0\u10dd\u10db\u10d4\u10e0
135
+ \u10e1\u10d8\u10db\u10de\u10e1\u10dd\u10dc\u10d8","badges":[]},"kowiki":{"site":"kowiki","title":"\ud638\uba38
136
+ \uc2ec\uc2a8","badges":[]},"lbwiki":{"site":"lbwiki","title":"Homer Simpson","badges":[]},"ltwiki":{"site":"ltwiki","title":"Homer
137
+ Simpson","badges":[]},"lvwiki":{"site":"lvwiki","title":"Hom\u0113rs Simpsons","badges":[]},"mrwiki":{"site":"mrwiki","title":"\u0939\u094b\u092e\u0930
138
+ \u0938\u093f\u092e\u094d\u092a\u094d\u0938\u0928","badges":[]},"nahwiki":{"site":"nahwiki","title":"Homer
139
+ Simpson","badges":[]},"newiki":{"site":"newiki","title":"\u0939\u094b\u092e\u0930
140
+ \u0938\u093f\u092e\u094d\u092a\u094d\u0938\u0928","badges":[]},"nlwiki":{"site":"nlwiki","title":"Homer
141
+ Simpson","badges":[]},"nowiki":{"site":"nowiki","title":"Homer Simpson","badges":[]},"nowikiquote":{"site":"nowikiquote","title":"Homer
142
+ Simpson","badges":[]},"ocwiki":{"site":"ocwiki","title":"Homer Simpson","badges":[]},"piwiki":{"site":"piwiki","title":"\u0939\u094b\u092e\u0930
143
+ \u0938\u093f\u092e\u094d\u092a\u094d\u0938\u0928","badges":[]},"plwiki":{"site":"plwiki","title":"Homer
144
+ Simpson","badges":[]},"plwikiquote":{"site":"plwikiquote","title":"Homer Simpson","badges":[]},"ptwiki":{"site":"ptwiki","title":"Homer
145
+ Simpson","badges":[]},"rowiki":{"site":"rowiki","title":"Homer Simpson","badges":[]},"ruwiki":{"site":"ruwiki","title":"\u0413\u043e\u043c\u0435\u0440
146
+ \u0421\u0438\u043c\u043f\u0441\u043e\u043d","badges":[]},"ruwikiquote":{"site":"ruwikiquote","title":"\u0413\u043e\u043c\u0435\u0440
147
+ \u0421\u0438\u043c\u043f\u0441\u043e\u043d","badges":[]},"sawiki":{"site":"sawiki","title":"\u0939\u094b\u092e\u0930
148
+ \u0938\u093f\u092e\u094d\u092a\u094d\u0938\u0928","badges":[]},"scnwiki":{"site":"scnwiki","title":"Homer
149
+ Simpson","badges":[]},"shwiki":{"site":"shwiki","title":"Homer Simpson","badges":[]},"simplewiki":{"site":"simplewiki","title":"Homer
150
+ Simpson","badges":[]},"skwiki":{"site":"skwiki","title":"Homer Simpson","badges":[]},"sqwiki":{"site":"sqwiki","title":"Homer
151
+ Simpson","badges":[]},"srwiki":{"site":"srwiki","title":"\u0425\u043e\u043c\u0435\u0440
152
+ \u040f\u0435\u0458 \u0421\u0438\u043c\u043f\u0441\u043e\u043d","badges":["Q17437798"]},"svwiki":{"site":"svwiki","title":"Homer
153
+ Simpson","badges":[]},"svwikiquote":{"site":"svwikiquote","title":"Homer Simpson","badges":[]},"thwiki":{"site":"thwiki","title":"\u0e42\u0e2e\u0e40\u0e21\u0e2d\u0e23\u0e4c
154
+ \u0e0b\u0e34\u0e21\u0e1b\u0e4c\u0e2a\u0e31\u0e19","badges":[]},"trwiki":{"site":"trwiki","title":"Homer
155
+ Simpson","badges":[]},"trwikiquote":{"site":"trwikiquote","title":"Homer Simpson","badges":[]},"ukwiki":{"site":"ukwiki","title":"\u0413\u043e\u043c\u0435\u0440
156
+ \u0421\u0456\u043c\u043f\u0441\u043e\u043d","badges":[]},"viwiki":{"site":"viwiki","title":"Homer
157
+ Simpson","badges":[]},"warwiki":{"site":"warwiki","title":"Homer Simpson","badges":[]},"zhwiki":{"site":"zhwiki","title":"\u970d\u9ed8\u00b7\u8f9b\u666e\u68ee","badges":["Q17437798"]}}}},"success":1}'
158
+ http_version:
159
+ recorded_at: Wed, 01 Oct 2014 15:08:43 GMT
160
+ recorded_with: VCR 2.9.3
@@ -117,6 +117,10 @@ describe Wikidata::Entity, :vcr do
117
117
  c.value.should eq '/m/0h545'
118
118
  end
119
119
  end
120
+
121
+ it 'should return a nil property_id if not an item' do
122
+ homer.property_id('P646').should be_nil
123
+ end
120
124
  end
121
125
 
122
126
  context 'of type url' do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: wikidata-client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kévin Lacointe
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-09-29 00:00:00.000000000 Z
11
+ date: 2014-10-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
@@ -162,7 +162,6 @@ files:
162
162
  - lib/wikidata/property/string.rb
163
163
  - lib/wikidata/property/time.rb
164
164
  - lib/wikidata/property/url.rb
165
- - lib/wikidata/resource.rb
166
165
  - lib/wikidata/response.rb
167
166
  - lib/wikidata/search_response.rb
168
167
  - lib/wikidata/version.rb
@@ -176,6 +175,8 @@ files:
176
175
  - spec/fixtures/vcr/Wikidata_Entity/properties/properties/of_type_globe_coordinate/should_return_GlobeCoordinate_from_a_property_id_P625_for_coordinate_location_here_.yml
177
176
  - spec/fixtures/vcr/Wikidata_Entity/properties/properties/of_type_string/should_return_String_from_a_key_freebase_identifier_here_.yml
178
177
  - spec/fixtures/vcr/Wikidata_Entity/properties/properties/of_type_string/should_return_String_from_a_property_id_P646_for_freebase_identifier_here_.yml
178
+ - spec/fixtures/vcr/Wikidata_Entity/properties/properties/of_type_string/should_return_a_nil_property_id_if_not_an_item.yml
179
+ - spec/fixtures/vcr/Wikidata_Entity/properties/properties/of_type_string/should_return_property_id.yml
179
180
  - spec/fixtures/vcr/Wikidata_Entity/properties/properties/of_type_url/should_return_Url_from_a_key_official_website_here_.yml
180
181
  - spec/fixtures/vcr/Wikidata_Entity/properties/properties/of_type_url/should_return_Url_from_a_property_id_P856_for_official_website_here_.yml
181
182
  - spec/fixtures/vcr/Wikidata_Entity/properties/should_return_aliases.yml
@@ -236,6 +237,8 @@ test_files:
236
237
  - spec/fixtures/vcr/Wikidata_Entity/properties/properties/of_type_globe_coordinate/should_return_GlobeCoordinate_from_a_property_id_P625_for_coordinate_location_here_.yml
237
238
  - spec/fixtures/vcr/Wikidata_Entity/properties/properties/of_type_string/should_return_String_from_a_key_freebase_identifier_here_.yml
238
239
  - spec/fixtures/vcr/Wikidata_Entity/properties/properties/of_type_string/should_return_String_from_a_property_id_P646_for_freebase_identifier_here_.yml
240
+ - spec/fixtures/vcr/Wikidata_Entity/properties/properties/of_type_string/should_return_a_nil_property_id_if_not_an_item.yml
241
+ - spec/fixtures/vcr/Wikidata_Entity/properties/properties/of_type_string/should_return_property_id.yml
239
242
  - spec/fixtures/vcr/Wikidata_Entity/properties/properties/of_type_url/should_return_Url_from_a_key_official_website_here_.yml
240
243
  - spec/fixtures/vcr/Wikidata_Entity/properties/properties/of_type_url/should_return_Url_from_a_property_id_P856_for_official_website_here_.yml
241
244
  - spec/fixtures/vcr/Wikidata_Entity/properties/should_return_aliases.yml
@@ -1,69 +0,0 @@
1
- module Wikidata
2
- class Resource
3
- attr_accessor :item
4
- delegate :claims_for_property_id, to: :item
5
-
6
- def initialize item
7
- return unless item.data_hash
8
- @item = item
9
- end
10
-
11
- def name
12
- return @_name if @_name
13
- %w{fr en}.each do |l|
14
- @_name ||= item.labels[l].value if item.data_hash[:labels] && item.labels[l]
15
- @_name ||= item.sitelinks["#{l}wiki"].title if item.data_hash[:sitelinks] && item.sitelinks["#{l}wiki"]
16
- end
17
- @_name
18
- end
19
-
20
- def url
21
- Gaston.wikidata.item_url.gsub(':id', item.id)
22
- end
23
-
24
- Gaston.wikidata.accessors.each do |k|
25
- define_method k do
26
- item.data_hash[k]
27
- end
28
- end
29
-
30
- Gaston.wikidata.mapping.resources.each do |k, code|
31
- define_method k do
32
- property code
33
- end
34
- define_method "#{k}_id" do
35
- property_id code
36
- end
37
- end
38
- Gaston.wikidata.mapping.collections.each do |k, code|
39
- define_method k do
40
- properties code
41
- end
42
- define_method "#{k}_ids" do
43
- property_ids code
44
- end
45
- end
46
-
47
- def properties code
48
- claims_for_property_id(code).map {|a| Wikidata::Attribute.build a }
49
- end
50
-
51
- def property code
52
- properties(code).first
53
- end
54
-
55
- def property_ids code
56
- claims_for_property_id(code).map do |a|
57
- begin
58
- "Q#{a.mainsnak.value.data_hash['numeric-id']}"
59
- rescue
60
- nil
61
- end
62
- end.compact
63
- end
64
-
65
- def property_id code
66
- property_ids(code).first
67
- end
68
- end
69
- end