cdmbl 0.14.0 → 0.15.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/cdmbl.gemspec +1 -3
- data/lib/cdmbl/cdm_request_worker.rb +90 -0
- data/lib/cdmbl/oai_client.rb +6 -4
- data/lib/cdmbl/version.rb +1 -1
- metadata +6 -45
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 637df7b53cd7d660727a0a8d55fa7847d7cba6c442f0a5aa44accd652bc1efed
|
4
|
+
data.tar.gz: debd85256ed204a7c58de43e2db284ffeaaaafd4dc63bc59693d965c211f81e8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2a803c89d9a67faa6f706dd1a6f8cf1c3b8d535cda68dd7ef0d5102b7c5201b08dd84d31cb7d0571a957fed3f1f84e76c54bf117c11ee64e288bbba96a113a2a
|
7
|
+
data.tar.gz: f6878f26d9151558bbde5e0a3a10c8a793123b8c686b3815b543835a42423b87f8f5a3ae01fef834432941a710692d654b6c60052de5121f53454607664180a3
|
data/cdmbl.gemspec
CHANGED
@@ -18,7 +18,7 @@ Gem::Specification.new do |spec|
|
|
18
18
|
spec.require_paths = ['lib']
|
19
19
|
|
20
20
|
spec.add_dependency 'hash_at_path', '~> 0.1'
|
21
|
-
spec.add_dependency 'contentdm_api', '~> 0.
|
21
|
+
spec.add_dependency 'contentdm_api', '~> 0.4.1'
|
22
22
|
spec.add_dependency 'sidekiq', '>= 3.5'
|
23
23
|
spec.add_dependency 'titleize', '~> 1.4'
|
24
24
|
spec.add_dependency 'rsolr', '~> 2.0'
|
@@ -32,6 +32,4 @@ Gem::Specification.new do |spec|
|
|
32
32
|
spec.add_development_dependency 'rake', '~> 12.0'
|
33
33
|
spec.add_development_dependency 'minitest', '~> 5.0'
|
34
34
|
spec.add_development_dependency 'yard', '~> 0.9.0'
|
35
|
-
spec.add_development_dependency 'webmock', '~> 1.24', '>= 1.24.0'
|
36
|
-
spec.add_development_dependency 'vcr', '~> 3.0', '>= 3.0.1'
|
37
35
|
end
|
@@ -0,0 +1,90 @@
|
|
1
|
+
require 'sidekiq'
|
2
|
+
module CDMBL
|
3
|
+
class CdmRequestWorker
|
4
|
+
include Sidekiq::Worker
|
5
|
+
attr_reader :collection,
|
6
|
+
:id,
|
7
|
+
:set_lookup,
|
8
|
+
:field_mappings
|
9
|
+
|
10
|
+
attr_writer :cdm_api_klass,
|
11
|
+
:oai_request_klass,
|
12
|
+
:oai_set_lookup_klass,
|
13
|
+
:cdm_notification_klass,
|
14
|
+
:load_worker_klass,
|
15
|
+
:transformer_klass
|
16
|
+
|
17
|
+
def perform(collection, id)
|
18
|
+
|
19
|
+
@identifiers = identifiers
|
20
|
+
@solr_config = solr_config
|
21
|
+
@cdm_endpoint = cdm_endpoint
|
22
|
+
@oai_endpoint = oai_endpoint
|
23
|
+
@field_mappings = field_mappings
|
24
|
+
@extract_compounds = extract_compounds
|
25
|
+
transform_and_load!
|
26
|
+
end
|
27
|
+
|
28
|
+
def oai_set_lookup_klass
|
29
|
+
@oai_set_lookup_klass ||= OAISetLookup
|
30
|
+
end
|
31
|
+
|
32
|
+
def oai_request_klass
|
33
|
+
@oai_request_klass ||= OaiRequest
|
34
|
+
end
|
35
|
+
|
36
|
+
def cdm_api_klass
|
37
|
+
@cdm_api_klass ||= CONTENTdmAPI::Item
|
38
|
+
end
|
39
|
+
|
40
|
+
def cdm_notification_klass
|
41
|
+
@cdm_notification_klass ||= CdmNotification
|
42
|
+
end
|
43
|
+
|
44
|
+
def transformer_klass
|
45
|
+
@transformer_klass ||= Transformer
|
46
|
+
end
|
47
|
+
|
48
|
+
def load_worker_klass
|
49
|
+
@load_worker_klass ||= LoadWorker
|
50
|
+
end
|
51
|
+
|
52
|
+
private
|
53
|
+
|
54
|
+
def transform_and_load!
|
55
|
+
load_worker_klass.perform_async(transformed_records, [], solr_config)
|
56
|
+
end
|
57
|
+
|
58
|
+
def transformed_records
|
59
|
+
@transformation ||=
|
60
|
+
transformer_klass.new(cdm_records: records,
|
61
|
+
oai_sets: set_lookup,
|
62
|
+
field_mappings: field_mappings,
|
63
|
+
extract_compounds: extract_compounds).records
|
64
|
+
end
|
65
|
+
|
66
|
+
def set_lookup
|
67
|
+
oai_set_lookup_klass.new(oai_sets: sets).keyed
|
68
|
+
end
|
69
|
+
|
70
|
+
def records
|
71
|
+
identifiers.map do |identifier|
|
72
|
+
cdm_request(*identifier)
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
# e.g. local_identifiers.map { |identifier| extractor.cdm_request(*identifier) }
|
77
|
+
def cdm_request(collection, id)
|
78
|
+
cdm_notification_klass.call!(collection, id, cdm_endpoint)
|
79
|
+
cdm_api_klass.new(base_url: cdm_endpoint,
|
80
|
+
collection: collection,
|
81
|
+
with_compounds: false,
|
82
|
+
id: id)
|
83
|
+
end
|
84
|
+
|
85
|
+
def sets
|
86
|
+
@oai_request ||=
|
87
|
+
oai_request_klass.new(base_uri: oai_endpoint).sets
|
88
|
+
end
|
89
|
+
end
|
90
|
+
end
|
data/lib/cdmbl/oai_client.rb
CHANGED
@@ -1,10 +1,12 @@
|
|
1
|
+
|
1
2
|
require 'json'
|
3
|
+
require 'http'
|
2
4
|
module CDMBL
|
3
5
|
class OaiClient
|
4
|
-
attr_reader :base_url, :
|
5
|
-
def initialize(base_url: '',
|
6
|
+
attr_reader :base_url, :client
|
7
|
+
def initialize(base_url: '', client: HTTP)
|
6
8
|
@base_url = base_url
|
7
|
-
@
|
9
|
+
@client = client
|
8
10
|
end
|
9
11
|
|
10
12
|
def request(query)
|
@@ -14,7 +16,7 @@ module CDMBL
|
|
14
16
|
private
|
15
17
|
|
16
18
|
def get(url)
|
17
|
-
|
19
|
+
client.get(url).to_s
|
18
20
|
end
|
19
21
|
|
20
22
|
def hashify(xml)
|
data/lib/cdmbl/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cdmbl
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.15.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- chadfennell
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-01-
|
11
|
+
date: 2019-01-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: hash_at_path
|
@@ -30,14 +30,14 @@ dependencies:
|
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: 0.
|
33
|
+
version: 0.4.1
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: 0.
|
40
|
+
version: 0.4.1
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: sidekiq
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -150,46 +150,6 @@ dependencies:
|
|
150
150
|
- - "~>"
|
151
151
|
- !ruby/object:Gem::Version
|
152
152
|
version: 0.9.0
|
153
|
-
- !ruby/object:Gem::Dependency
|
154
|
-
name: webmock
|
155
|
-
requirement: !ruby/object:Gem::Requirement
|
156
|
-
requirements:
|
157
|
-
- - "~>"
|
158
|
-
- !ruby/object:Gem::Version
|
159
|
-
version: '1.24'
|
160
|
-
- - ">="
|
161
|
-
- !ruby/object:Gem::Version
|
162
|
-
version: 1.24.0
|
163
|
-
type: :development
|
164
|
-
prerelease: false
|
165
|
-
version_requirements: !ruby/object:Gem::Requirement
|
166
|
-
requirements:
|
167
|
-
- - "~>"
|
168
|
-
- !ruby/object:Gem::Version
|
169
|
-
version: '1.24'
|
170
|
-
- - ">="
|
171
|
-
- !ruby/object:Gem::Version
|
172
|
-
version: 1.24.0
|
173
|
-
- !ruby/object:Gem::Dependency
|
174
|
-
name: vcr
|
175
|
-
requirement: !ruby/object:Gem::Requirement
|
176
|
-
requirements:
|
177
|
-
- - "~>"
|
178
|
-
- !ruby/object:Gem::Version
|
179
|
-
version: '3.0'
|
180
|
-
- - ">="
|
181
|
-
- !ruby/object:Gem::Version
|
182
|
-
version: 3.0.1
|
183
|
-
type: :development
|
184
|
-
prerelease: false
|
185
|
-
version_requirements: !ruby/object:Gem::Requirement
|
186
|
-
requirements:
|
187
|
-
- - "~>"
|
188
|
-
- !ruby/object:Gem::Version
|
189
|
-
version: '3.0'
|
190
|
-
- - ">="
|
191
|
-
- !ruby/object:Gem::Version
|
192
|
-
version: 3.0.1
|
193
153
|
description:
|
194
154
|
email:
|
195
155
|
- fenne035@umn.edu
|
@@ -211,6 +171,7 @@ files:
|
|
211
171
|
- lib/cdmbl.rb
|
212
172
|
- lib/cdmbl/batch_deleter.rb
|
213
173
|
- lib/cdmbl/batch_deleter_worker.rb
|
174
|
+
- lib/cdmbl/cdm_request_worker.rb
|
214
175
|
- lib/cdmbl/compound_filter.rb
|
215
176
|
- lib/cdmbl/compound_lookup.rb
|
216
177
|
- lib/cdmbl/default_cdm_notification.rb
|
@@ -265,7 +226,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
265
226
|
version: '0'
|
266
227
|
requirements: []
|
267
228
|
rubyforge_project:
|
268
|
-
rubygems_version: 2.
|
229
|
+
rubygems_version: 2.7.8
|
269
230
|
signing_key:
|
270
231
|
specification_version: 4
|
271
232
|
summary: Load CONTENTdm data into a Solr Index. CDMBL expects to run inside a Rails
|