europeana-blacklight 1.2.2 → 1.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.ruby-style.yml +1 -1
- data/.travis.yml +4 -2
- data/Gemfile +2 -0
- data/Rakefile +3 -1
- data/app/controllers/concerns/europeana/blacklight/catalog.rb +4 -2
- data/app/controllers/concerns/europeana/blacklight/search_helper.rb +2 -0
- data/app/models/europeana/blacklight/document/lang_maps.rb +5 -3
- data/app/models/europeana/blacklight/document/more_like_this.rb +4 -2
- data/app/models/europeana/blacklight/document/relations.rb +6 -4
- data/app/models/europeana/blacklight/document.rb +7 -5
- data/app/presenters/europeana/blacklight/document_presenter.rb +3 -1
- data/europeana-blacklight.gemspec +3 -1
- data/lib/europeana/blacklight/engine.rb +2 -0
- data/lib/europeana/blacklight/repository.rb +2 -0
- data/lib/europeana/blacklight/response/facets.rb +10 -9
- data/lib/europeana/blacklight/response/more_like_this.rb +2 -0
- data/lib/europeana/blacklight/response/pagination.rb +2 -0
- data/lib/europeana/blacklight/response.rb +2 -16
- data/lib/europeana/blacklight/routes.rb +2 -0
- data/lib/europeana/blacklight/search_builder/facet_pagination.rb +9 -8
- data/lib/europeana/blacklight/search_builder/more_like_this.rb +3 -1
- data/lib/europeana/blacklight/search_builder/overlay_params.rb +7 -5
- data/lib/europeana/blacklight/search_builder/ranges.rb +2 -0
- data/lib/europeana/blacklight/search_builder.rb +19 -17
- data/lib/europeana/blacklight/version.rb +3 -1
- data/lib/europeana/blacklight.rb +2 -0
- data/lib/generators/europeana/blacklight/install_generator.rb +3 -1
- data/spec/dummy/Rakefile +3 -1
- data/spec/dummy/app/controllers/application_controller.rb +2 -0
- data/spec/dummy/app/helpers/application_helper.rb +2 -0
- data/spec/dummy/bin/bundle +3 -1
- data/spec/dummy/bin/rails +3 -1
- data/spec/dummy/bin/rake +2 -0
- data/spec/dummy/bin/setup +10 -8
- data/spec/dummy/config/application.rb +3 -1
- data/spec/dummy/config/boot.rb +4 -2
- data/spec/dummy/config/environment.rb +3 -1
- data/spec/dummy/config/environments/development.rb +2 -0
- data/spec/dummy/config/environments/production.rb +2 -0
- data/spec/dummy/config/environments/test.rb +2 -0
- data/spec/dummy/config/initializers/assets.rb +2 -0
- data/spec/dummy/config/initializers/backtrace_silencers.rb +2 -0
- data/spec/dummy/config/initializers/cookies_serializer.rb +2 -0
- data/spec/dummy/config/initializers/filter_parameter_logging.rb +2 -0
- data/spec/dummy/config/initializers/inflections.rb +2 -0
- data/spec/dummy/config/initializers/mime_types.rb +2 -0
- data/spec/dummy/config/initializers/session_store.rb +2 -0
- data/spec/dummy/config/initializers/wrap_parameters.rb +2 -0
- data/spec/dummy/config/routes.rb +2 -0
- data/spec/dummy/config.ru +2 -0
- data/spec/europeana/blacklight/repository_spec.rb +5 -3
- data/spec/europeana/blacklight/search_builder_spec.rb +2 -0
- data/spec/europeana/blacklight_spec.rb +2 -0
- data/spec/models/europeana/blacklight/document/lang_maps_spec.rb +2 -0
- data/spec/models/europeana/blacklight/document/more_like_this_spec.rb +2 -0
- data/spec/models/europeana/blacklight/document/relations_spec.rb +4 -2
- data/spec/models/europeana/blacklight/document_spec.rb +6 -4
- data/spec/presenters/europeana/blacklight/document_presenter_spec.rb +2 -0
- data/spec/spec_helper.rb +3 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: c4eb11c730a0cd1f642dcfc2da1cab5c3be8d352e39ce657100744e4d91cc5d9
|
4
|
+
data.tar.gz: 567559669e91097db14b419d12e10be276572d7d4cc680b46e1951b3d6281b5a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d52aef50b7a719866d43f07bccbb77692aa6648229ad2a91dfb24f5d31a9a03a2a90c20a2a4578d194121388f392cfcef11b03f86314844278115a7e0e9fdd0a
|
7
|
+
data.tar.gz: f52f8a7e8b539151f50f37456256e61a06c86e05b7c5dd4a49af7d1585ce08afd6a14f4382a2eb90d45495a5baf912a41038b8e6c0662ad3450e09ef10cc9541
|
data/.ruby-style.yml
CHANGED
@@ -3,7 +3,7 @@ AllCops:
|
|
3
3
|
- "vendor/**/*"
|
4
4
|
- "db/schema.rb"
|
5
5
|
UseCache: false
|
6
|
-
TargetRubyVersion: 2.
|
6
|
+
TargetRubyVersion: 2.5
|
7
7
|
Style/CollectionMethods:
|
8
8
|
Description: Preferred collection methods.
|
9
9
|
StyleGuide: https://github.com/bbatsov/ruby-style-guide#map-find-select-reduce-size
|
data/.travis.yml
CHANGED
@@ -3,14 +3,16 @@ rvm:
|
|
3
3
|
- 2.3
|
4
4
|
- 2.4
|
5
5
|
- 2.5
|
6
|
+
- 2.6
|
6
7
|
notifications:
|
7
8
|
email: false
|
8
9
|
sudo: false
|
9
10
|
cache:
|
10
11
|
bundler: true
|
12
|
+
# Downgrade bundler to 1.x <https://docs.travis-ci.com/user/languages/ruby/#bundler-20>
|
11
13
|
before_install:
|
12
|
-
- gem
|
13
|
-
- gem install bundler
|
14
|
+
- gem uninstall -v '>= 2' -i $(rvm gemdir)@global -ax bundler || true
|
15
|
+
- gem install bundler -v '< 2'
|
14
16
|
before_script:
|
15
17
|
- curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
|
16
18
|
- chmod +x ./cc-test-reporter
|
data/Gemfile
CHANGED
data/Rakefile
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Europeana
|
2
4
|
module Blacklight
|
3
5
|
module Catalog
|
@@ -61,8 +63,8 @@ module Europeana
|
|
61
63
|
|
62
64
|
def europeana_api_query_facet_count(query_field_fq, user_params)
|
63
65
|
query = search_builder_class.new(search_params_logic, self).
|
64
|
-
|
65
|
-
|
66
|
+
with(user_params).with_overlay_params(query_field_fq || {}).query.
|
67
|
+
merge(rows: 0, start: 1, profile: 'minimal')
|
66
68
|
repository.search(query).total
|
67
69
|
end
|
68
70
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Europeana
|
2
4
|
module Blacklight
|
3
5
|
class Document
|
@@ -6,12 +8,12 @@ module Europeana
|
|
6
8
|
# @see http://labs.europeana.eu/api/getting-started#datatypes
|
7
9
|
module LangMaps
|
8
10
|
# @see https://www.loc.gov/standards/iso639-2/php/code_changes.php
|
9
|
-
DEPRECATED_ISO_LANG_CODES = %w(in iw jaw ji jw mo mol scc scr sh)
|
11
|
+
DEPRECATED_ISO_LANG_CODES = %w(in iw jaw ji jw mo mol scc scr sh).freeze
|
10
12
|
|
11
13
|
# Special keys API may return in a LangMap, not ISO codes
|
12
14
|
# @todo Empty key acceptance is a workaround for malformed API data
|
13
15
|
# output; remove when fixed at source
|
14
|
-
NON_ISO_LANG_CODES = ['def', '']
|
16
|
+
NON_ISO_LANG_CODES = ['def', ''].freeze
|
15
17
|
|
16
18
|
# @todo Are three-letter language codes valid in EDM?
|
17
19
|
def lang_map?(obj)
|
@@ -75,7 +77,7 @@ module Europeana
|
|
75
77
|
|
76
78
|
# Any sub-code will do
|
77
79
|
lang_map.keys.select do |k|
|
78
|
-
k =~
|
80
|
+
k =~ /\A#{iso_code}-/
|
79
81
|
end.flatten.compact
|
80
82
|
end
|
81
83
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Europeana
|
2
4
|
module Blacklight
|
3
5
|
class Document
|
@@ -8,9 +10,9 @@ module Europeana
|
|
8
10
|
# @return [String]
|
9
11
|
def more_like_this_query(param = nil)
|
10
12
|
queries = more_like_this_field_queries(param)
|
11
|
-
return nil
|
13
|
+
return nil if queries.empty?
|
12
14
|
field_queries = queries.join(' OR ')
|
13
|
-
"(#{field_queries}) NOT europeana_id:\"#{
|
15
|
+
"(#{field_queries}) NOT europeana_id:\"#{id}\""
|
14
16
|
end
|
15
17
|
|
16
18
|
protected
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'active_support/core_ext/hash'
|
2
4
|
|
3
5
|
module Europeana
|
@@ -11,7 +13,7 @@ module Europeana
|
|
11
13
|
def fetch_through_relation(key, *default)
|
12
14
|
field = nested_field_key(key)
|
13
15
|
container = nested_field_container(key)
|
14
|
-
value = [container].flatten.compact.
|
16
|
+
value = [container].flatten.compact.map do |target|
|
15
17
|
target.fetch(field, *default)
|
16
18
|
end.compact.flatten
|
17
19
|
end
|
@@ -52,7 +54,7 @@ module Europeana
|
|
52
54
|
keys = split_edm_key(field)
|
53
55
|
field = keys.last
|
54
56
|
keys[0..-2].each do |relation_key|
|
55
|
-
container = [container].flatten.
|
57
|
+
container = [container].flatten.map { |d| d.send(relation_key.to_sym) }
|
56
58
|
end
|
57
59
|
end
|
58
60
|
container
|
@@ -104,8 +106,8 @@ module Europeana
|
|
104
106
|
end
|
105
107
|
|
106
108
|
def relation_keys
|
107
|
-
|
108
|
-
|
109
|
+
%i(agents aggregations concepts europeanaAggregation licenses
|
110
|
+
places providedCHOs proxies timespans webResources)
|
109
111
|
end
|
110
112
|
end
|
111
113
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'active_model'
|
2
4
|
require 'iso-639'
|
3
5
|
|
@@ -37,11 +39,11 @@ module Europeana
|
|
37
39
|
|
38
40
|
def fetch(key, *default)
|
39
41
|
value = if has_relation?(key)
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
42
|
+
relations[key]
|
43
|
+
elsif field_in_relation?(key)
|
44
|
+
fetch_through_relation(key, *default)
|
45
|
+
else
|
46
|
+
super
|
45
47
|
end
|
46
48
|
localize_lang_map(value)
|
47
49
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Europeana
|
2
4
|
module Blacklight
|
3
5
|
##
|
@@ -19,7 +21,7 @@ module Europeana
|
|
19
21
|
|
20
22
|
field_config = @configuration.send(:"#{context}_fields")[key]
|
21
23
|
value = options[:value] || begin
|
22
|
-
[container].flatten.compact.
|
24
|
+
[container].flatten.compact.map do |target|
|
23
25
|
presenter = self.class.new(target, @controller, @configuration)
|
24
26
|
presenter.get_field_values(key, field_config, options)
|
25
27
|
end.compact.flatten
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Europeana
|
2
4
|
module Blacklight
|
3
5
|
class Response
|
@@ -37,7 +39,8 @@ module Europeana
|
|
37
39
|
attr_reader :name, :items
|
38
40
|
|
39
41
|
def initialize(name, items, options = {})
|
40
|
-
@name
|
42
|
+
@name = name
|
43
|
+
@items = items
|
41
44
|
@options = options
|
42
45
|
end
|
43
46
|
|
@@ -50,8 +53,7 @@ module Europeana
|
|
50
53
|
end
|
51
54
|
|
52
55
|
# Expected by {Blacklight::Facet#facet_paginator}
|
53
|
-
def prefix
|
54
|
-
end
|
56
|
+
def prefix; end
|
55
57
|
|
56
58
|
def sort
|
57
59
|
# Europeana API does not support facet sorting
|
@@ -92,7 +94,7 @@ module Europeana
|
|
92
94
|
facet_fields.each_with_object({}) do |facet, hash|
|
93
95
|
facet_field_name = facet['name']
|
94
96
|
|
95
|
-
items = facet['fields'].
|
97
|
+
items = facet['fields'].map do |value|
|
96
98
|
FacetItem.new(value: value['label'], hits: value['count'])
|
97
99
|
end
|
98
100
|
|
@@ -104,11 +106,10 @@ module Europeana
|
|
104
106
|
|
105
107
|
hash[facet_field_name] = FacetField.new(facet_field_name, items, facet_field_aggregation_options(facet_field_name))
|
106
108
|
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
end
|
109
|
+
next unless blacklight_config && !blacklight_config.facet_fields[facet_field_name]
|
110
|
+
# alias all the possible blacklight config names..
|
111
|
+
blacklight_config.facet_fields.select { |_k, v| v.field == facet_field_name }.each do |key, _|
|
112
|
+
hash[key] = hash[facet_field_name]
|
112
113
|
end
|
113
114
|
end
|
114
115
|
end
|
@@ -17,7 +17,7 @@ module Europeana
|
|
17
17
|
attr_accessor :document_model, :blacklight_config
|
18
18
|
|
19
19
|
def initialize(data, request_params, options = {})
|
20
|
-
super(
|
20
|
+
super(data)
|
21
21
|
@request_params = request_params
|
22
22
|
self.document_model = options[:document_model] || Document
|
23
23
|
self.blacklight_config = options[:blacklight_config]
|
@@ -41,7 +41,7 @@ module Europeana
|
|
41
41
|
end
|
42
42
|
|
43
43
|
def documents
|
44
|
-
@documents ||= (
|
44
|
+
@documents ||= (key?('object') ? [self['object']] : (self['items'] || [])).map do |doc|
|
45
45
|
document_model.new(doc, self)
|
46
46
|
end
|
47
47
|
end
|
@@ -74,20 +74,6 @@ module Europeana
|
|
74
74
|
def empty?
|
75
75
|
total == 0
|
76
76
|
end
|
77
|
-
|
78
|
-
private
|
79
|
-
|
80
|
-
def force_to_utf8(value)
|
81
|
-
case value
|
82
|
-
when Hash
|
83
|
-
value.each { |k, v| value[k] = force_to_utf8(v) }
|
84
|
-
when Array
|
85
|
-
value.each { |v| force_to_utf8(v) }
|
86
|
-
when String
|
87
|
-
String.new(value).force_encoding('utf-8') if value.respond_to?(:force_encoding)
|
88
|
-
end
|
89
|
-
value
|
90
|
-
end
|
91
77
|
end
|
92
78
|
end
|
93
79
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Europeana
|
2
4
|
module Blacklight
|
3
5
|
class SearchBuilder
|
@@ -9,21 +11,21 @@ module Europeana
|
|
9
11
|
included do
|
10
12
|
default_processor_chain << :add_facet_paging_to_api
|
11
13
|
end
|
12
|
-
|
14
|
+
|
13
15
|
def add_facet_paging_to_api(api_parameters)
|
14
16
|
return unless facet.present?
|
15
17
|
|
16
18
|
facet_config = blacklight_config.facet_fields[facet]
|
17
19
|
|
18
20
|
limit = if scope.respond_to?(:facet_list_limit)
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
21
|
+
scope.facet_list_limit.to_s.to_i
|
22
|
+
elsif api_parameters['facet.limit']
|
23
|
+
api_parameters['facet.limit'].to_i
|
24
|
+
else
|
25
|
+
20
|
24
26
|
end
|
25
27
|
|
26
|
-
offset = (blacklight_params.fetch(blacklight_config.facet_paginator_class.request_keys[:page], 1).to_i - 1) *
|
28
|
+
offset = (blacklight_params.fetch(blacklight_config.facet_paginator_class.request_keys[:page], 1).to_i - 1) * limit
|
27
29
|
|
28
30
|
# Need to set as f.facet_field.facet.* to make sure we
|
29
31
|
# override any field-specific default in the solr request handler.
|
@@ -35,4 +37,3 @@ module Europeana
|
|
35
37
|
end
|
36
38
|
end
|
37
39
|
end
|
38
|
-
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Europeana
|
2
4
|
module Blacklight
|
3
5
|
class SearchBuilder
|
@@ -9,7 +11,7 @@ module Europeana
|
|
9
11
|
included do
|
10
12
|
default_processor_chain.unshift :add_mlt_to_api
|
11
13
|
end
|
12
|
-
|
14
|
+
|
13
15
|
def add_mlt_to_api(api_parameters)
|
14
16
|
return unless blacklight_params[:mlt]
|
15
17
|
repository = blacklight_config.repository_class.new(blacklight_config)
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Europeana
|
2
4
|
module Blacklight
|
3
5
|
class SearchBuilder
|
@@ -23,11 +25,11 @@ module Europeana
|
|
23
25
|
@overlay_params.each do |param_set|
|
24
26
|
param_set.each_pair do |k, v|
|
25
27
|
k = k.to_sym
|
26
|
-
if api_parameters.key?(k)
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
28
|
+
api_parameters[k] = if api_parameters.key?(k)
|
29
|
+
[api_parameters[k]].flatten # in case it's not an Array
|
30
|
+
else
|
31
|
+
[]
|
32
|
+
end
|
31
33
|
api_parameters[k] += [v]
|
32
34
|
api_parameters[k] = api_parameters[k].flatten.uniq
|
33
35
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Europeana
|
2
4
|
module Blacklight
|
3
5
|
##
|
@@ -8,12 +10,12 @@ module Europeana
|
|
8
10
|
require 'europeana/blacklight/search_builder/overlay_params'
|
9
11
|
require 'europeana/blacklight/search_builder/ranges'
|
10
12
|
|
11
|
-
self.default_processor_chain =
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
13
|
+
self.default_processor_chain = %i(
|
14
|
+
default_api_parameters add_profile_to_api
|
15
|
+
add_query_to_api add_qf_to_api add_facet_qf_to_api add_query_facet_to_api
|
16
|
+
add_standalone_facets_to_api add_facetting_to_api add_paging_to_api
|
17
|
+
add_sorting_to_api add_api_url_to_api
|
18
|
+
)
|
17
19
|
|
18
20
|
include FacetPagination
|
19
21
|
include MoreLikeThis
|
@@ -36,13 +38,13 @@ module Europeana
|
|
36
38
|
# @todo Rename default_solr_params to default_params upstream
|
37
39
|
def default_api_parameters(api_parameters)
|
38
40
|
blacklight_config.default_solr_params.each do |key, value|
|
39
|
-
if value.respond_to?(:deep_dup)
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
41
|
+
api_parameters[key] = if value.respond_to?(:deep_dup)
|
42
|
+
value.deep_dup
|
43
|
+
elsif value.respond_to?(:dup) && value.duplicable?
|
44
|
+
value.dup
|
45
|
+
else
|
46
|
+
value
|
47
|
+
end
|
46
48
|
end
|
47
49
|
end
|
48
50
|
|
@@ -52,7 +54,7 @@ module Europeana
|
|
52
54
|
# @see http://labs.europeana.eu/api/search/#profile-parameter
|
53
55
|
def add_profile_to_api(api_parameters)
|
54
56
|
api_parameters[:profile] = 'params rich'
|
55
|
-
api_parameters[:profile]
|
57
|
+
api_parameters[:profile] = api_parameters[:profile] + ' facets' if blacklight_config.facet_fields
|
56
58
|
end
|
57
59
|
|
58
60
|
##
|
@@ -211,7 +213,7 @@ module Europeana
|
|
211
213
|
end
|
212
214
|
|
213
215
|
def api_request_facet_fields
|
214
|
-
@api_request_facet_fields ||= blacklight_config.facet_fields.select do |
|
216
|
+
@api_request_facet_fields ||= blacklight_config.facet_fields.select do |_field_name, facet|
|
215
217
|
requestable_facet?(facet)
|
216
218
|
end
|
217
219
|
end
|
@@ -230,8 +232,8 @@ module Europeana
|
|
230
232
|
return if query.blank?
|
231
233
|
return if query == '*:*' && api_parameters[:query].present?
|
232
234
|
api_parameters[:query] ||= ''
|
233
|
-
api_parameters[:query]
|
234
|
-
api_parameters[:query]
|
235
|
+
api_parameters[:query] = api_parameters[:query] + ' ' unless api_parameters[:query].blank?
|
236
|
+
api_parameters[:query] = api_parameters[:query] + query
|
235
237
|
end
|
236
238
|
end
|
237
239
|
end
|
data/lib/europeana/blacklight.rb
CHANGED
@@ -1,7 +1,9 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Europeana
|
2
4
|
module Blacklight
|
3
5
|
class Install < Rails::Generators::Base
|
4
|
-
source_root File.expand_path('
|
6
|
+
source_root File.expand_path('templates', __dir__)
|
5
7
|
|
6
8
|
argument :europeana_api_key, type: :string
|
7
9
|
argument :controller_name, type: :string, default: 'catalog'
|
data/spec/dummy/Rakefile
CHANGED
@@ -1,6 +1,8 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
# Add your own tasks in files placed in lib/tasks ending in .rake,
|
2
4
|
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
|
3
5
|
|
4
|
-
require File.expand_path('
|
6
|
+
require File.expand_path('config/application', __dir__)
|
5
7
|
|
6
8
|
Rails.application.load_tasks
|
data/spec/dummy/bin/bundle
CHANGED
data/spec/dummy/bin/rails
CHANGED
data/spec/dummy/bin/rake
CHANGED
data/spec/dummy/bin/setup
CHANGED
@@ -1,16 +1,18 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
2
4
|
require 'pathname'
|
3
5
|
|
4
6
|
# path to your application root.
|
5
|
-
APP_ROOT = Pathname.new File.expand_path('
|
7
|
+
APP_ROOT = Pathname.new File.expand_path('..', __dir__)
|
6
8
|
|
7
9
|
Dir.chdir APP_ROOT do
|
8
10
|
# This script is a starting point to setup your application.
|
9
11
|
# Add necessary setup steps to this file:
|
10
12
|
|
11
|
-
puts
|
12
|
-
system
|
13
|
-
system
|
13
|
+
puts '== Installing dependencies =='
|
14
|
+
system 'gem install bundler --conservative'
|
15
|
+
system 'bundle check || bundle install'
|
14
16
|
|
15
17
|
# puts "\n== Copying sample files =="
|
16
18
|
# unless File.exist?("config/database.yml")
|
@@ -18,12 +20,12 @@ Dir.chdir APP_ROOT do
|
|
18
20
|
# end
|
19
21
|
|
20
22
|
puts "\n== Preparing database =="
|
21
|
-
system
|
23
|
+
system 'bin/rake db:setup'
|
22
24
|
|
23
25
|
puts "\n== Removing old logs and tempfiles =="
|
24
|
-
system
|
25
|
-
system
|
26
|
+
system 'rm -f log/*'
|
27
|
+
system 'rm -rf tmp/cache'
|
26
28
|
|
27
29
|
puts "\n== Restarting application server =="
|
28
|
-
system
|
30
|
+
system 'touch tmp/restart.txt'
|
29
31
|
end
|
data/spec/dummy/config/boot.rb
CHANGED
@@ -1,5 +1,7 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
# Set up gems listed in the Gemfile.
|
2
|
-
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('
|
4
|
+
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../../Gemfile', __dir__)
|
3
5
|
|
4
6
|
require 'bundler/setup' if File.exist?(ENV['BUNDLE_GEMFILE'])
|
5
|
-
$LOAD_PATH.unshift File.expand_path('
|
7
|
+
$LOAD_PATH.unshift File.expand_path('../../../lib', __dir__)
|
data/spec/dummy/config/routes.rb
CHANGED
data/spec/dummy/config.ru
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
RSpec.describe Europeana::Blacklight::Repository do
|
2
4
|
let(:blacklight_config) do
|
3
5
|
Blacklight::Configuration.new.tap do |config|
|
@@ -25,13 +27,13 @@ RSpec.describe Europeana::Blacklight::Repository do
|
|
25
27
|
it 'should send a record query to the API' do
|
26
28
|
subject.find(record_id)
|
27
29
|
expect(a_request(:get, "https://www.europeana.eu/api/v2/record#{record_id}.json").
|
28
|
-
with(query: hash_including(
|
30
|
+
with(query: hash_including('wskey' => api_key))).to have_been_made
|
29
31
|
end
|
30
32
|
|
31
33
|
it 'should pass on API query params' do
|
32
34
|
subject.find(record_id, callback: 'showRecord')
|
33
35
|
expect(a_request(:get, "https://www.europeana.eu/api/v2/record#{record_id}.json").
|
34
|
-
with(query: hash_including(
|
36
|
+
with(query: hash_including('wskey' => api_key, 'callback' => 'showRecord'))).to have_been_made
|
35
37
|
end
|
36
38
|
|
37
39
|
it 'should return configured response model' do
|
@@ -45,7 +47,7 @@ RSpec.describe Europeana::Blacklight::Repository do
|
|
45
47
|
it 'should send a search query to the API' do
|
46
48
|
subject.search('query' => query)
|
47
49
|
expect(a_request(:get, 'https://www.europeana.eu/api/v2/search.json').
|
48
|
-
with(query: hash_including(
|
50
|
+
with(query: hash_including('wskey' => api_key, 'query' => query))).to have_been_made
|
49
51
|
end
|
50
52
|
|
51
53
|
it 'should return configured response model' do
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
RSpec.describe Europeana::Blacklight::Document::Relations do
|
2
4
|
subject { Europeana::Blacklight::Document.new(source) }
|
3
5
|
|
@@ -5,8 +7,8 @@ RSpec.describe Europeana::Blacklight::Document::Relations do
|
|
5
7
|
let(:source) { { id: '/abc/123', title: ['test'] } }
|
6
8
|
|
7
9
|
it 'returns an empty array' do
|
8
|
-
|
9
|
-
|
10
|
+
%i(agents aggregations concepts europeanaAggregation places
|
11
|
+
providedCHOs proxies timespans).each do |relation|
|
10
12
|
expect(subject.send(relation)).to eq([])
|
11
13
|
end
|
12
14
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'spec_helper'
|
2
4
|
require 'i18n'
|
3
5
|
|
@@ -11,7 +13,7 @@ RSpec.describe Europeana::Blacklight::Document do
|
|
11
13
|
{
|
12
14
|
id: '/abc/123',
|
13
15
|
type: 'IMAGE',
|
14
|
-
title:
|
16
|
+
title: %w(title1 title2),
|
15
17
|
proxies: [
|
16
18
|
{
|
17
19
|
about: '/proxy/provider/abc/123',
|
@@ -20,7 +22,7 @@ RSpec.describe Europeana::Blacklight::Document do
|
|
20
22
|
en: ['Picture']
|
21
23
|
},
|
22
24
|
dcSubject: {
|
23
|
-
def:
|
25
|
+
def: %w(music art)
|
24
26
|
},
|
25
27
|
dcDescription: {
|
26
28
|
en: ['object desc']
|
@@ -136,7 +138,7 @@ RSpec.describe Europeana::Blacklight::Document do
|
|
136
138
|
|
137
139
|
context 'when value is array' do
|
138
140
|
it 'returns array of values' do
|
139
|
-
expect(subject['title']).to eq(
|
141
|
+
expect(subject['title']).to eq(%w(title1 title2))
|
140
142
|
end
|
141
143
|
end
|
142
144
|
|
@@ -149,7 +151,7 @@ RSpec.describe Europeana::Blacklight::Document do
|
|
149
151
|
end
|
150
152
|
end
|
151
153
|
end
|
152
|
-
|
154
|
+
|
153
155
|
describe '#fetch' do
|
154
156
|
context 'when key is to relation' do
|
155
157
|
it 'handles 2-level keys' do
|
data/spec/spec_helper.rb
CHANGED
@@ -1,10 +1,12 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
ENV['RAILS_ENV'] ||= 'test'
|
2
4
|
|
3
5
|
# Generate Simplecov report
|
4
6
|
require 'simplecov'
|
5
7
|
SimpleCov.start
|
6
8
|
|
7
|
-
require File.expand_path('
|
9
|
+
require File.expand_path('dummy/config/environment.rb', __dir__)
|
8
10
|
require 'rspec/rails'
|
9
11
|
require 'shoulda/matchers'
|
10
12
|
require 'webmock/rspec'
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: europeana-blacklight
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Richard Doe
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2019-01-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: blacklight
|
@@ -282,7 +282,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
282
282
|
version: '0'
|
283
283
|
requirements: []
|
284
284
|
rubyforge_project:
|
285
|
-
rubygems_version: 2.
|
285
|
+
rubygems_version: 2.7.3
|
286
286
|
signing_key:
|
287
287
|
specification_version: 4
|
288
288
|
summary: Europeana REST API adapter for Blacklight
|