europeana-api 0.3.1 → 0.3.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/europeana/api.rb +3 -0
- data/lib/europeana/api/request.rb +3 -2
- data/lib/europeana/api/search.rb +4 -0
- data/lib/europeana/api/search/fields.rb +108 -0
- data/lib/europeana/api/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 500f7c88f44dbde522ac372b0ae2c1fb476abf63
|
4
|
+
data.tar.gz: 34aa954f4695ea86ee8da7de5fac762583e421d1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 908669cc6589a3691015692c16288ebf0e653f8e6efa9e8cd380d2291ac6961dcab42a1a8cae596266dc4fb482586086f5c972d6bcc106db5b96d1f777dc1eb9
|
7
|
+
data.tar.gz: 0e45855f5af50ff70351a43f6fff753c2146136b1d615f07c59b5decfcdee0d1d15cc877b1e2a29916ca36764ff2bde661fa15c08ece65b2109585ad48160048
|
data/lib/europeana/api.rb
CHANGED
@@ -21,18 +21,19 @@ module Europeana
|
|
21
21
|
|
22
22
|
# @return (see Net::HTTP#request)
|
23
23
|
def execute
|
24
|
-
logger.info("Request URL: #{uri}")
|
25
|
-
|
26
24
|
benchmark("Request query", level: :info) do
|
27
25
|
http = Net::HTTP.new(uri.host, uri.port)
|
28
26
|
request = Net::HTTP::Get.new(uri.request_uri)
|
29
27
|
retries = Europeana::API.max_retries
|
30
28
|
|
31
29
|
begin
|
30
|
+
attempt = Europeana::API.max_retries - retries + 1
|
31
|
+
logger.info("Request URL: #{uri} (attempt ##{attempt})")
|
32
32
|
@response = http.request(request)
|
33
33
|
rescue Timeout::Error, Errno::ECONNREFUSED, EOFError
|
34
34
|
retries -= 1
|
35
35
|
raise unless retries > 0
|
36
|
+
logger.warn("Network error; sleeping #{Europeana::API.retry_delay}s")
|
36
37
|
sleep Europeana::API.retry_delay
|
37
38
|
retry
|
38
39
|
end
|
data/lib/europeana/api/search.rb
CHANGED
@@ -0,0 +1,108 @@
|
|
1
|
+
module Europeana
|
2
|
+
module API
|
3
|
+
class Search
|
4
|
+
##
|
5
|
+
# API field information and validation in search context
|
6
|
+
#
|
7
|
+
# @see http://labs.europeana.eu/api/data-fields/
|
8
|
+
module Fields
|
9
|
+
EDM_PROVIDED_CHO = %w(edm_europeana_proxy proxy_dc_contributor
|
10
|
+
proxy_dc_coverage proxy_dc_creator proxy_dc_date proxy_dc_description
|
11
|
+
proxy_dc_format proxy_dc_identifier proxy_dc_language
|
12
|
+
proxy_dc_publisher proxy_dc_relation proxy_dc_rights proxy_dc_source
|
13
|
+
proxy_dc_subject proxy_dc_title proxy_dc_type
|
14
|
+
proxy_dcterms_alternative proxy_dcterms_conformsTo
|
15
|
+
proxy_dcterms_created proxy_dcterms_extent proxy_dcterms_hasFormat
|
16
|
+
proxy_dcterms_hasPart proxy_dcterms_hasVersion
|
17
|
+
proxy_dcterms_isFormatOf proxy_dcterms_isPartOf
|
18
|
+
proxy_dcterms_isReferencedBy proxy_dcterms_isReplacedBy
|
19
|
+
proxy_dcterms_isRequiredBy proxy_dcterms_issued
|
20
|
+
proxy_dcterms_isVersionOf proxy_dcterms_medium
|
21
|
+
proxy_dcterms_provenance proxy_dcterms_references
|
22
|
+
proxy_dcterms_replaces proxy_dcterms_requires proxy_dcterms_spatial
|
23
|
+
proxy_dcterms_tableOfContents proxy_dcterms_temporal
|
24
|
+
proxy_edm_currentLocation proxy_edm_currentLocation_lat
|
25
|
+
proxy_edm_currentLocation_lon proxy_edm_hasMet proxy_edm_hasType
|
26
|
+
proxy_edm_incorporates proxy_edm_isDerivativeOf
|
27
|
+
proxy_edm_isNextInSequence proxy_edm_isRelatedTo
|
28
|
+
proxy_edm_isRepresentationOf proxy_edm_isSimilarTo
|
29
|
+
proxy_edm_isSuccessorOf proxy_edm_realizes proxy_edm_type
|
30
|
+
proxy_edm_unstored proxy_edm_wasPresentAt proxy_owl_sameAs
|
31
|
+
proxy_edm_rights proxy_edm_userTags proxy_edm_year proxy_ore_proxy
|
32
|
+
proxy_ore_proxyFor proxy_ore_proxyIn)
|
33
|
+
|
34
|
+
ORE_AGGREGATION = %w(provider_aggregation_ore_aggregation
|
35
|
+
provider_aggregation_ore_aggregates
|
36
|
+
provider_aggregation_edm_aggregatedCHO
|
37
|
+
provider_aggregation_edm_dataProvider
|
38
|
+
provider_aggregation_edm_hasView provider_aggregation_edm_isShownAt
|
39
|
+
provider_aggregation_edm_isShownBy provider_aggregation_edm_object
|
40
|
+
provider_aggregation_edm_provider provider_aggregation_dc_rights
|
41
|
+
provider_aggregation_edm_rights edm_UGC
|
42
|
+
provider_aggregation_edm_unstored edm_previewNoDistribute)
|
43
|
+
|
44
|
+
EDM_EUROPEANA_AGGREGATION = %w(edm_europeana_aggregation
|
45
|
+
europeana_aggregation_dc_creator europeana_aggregation_edm_country
|
46
|
+
europeana_aggregation_edm_hasView europeana_aggregation_edm_isShownBy
|
47
|
+
europeana_aggregation_edm_landingPage
|
48
|
+
europeana_aggregation_edm_language europeana_aggregation_edm_rights
|
49
|
+
europeana_aggregation_ore_aggregatedCHO
|
50
|
+
europeana_aggregation_ore_aggregates)
|
51
|
+
|
52
|
+
EDM_WEB_RESOURCE = %w(edm_webResource wr_dc_description wr_dc_format
|
53
|
+
wr_dc_rights wr_dc_source wr_dcterms_conformsTo wr_dcterms_created
|
54
|
+
wr_dcterms_extent wr_dcterms_hasPart wr_dcterms_isFormatOf
|
55
|
+
wr_dcterms_issued wr_edm_isNextInSequence wr_edm_rights)
|
56
|
+
|
57
|
+
EDM_AGENT = %w(edm_agent ag_skos_prefLabel ag_skos_altLabel
|
58
|
+
ag_skos_hiddenLabel ag_skos_note ag_dc_date ag_dc_identifier
|
59
|
+
ag_edm_begin ag_edm_end ag_edm_hasMet ag_edm_isRelatedTo
|
60
|
+
ag_edm_wasPresentAt ag_foaf_name ag_rdagr2_biographicalInformation
|
61
|
+
ag_rdagr2_dateOfBirth ag_rdagr2_dateOfDeath
|
62
|
+
ag_rdagr2_dateOfEstablishment ag_rdagr2_dateOfTermination
|
63
|
+
ag_rdagr2_gender ag_rdagr2_professionOrOccupation ag_owl_sameAs)
|
64
|
+
|
65
|
+
SKOS_CONCEPT = %w(skos_concept cc_skos_prefLabel cc_skos_altLabel
|
66
|
+
cc_skos_hiddenLabel cc_skos_broader cc_skos_broaderLabel
|
67
|
+
cc_skos_narrower cc_skos_related cc_skos_broadMatch
|
68
|
+
cc_skos_narrowMatch cc_skos_relatedMatch cc_skos_exactMatch
|
69
|
+
cc_skos_closeMatch cc_skos_note cc_skos_notation cc_skos_inScheme)
|
70
|
+
|
71
|
+
EDM_PLACE = %w(edm_place pl_wgs84_pos_lat pl_wgs84_pos_long
|
72
|
+
pl_wgs84_pos_alt pl_wgs84_pos_lat_long pl_skos_prefLabel
|
73
|
+
pl_skos_altLabel pl_skos_hiddenLabel pl_skos_note pl_dcterms_hasPart
|
74
|
+
pl_dcterms_isPartOf pl_owl_sameAs pl_dcterms_isPartOf_label)
|
75
|
+
|
76
|
+
EDM_TIME_SPAN = %w(edm_timespan ts_skos_prefLabel ts_skos_altLabel
|
77
|
+
ts_skos_hiddenLabel ts_skos_note ts_dcterms_hasPart
|
78
|
+
ts_dcterms_isPartOf ts_edm_begin ts_edm_end ts_owl_sameAs
|
79
|
+
ts_dcterms_isPartOf_label)
|
80
|
+
|
81
|
+
NON_EDM = %w(europeana_completeness europeana_previewNoDistribute
|
82
|
+
timestamp europeana_id identifier europeana_collectionName)
|
83
|
+
|
84
|
+
AGGREGATED = %w(country date description format language location
|
85
|
+
publisher relation rights source subject text title what when where
|
86
|
+
who)
|
87
|
+
|
88
|
+
FACETS = %w(COMPLETENESS CONTRIBUTOR COUNTRY DATA_PROVIDER LANGUAGE
|
89
|
+
LOCATION PROVIDER RIGHTS SUBJECT TYPE UGC USERTAGS YEAR)
|
90
|
+
|
91
|
+
AGGREGATED_FACETS = %w(DEFAULT)
|
92
|
+
|
93
|
+
##
|
94
|
+
# Tests whether the given field name is valid in the API search context
|
95
|
+
#
|
96
|
+
# @param name [String] field name
|
97
|
+
# @return [Boolean]
|
98
|
+
def self.include?(name)
|
99
|
+
constants.any? do |scope|
|
100
|
+
const_get(scope).any? do |field|
|
101
|
+
field == name
|
102
|
+
end
|
103
|
+
end
|
104
|
+
end
|
105
|
+
end
|
106
|
+
end
|
107
|
+
end
|
108
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: europeana-api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Richard Doe
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-05-
|
11
|
+
date: 2015-05-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -112,6 +112,7 @@ files:
|
|
112
112
|
- lib/europeana/api/record.rb
|
113
113
|
- lib/europeana/api/request.rb
|
114
114
|
- lib/europeana/api/search.rb
|
115
|
+
- lib/europeana/api/search/fields.rb
|
115
116
|
- lib/europeana/api/version.rb
|
116
117
|
- spec/europeana/errors_spec.rb
|
117
118
|
- spec/europeana/record_spec.rb
|