base_indexer 0.3.8 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -13
- data/Rakefile +9 -9
- data/lib/base_indexer/collection.rb +13 -13
- data/lib/base_indexer/engine.rb +5 -2
- data/lib/base_indexer/main_indexer_engine.rb +7 -7
- data/lib/base_indexer/version.rb +1 -1
- data/lib/generators/base_indexer/install_generator.rb +14 -0
- data/lib/generators/base_indexer/templates/solr.yml +4 -0
- metadata +37 -35
checksums.yaml
CHANGED
@@ -1,15 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
|
5
|
-
data.tar.gz: !binary |-
|
6
|
-
YzBlNWY5ZGNkZjU5MjdkMWYwZWY4NzI3Yjg3MjllMzQ5ODlmNzNhZQ==
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 0411b782fc2b37b199c84de8c1d0cfa407bf284f
|
4
|
+
data.tar.gz: f516ca6d3360adf7f7edc6e9c15ae02d97add79c
|
7
5
|
SHA512:
|
8
|
-
metadata.gz:
|
9
|
-
|
10
|
-
MjMwMWIxNzg4ODU2NGI3MWI2NmQ5NmFhMDUwMDRhMmU4OTdlZjM5OTRkMDYy
|
11
|
-
OWEwNTlkYTZmNDQxZDViZTQ1YTc2MTI1MzRkMzY4MjA1M2JkN2M=
|
12
|
-
data.tar.gz: !binary |-
|
13
|
-
MTNiMzFlYWQzNzU0ZmQ4YmMzYmZhOWM5ZjYzMWNhNTU0NTRiN2Q2OGFjMmZk
|
14
|
-
M2YyMzE1YzhkNzhjZGMyYWJlNzFkMGJkYzVjOWM3YmNjNjk3N2UzNjE0NmYy
|
15
|
-
YjExMTk0OGUzNWY1ZGJhNDFjMTJkNzBlN2UwZTM4MmFhNjQ3YmQ=
|
6
|
+
metadata.gz: 8aac42831ca4197392c0cf289d0d8dea5595910597f2dc99a84e22b867baefa3f48117bcb0eead9c3f3de2faf7b8bceee8b2b37fd961ef1c471b54ee6b513b34
|
7
|
+
data.tar.gz: 3a5289a81cce30caba2a7eb911d8e7a8bc157c36124fb62bd177c87303ce6d3af6796360d5fab0e0f65e069bb338d86b7902e211b07af27033abef8456ecf21b
|
data/Rakefile
CHANGED
@@ -11,23 +11,23 @@ require 'yard/rake/yardoc_task'
|
|
11
11
|
|
12
12
|
Bundler::GemHelper.install_tasks
|
13
13
|
|
14
|
-
|
15
|
-
|
16
|
-
APP_RAKEFILE = File.expand_path("../spec/internal/Rakefile", __FILE__)
|
17
|
-
load 'rails/tasks/engine.rake'
|
18
14
|
Dir[File.join(File.dirname(__FILE__), 'tasks/**/*.rake')].each {|f| load f }
|
19
15
|
|
20
16
|
# Travis ci task
|
21
17
|
task :default => :ci
|
22
18
|
desc "run continuous integration suite (tests, coverage, docs)"
|
23
|
-
task :ci => [:rspec, :doc]
|
24
19
|
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
20
|
+
require 'engine_cart/rake_task'
|
21
|
+
EngineCart.fingerprint_proc = EngineCart.rails_fingerprint_proc
|
22
|
+
|
23
|
+
task :ci => ['engine_cart:generate'] do
|
24
|
+
# run the tests
|
25
|
+
Rake::Task['spec'].invoke
|
26
|
+
Rake::Task['doc'].invoke
|
29
27
|
end
|
30
28
|
|
29
|
+
RSpec::Core::RakeTask.new(:spec)
|
30
|
+
|
31
31
|
# Use yard to build docs
|
32
32
|
begin
|
33
33
|
project_root = File.expand_path(File.dirname(__FILE__))
|
@@ -1,25 +1,25 @@
|
|
1
1
|
module BaseIndexer
|
2
2
|
|
3
|
-
# It caches the collection information such as name
|
3
|
+
# It caches the collection information such as name and catkey
|
4
4
|
class Collection
|
5
5
|
|
6
6
|
# Returns the collection name from cache, otherwise will fetch it from PURL.
|
7
7
|
#
|
8
8
|
# @param collection_druid [String] is the druid for a collection e.g., ab123cd4567
|
9
|
-
# @return [String] the collection
|
9
|
+
# @return [Array<String>] the collection data or [] if there is no name and catkey or the object
|
10
10
|
# is not a collection
|
11
|
-
def self.
|
11
|
+
def self.get_collection_info(collection_druid)
|
12
12
|
|
13
|
-
|
14
|
-
if
|
15
|
-
|
13
|
+
collection_info = get_from_cache(collection_druid)
|
14
|
+
if collection_info.nil?
|
15
|
+
collection_info = get_from_purl(collection_druid)
|
16
16
|
end
|
17
|
-
|
17
|
+
collection_info
|
18
18
|
end
|
19
19
|
|
20
20
|
# @param [String] collection_druid is the druid for a collection e.g., ab123cd4567
|
21
21
|
# @return [String] return the collection label from cache if available, nil otherwise
|
22
|
-
def self.
|
22
|
+
def self.get_from_cache(collection_druid)
|
23
23
|
Rails.cache.read(collection_druid)
|
24
24
|
end
|
25
25
|
|
@@ -28,13 +28,13 @@ module BaseIndexer
|
|
28
28
|
def self.get_from_purl(collection_druid)
|
29
29
|
begin
|
30
30
|
purl_model =DiscoveryIndexer::InputXml::Purlxml.new(collection_druid).load()
|
31
|
-
unless purl_model.nil? or purl_model.label.nil? or not(purl_model.is_collection)
|
32
|
-
Rails.cache.write(collection_druid, purl_model.label, expires_in: 1.hours)
|
33
|
-
purl_model.label
|
31
|
+
unless purl_model.nil? or (purl_model.label.nil? and purl_model.catkey.nil?) or not(purl_model.is_collection)
|
32
|
+
Rails.cache.write(collection_druid, { label: purl_model.label, ckey: purl_model.catkey }, expires_in: 1.hours)
|
33
|
+
{ label: purl_model.label, ckey: purl_model.catkey }
|
34
34
|
end
|
35
35
|
rescue => e
|
36
|
-
Rails.logger.error "There is a problem in retrieving collection name for #{collection_druid}. #{e.inspect}\n#{e.message }\n#{e.backtrace}"
|
37
|
-
return
|
36
|
+
Rails.logger.error "There is a problem in retrieving collection name and/or catkey for #{collection_druid}. #{e.inspect}\n#{e.message }\n#{e.backtrace}"
|
37
|
+
return {}
|
38
38
|
end
|
39
39
|
end
|
40
40
|
end
|
data/lib/base_indexer/engine.rb
CHANGED
@@ -15,9 +15,12 @@ module BaseIndexer
|
|
15
15
|
|
16
16
|
config.after_initialize do
|
17
17
|
|
18
|
-
|
19
|
-
BaseIndexer.solr_configuration_class_name.constantize.instance.read(Rails.configuration.solr_config_file_path ||= 'test')
|
18
|
+
config.solr_config_file = File.join(Rails.root, "config","solr.yml")
|
20
19
|
|
20
|
+
if File.exists? config.solr_config_file
|
21
|
+
# Reads the SOLR configuration file
|
22
|
+
BaseIndexer.solr_configuration_class_name.constantize.instance.read(config.solr_config_file)
|
23
|
+
end
|
21
24
|
|
22
25
|
# Initializes the DiscoveryIndexer log with Rails logger, so all the messages will go to
|
23
26
|
# the same log file
|
@@ -30,10 +30,10 @@ module BaseIndexer
|
|
30
30
|
# Read input mods and purl
|
31
31
|
purl_model = read_purl(druid)
|
32
32
|
mods_model = read_mods(druid)
|
33
|
-
|
33
|
+
collection_data = get_collection_data(purl_model.collection_druids)
|
34
34
|
|
35
35
|
# Map the input to solr_doc
|
36
|
-
solr_doc = BaseIndexer.mapper_class_name.constantize.new(druid, mods_model, purl_model,
|
36
|
+
solr_doc = BaseIndexer.mapper_class_name.constantize.new(druid, mods_model, purl_model, collection_data).convert_to_solr_doc
|
37
37
|
|
38
38
|
# Get target list
|
39
39
|
targets_hash={}
|
@@ -96,16 +96,16 @@ module BaseIndexer
|
|
96
96
|
# !["ab123cd4567", "ef123gh4567"]
|
97
97
|
# @return [Hash] a hash for collection druid and its name
|
98
98
|
# !{"ab123cd4567"=>"Collection 1", "ef123gh4567"=>"Collection 2"}
|
99
|
-
def
|
100
|
-
|
99
|
+
def get_collection_data collection_druids
|
100
|
+
collection_data = {}
|
101
101
|
|
102
102
|
unless collection_druids.nil? then
|
103
103
|
collection_druids.each do |cdruid|
|
104
|
-
|
105
|
-
|
104
|
+
cdata = BaseIndexer::Collection.get_collection_info(cdruid)
|
105
|
+
collection_data[cdruid] = cdata unless cdata.nil?
|
106
106
|
end
|
107
107
|
end
|
108
|
-
|
108
|
+
collection_data
|
109
109
|
end
|
110
110
|
|
111
111
|
end
|
data/lib/base_indexer/version.rb
CHANGED
@@ -0,0 +1,14 @@
|
|
1
|
+
require 'rails/generators'
|
2
|
+
|
3
|
+
module BaseIndexer
|
4
|
+
class Install < Rails::Generators::Base
|
5
|
+
|
6
|
+
source_root File.expand_path('../templates', __FILE__)
|
7
|
+
|
8
|
+
desc "Install Base Indexer"
|
9
|
+
|
10
|
+
def assets
|
11
|
+
copy_file "solr.yml", "config/solr.yml"
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
metadata
CHANGED
@@ -1,215 +1,215 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: base_indexer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ahmed Alsum
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-06-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - ~>
|
17
|
+
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '4.1'
|
20
|
-
- -
|
20
|
+
- - ">="
|
21
21
|
- !ruby/object:Gem::Version
|
22
22
|
version: 4.1.9
|
23
23
|
type: :runtime
|
24
24
|
prerelease: false
|
25
25
|
version_requirements: !ruby/object:Gem::Requirement
|
26
26
|
requirements:
|
27
|
-
- - ~>
|
27
|
+
- - "~>"
|
28
28
|
- !ruby/object:Gem::Version
|
29
29
|
version: '4.1'
|
30
|
-
- -
|
30
|
+
- - ">="
|
31
31
|
- !ruby/object:Gem::Version
|
32
32
|
version: 4.1.9
|
33
33
|
- !ruby/object:Gem::Dependency
|
34
34
|
name: discovery-indexer
|
35
35
|
requirement: !ruby/object:Gem::Requirement
|
36
36
|
requirements:
|
37
|
-
- -
|
37
|
+
- - ">="
|
38
38
|
- !ruby/object:Gem::Version
|
39
39
|
version: '0'
|
40
40
|
type: :runtime
|
41
41
|
prerelease: false
|
42
42
|
version_requirements: !ruby/object:Gem::Requirement
|
43
43
|
requirements:
|
44
|
-
- -
|
44
|
+
- - ">="
|
45
45
|
- !ruby/object:Gem::Version
|
46
46
|
version: '0'
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: retries
|
49
49
|
requirement: !ruby/object:Gem::Requirement
|
50
50
|
requirements:
|
51
|
-
- -
|
51
|
+
- - ">="
|
52
52
|
- !ruby/object:Gem::Version
|
53
53
|
version: '0'
|
54
54
|
type: :runtime
|
55
55
|
prerelease: false
|
56
56
|
version_requirements: !ruby/object:Gem::Requirement
|
57
57
|
requirements:
|
58
|
-
- -
|
58
|
+
- - ">="
|
59
59
|
- !ruby/object:Gem::Version
|
60
60
|
version: '0'
|
61
61
|
- !ruby/object:Gem::Dependency
|
62
62
|
name: is_it_working-cbeer
|
63
63
|
requirement: !ruby/object:Gem::Requirement
|
64
64
|
requirements:
|
65
|
-
- -
|
65
|
+
- - ">="
|
66
66
|
- !ruby/object:Gem::Version
|
67
67
|
version: '0'
|
68
68
|
type: :runtime
|
69
69
|
prerelease: false
|
70
70
|
version_requirements: !ruby/object:Gem::Requirement
|
71
71
|
requirements:
|
72
|
-
- -
|
72
|
+
- - ">="
|
73
73
|
- !ruby/object:Gem::Version
|
74
74
|
version: '0'
|
75
75
|
- !ruby/object:Gem::Dependency
|
76
76
|
name: sqlite3
|
77
77
|
requirement: !ruby/object:Gem::Requirement
|
78
78
|
requirements:
|
79
|
-
- -
|
79
|
+
- - ">="
|
80
80
|
- !ruby/object:Gem::Version
|
81
81
|
version: '0'
|
82
82
|
type: :development
|
83
83
|
prerelease: false
|
84
84
|
version_requirements: !ruby/object:Gem::Requirement
|
85
85
|
requirements:
|
86
|
-
- -
|
86
|
+
- - ">="
|
87
87
|
- !ruby/object:Gem::Version
|
88
88
|
version: '0'
|
89
89
|
- !ruby/object:Gem::Dependency
|
90
90
|
name: rspec
|
91
91
|
requirement: !ruby/object:Gem::Requirement
|
92
92
|
requirements:
|
93
|
-
- - ~>
|
93
|
+
- - "~>"
|
94
94
|
- !ruby/object:Gem::Version
|
95
95
|
version: 3.1.0
|
96
96
|
type: :development
|
97
97
|
prerelease: false
|
98
98
|
version_requirements: !ruby/object:Gem::Requirement
|
99
99
|
requirements:
|
100
|
-
- - ~>
|
100
|
+
- - "~>"
|
101
101
|
- !ruby/object:Gem::Version
|
102
102
|
version: 3.1.0
|
103
103
|
- !ruby/object:Gem::Dependency
|
104
104
|
name: rspec-rails
|
105
105
|
requirement: !ruby/object:Gem::Requirement
|
106
106
|
requirements:
|
107
|
-
- - ~>
|
107
|
+
- - "~>"
|
108
108
|
- !ruby/object:Gem::Version
|
109
109
|
version: 3.1.0
|
110
110
|
type: :development
|
111
111
|
prerelease: false
|
112
112
|
version_requirements: !ruby/object:Gem::Requirement
|
113
113
|
requirements:
|
114
|
-
- - ~>
|
114
|
+
- - "~>"
|
115
115
|
- !ruby/object:Gem::Version
|
116
116
|
version: 3.1.0
|
117
117
|
- !ruby/object:Gem::Dependency
|
118
118
|
name: capybara
|
119
119
|
requirement: !ruby/object:Gem::Requirement
|
120
120
|
requirements:
|
121
|
-
- -
|
121
|
+
- - ">="
|
122
122
|
- !ruby/object:Gem::Version
|
123
123
|
version: '0'
|
124
124
|
type: :development
|
125
125
|
prerelease: false
|
126
126
|
version_requirements: !ruby/object:Gem::Requirement
|
127
127
|
requirements:
|
128
|
-
- -
|
128
|
+
- - ">="
|
129
129
|
- !ruby/object:Gem::Version
|
130
130
|
version: '0'
|
131
131
|
- !ruby/object:Gem::Dependency
|
132
132
|
name: vcr
|
133
133
|
requirement: !ruby/object:Gem::Requirement
|
134
134
|
requirements:
|
135
|
-
- -
|
135
|
+
- - ">="
|
136
136
|
- !ruby/object:Gem::Version
|
137
137
|
version: '0'
|
138
138
|
type: :development
|
139
139
|
prerelease: false
|
140
140
|
version_requirements: !ruby/object:Gem::Requirement
|
141
141
|
requirements:
|
142
|
-
- -
|
142
|
+
- - ">="
|
143
143
|
- !ruby/object:Gem::Version
|
144
144
|
version: '0'
|
145
145
|
- !ruby/object:Gem::Dependency
|
146
146
|
name: webmock
|
147
147
|
requirement: !ruby/object:Gem::Requirement
|
148
148
|
requirements:
|
149
|
-
- -
|
149
|
+
- - ">="
|
150
150
|
- !ruby/object:Gem::Version
|
151
151
|
version: '0'
|
152
152
|
type: :development
|
153
153
|
prerelease: false
|
154
154
|
version_requirements: !ruby/object:Gem::Requirement
|
155
155
|
requirements:
|
156
|
-
- -
|
156
|
+
- - ">="
|
157
157
|
- !ruby/object:Gem::Version
|
158
158
|
version: '0'
|
159
159
|
- !ruby/object:Gem::Dependency
|
160
160
|
name: coveralls
|
161
161
|
requirement: !ruby/object:Gem::Requirement
|
162
162
|
requirements:
|
163
|
-
- -
|
163
|
+
- - ">="
|
164
164
|
- !ruby/object:Gem::Version
|
165
165
|
version: '0'
|
166
166
|
type: :development
|
167
167
|
prerelease: false
|
168
168
|
version_requirements: !ruby/object:Gem::Requirement
|
169
169
|
requirements:
|
170
|
-
- -
|
170
|
+
- - ">="
|
171
171
|
- !ruby/object:Gem::Version
|
172
172
|
version: '0'
|
173
173
|
- !ruby/object:Gem::Dependency
|
174
174
|
name: yard
|
175
175
|
requirement: !ruby/object:Gem::Requirement
|
176
176
|
requirements:
|
177
|
-
- -
|
177
|
+
- - ">="
|
178
178
|
- !ruby/object:Gem::Version
|
179
179
|
version: '0'
|
180
180
|
type: :development
|
181
181
|
prerelease: false
|
182
182
|
version_requirements: !ruby/object:Gem::Requirement
|
183
183
|
requirements:
|
184
|
-
- -
|
184
|
+
- - ">="
|
185
185
|
- !ruby/object:Gem::Version
|
186
186
|
version: '0'
|
187
187
|
- !ruby/object:Gem::Dependency
|
188
188
|
name: engine_cart
|
189
189
|
requirement: !ruby/object:Gem::Requirement
|
190
190
|
requirements:
|
191
|
-
- -
|
191
|
+
- - ">="
|
192
192
|
- !ruby/object:Gem::Version
|
193
193
|
version: '0'
|
194
194
|
type: :development
|
195
195
|
prerelease: false
|
196
196
|
version_requirements: !ruby/object:Gem::Requirement
|
197
197
|
requirements:
|
198
|
-
- -
|
198
|
+
- - ">="
|
199
199
|
- !ruby/object:Gem::Version
|
200
200
|
version: '0'
|
201
201
|
- !ruby/object:Gem::Dependency
|
202
202
|
name: jettywrapper
|
203
203
|
requirement: !ruby/object:Gem::Requirement
|
204
204
|
requirements:
|
205
|
-
- -
|
205
|
+
- - ">="
|
206
206
|
- !ruby/object:Gem::Version
|
207
207
|
version: '0'
|
208
208
|
type: :development
|
209
209
|
prerelease: false
|
210
210
|
version_requirements: !ruby/object:Gem::Requirement
|
211
211
|
requirements:
|
212
|
-
- -
|
212
|
+
- - ">="
|
213
213
|
- !ruby/object:Gem::Version
|
214
214
|
version: '0'
|
215
215
|
description: Description of BaseIndexer.
|
@@ -239,6 +239,8 @@ files:
|
|
239
239
|
- lib/base_indexer/solr/solr_configuration.rb
|
240
240
|
- lib/base_indexer/solr/solr_configuration_from_file.rb
|
241
241
|
- lib/base_indexer/version.rb
|
242
|
+
- lib/generators/base_indexer/install_generator.rb
|
243
|
+
- lib/generators/base_indexer/templates/solr.yml
|
242
244
|
- lib/tasks/base_indexer_tasks.rake
|
243
245
|
- lib/tasks/index.rake
|
244
246
|
homepage:
|
@@ -251,17 +253,17 @@ require_paths:
|
|
251
253
|
- lib
|
252
254
|
required_ruby_version: !ruby/object:Gem::Requirement
|
253
255
|
requirements:
|
254
|
-
- -
|
256
|
+
- - ">="
|
255
257
|
- !ruby/object:Gem::Version
|
256
258
|
version: '0'
|
257
259
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
258
260
|
requirements:
|
259
|
-
- -
|
261
|
+
- - ">="
|
260
262
|
- !ruby/object:Gem::Version
|
261
263
|
version: '0'
|
262
264
|
requirements: []
|
263
265
|
rubyforge_project:
|
264
|
-
rubygems_version: 2.4.
|
266
|
+
rubygems_version: 2.4.5
|
265
267
|
signing_key:
|
266
268
|
specification_version: 4
|
267
269
|
summary: Summary of BaseIndexer.
|