base_indexer 3.0.0 → 4.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (39) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +40 -0
  3. data/.travis.yml +17 -0
  4. data/Gemfile +49 -0
  5. data/LICENSE +13 -0
  6. data/README.md +151 -0
  7. data/app/controllers/base_indexer/about_controller.rb +1 -1
  8. data/base_indexer.gemspec +40 -0
  9. data/code_diagram.png +0 -0
  10. data/config/initializers/base_indexer.rb +0 -2
  11. data/config/initializers/config.rb +6 -0
  12. data/lib/base_indexer.rb +0 -3
  13. data/lib/base_indexer/engine.rb +0 -9
  14. data/lib/base_indexer/main_indexer_engine.rb +5 -6
  15. data/lib/base_indexer/solr/client.rb +3 -3
  16. data/lib/base_indexer/version.rb +1 -1
  17. data/lib/generators/base_indexer/install_generator.rb +1 -1
  18. data/lib/generators/base_indexer/templates/settings.yml +5 -0
  19. data/lib/tasks/index.rake +4 -4
  20. data/spec/base_indexer/main_indexer_engine_spec.rb +46 -0
  21. data/spec/base_indexer/solr/client_spec.rb +47 -0
  22. data/spec/base_indexer/solr/writer_spec.rb +72 -0
  23. data/spec/controllers/base_indexer/items_controller_spec.rb +36 -0
  24. data/spec/fixtures/vcr_cassettes/available_mods_xml.yml +105 -0
  25. data/spec/fixtures/vcr_cassettes/available_purl_xml.yml +110 -0
  26. data/spec/fixtures/vcr_cassettes/get_collection_name_for_item.yml +197 -0
  27. data/spec/fixtures/vcr_cassettes/read_mods_in_vaild.yml +154 -0
  28. data/spec/fixtures/vcr_cassettes/read_mods_vaild.yml +199 -0
  29. data/spec/fixtures/vcr_cassettes/read_purl_in_vaild.yml +154 -0
  30. data/spec/fixtures/vcr_cassettes/read_purl_vaild.yml +197 -0
  31. data/spec/fixtures/vcr_cassettes/rsolr_client_delete.yml +174 -0
  32. data/spec/fixtures/vcr_cassettes/rsolr_client_index.yml +115 -0
  33. data/spec/fixtures/vcr_cassettes/rsolr_update.yml +313 -0
  34. data/spec/spec_helper.rb +112 -0
  35. data/spec/test_app_templates/lib/generators/test_app_generator.rb +14 -0
  36. metadata +72 -14
  37. data/lib/base_indexer/config/solr_configuration.rb +0 -17
  38. data/lib/base_indexer/config/solr_configuration_from_file.rb +0 -25
  39. data/lib/generators/base_indexer/templates/solr.yml +0 -4
@@ -0,0 +1,115 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: http://localhost:8983/solr/select?q=id:%22tn629pk3948%22&wt=ruby
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
9
+ headers: {}
10
+ response:
11
+ status:
12
+ code: 200
13
+ message: OK
14
+ headers:
15
+ Last-Modified:
16
+ - Wed, 11 Nov 2015 00:34:07 GMT
17
+ Etag:
18
+ - '"NDg5MDAwMDAwMDAwMDAwMFNvbHI="'
19
+ Content-Type:
20
+ - text/plain;charset=UTF-8
21
+ Transfer-Encoding:
22
+ - chunked
23
+ body:
24
+ encoding: UTF-8
25
+ string: |
26
+ {'responseHeader'=>{'status'=>0,'QTime'=>1},'response'=>{'numFound'=>0,'start'=>0,'docs'=>[]}}
27
+ http_version:
28
+ recorded_at: Wed, 11 Nov 2015 00:34:15 GMT
29
+ - request:
30
+ method: post
31
+ uri: http://localhost:8983/solr/update?wt=ruby
32
+ body:
33
+ encoding: UTF-8
34
+ string: <?xml version="1.0" encoding="UTF-8"?><add commitWithin="10000"><doc><field
35
+ name="id">tn629pk3948</field><field name="title">Lecture 1.</field></doc></add>
36
+ headers:
37
+ Content-Type:
38
+ - text/xml
39
+ response:
40
+ status:
41
+ code: 200
42
+ message: OK
43
+ headers:
44
+ Content-Type:
45
+ - text/plain;charset=UTF-8
46
+ Transfer-Encoding:
47
+ - chunked
48
+ body:
49
+ encoding: UTF-8
50
+ string: |
51
+ {'responseHeader'=>{'status'=>0,'QTime'=>2}}
52
+ http_version:
53
+ recorded_at: Wed, 11 Nov 2015 00:34:15 GMT
54
+ - request:
55
+ method: post
56
+ uri: http://localhost:8983/solr/update?commit=true
57
+ body:
58
+ encoding: ASCII-8BIT
59
+ string: ''
60
+ headers:
61
+ Accept:
62
+ - application/json
63
+ Accept-Encoding:
64
+ - gzip, deflate
65
+ Content-Type:
66
+ - application/x-www-form-urlencoded
67
+ Content-Length:
68
+ - '0'
69
+ User-Agent:
70
+ - Ruby
71
+ response:
72
+ status:
73
+ code: 200
74
+ message: OK
75
+ headers:
76
+ Content-Type:
77
+ - application/xml; charset=UTF-8
78
+ Transfer-Encoding:
79
+ - chunked
80
+ body:
81
+ encoding: UTF-8
82
+ string: |
83
+ <?xml version="1.0" encoding="UTF-8"?>
84
+ <response>
85
+ <lst name="responseHeader"><int name="status">0</int><int name="QTime">15</int></lst>
86
+ </response>
87
+ http_version:
88
+ recorded_at: Wed, 11 Nov 2015 00:34:15 GMT
89
+ - request:
90
+ method: get
91
+ uri: http://localhost:8983/solr/select?q=id:%22tn629pk3948%22&wt=ruby
92
+ body:
93
+ encoding: US-ASCII
94
+ string: ''
95
+ headers: {}
96
+ response:
97
+ status:
98
+ code: 200
99
+ message: OK
100
+ headers:
101
+ Last-Modified:
102
+ - Wed, 11 Nov 2015 00:34:15 GMT
103
+ Etag:
104
+ - '"Mjg5MDAwMDAwMDAwMDAwMFNvbHI="'
105
+ Content-Type:
106
+ - text/plain;charset=UTF-8
107
+ Transfer-Encoding:
108
+ - chunked
109
+ body:
110
+ encoding: UTF-8
111
+ string: |
112
+ {'responseHeader'=>{'status'=>0,'QTime'=>1},'response'=>{'numFound'=>1,'start'=>0,'docs'=>[{'id'=>'tn629pk3948','title'=>'Lecture 1.','_version_'=>1517501342175723520,'timestamp'=>'2015-11-11T00:34:15.145Z'}]}}
113
+ http_version:
114
+ recorded_at: Wed, 11 Nov 2015 00:34:15 GMT
115
+ recorded_with: VCR 2.9.3
@@ -0,0 +1,313 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: http://localhost:8983/solr/select?q=id:%22cb077vs7846%22&wt=ruby
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
9
+ headers: {}
10
+ response:
11
+ status:
12
+ code: 200
13
+ message: OK
14
+ headers:
15
+ Last-Modified:
16
+ - Wed, 11 Nov 2015 00:47:09 GMT
17
+ Etag:
18
+ - '"MjkwMDAwMDAwMDAwMDAwU29scg=="'
19
+ Content-Type:
20
+ - text/plain;charset=UTF-8
21
+ Transfer-Encoding:
22
+ - chunked
23
+ body:
24
+ encoding: UTF-8
25
+ string: |
26
+ {'responseHeader'=>{'status'=>0,'QTime'=>1},'response'=>{'numFound'=>0,'start'=>0,'docs'=>[]}}
27
+ http_version:
28
+ recorded_at: Wed, 11 Nov 2015 00:47:32 GMT
29
+ - request:
30
+ method: get
31
+ uri: http://localhost:8983/solr/select?q=id:%22cb077vs7846%22&wt=ruby
32
+ body:
33
+ encoding: US-ASCII
34
+ string: ''
35
+ headers: {}
36
+ response:
37
+ status:
38
+ code: 200
39
+ message: OK
40
+ headers:
41
+ Last-Modified:
42
+ - Wed, 11 Nov 2015 00:47:09 GMT
43
+ Etag:
44
+ - '"MjkwMDAwMDAwMDAwMDAwU29scg=="'
45
+ Content-Type:
46
+ - text/plain;charset=UTF-8
47
+ Transfer-Encoding:
48
+ - chunked
49
+ body:
50
+ encoding: UTF-8
51
+ string: |
52
+ {'responseHeader'=>{'status'=>0,'QTime'=>1},'response'=>{'numFound'=>0,'start'=>0,'docs'=>[]}}
53
+ http_version:
54
+ recorded_at: Wed, 11 Nov 2015 00:47:32 GMT
55
+ - request:
56
+ method: post
57
+ uri: http://localhost:8983/solr/update?wt=ruby
58
+ body:
59
+ encoding: UTF-8
60
+ string: <?xml version="1.0" encoding="UTF-8"?><add commitWithin="10000"><doc><field
61
+ name="id">cb077vs7846</field><field name="score_isi">10</field><field name="title">First
62
+ title</field></doc></add>
63
+ headers:
64
+ Content-Type:
65
+ - text/xml
66
+ response:
67
+ status:
68
+ code: 200
69
+ message: OK
70
+ headers:
71
+ Content-Type:
72
+ - text/plain;charset=UTF-8
73
+ Transfer-Encoding:
74
+ - chunked
75
+ body:
76
+ encoding: UTF-8
77
+ string: |
78
+ {'responseHeader'=>{'status'=>0,'QTime'=>2}}
79
+ http_version:
80
+ recorded_at: Wed, 11 Nov 2015 00:47:32 GMT
81
+ - request:
82
+ method: post
83
+ uri: http://localhost:8983/solr/update?commit=true
84
+ body:
85
+ encoding: ASCII-8BIT
86
+ string: ''
87
+ headers:
88
+ Accept:
89
+ - application/json
90
+ Accept-Encoding:
91
+ - gzip, deflate
92
+ Content-Type:
93
+ - application/x-www-form-urlencoded
94
+ Content-Length:
95
+ - '0'
96
+ User-Agent:
97
+ - Ruby
98
+ response:
99
+ status:
100
+ code: 200
101
+ message: OK
102
+ headers:
103
+ Content-Type:
104
+ - application/xml; charset=UTF-8
105
+ Transfer-Encoding:
106
+ - chunked
107
+ body:
108
+ encoding: UTF-8
109
+ string: |
110
+ <?xml version="1.0" encoding="UTF-8"?>
111
+ <response>
112
+ <lst name="responseHeader"><int name="status">0</int><int name="QTime">15</int></lst>
113
+ </response>
114
+ http_version:
115
+ recorded_at: Wed, 11 Nov 2015 00:47:32 GMT
116
+ - request:
117
+ method: get
118
+ uri: http://localhost:8983/solr/select?q=id:%22cb077vs7846%22&wt=ruby
119
+ body:
120
+ encoding: US-ASCII
121
+ string: ''
122
+ headers: {}
123
+ response:
124
+ status:
125
+ code: 200
126
+ message: OK
127
+ headers:
128
+ Last-Modified:
129
+ - Wed, 11 Nov 2015 00:47:32 GMT
130
+ Etag:
131
+ - '"NDI5MDAwMDAwMDAwMDAwMFNvbHI="'
132
+ Content-Type:
133
+ - text/plain;charset=UTF-8
134
+ Transfer-Encoding:
135
+ - chunked
136
+ body:
137
+ encoding: UTF-8
138
+ string: |
139
+ {'responseHeader'=>{'status'=>0,'QTime'=>0},'response'=>{'numFound'=>1,'start'=>0,'docs'=>[{'id'=>'cb077vs7846','score_isi'=>10,'title'=>'First title','_version_'=>1517502178483240960,'timestamp'=>'2015-11-11T00:47:32.71Z'}]}}
140
+ http_version:
141
+ recorded_at: Wed, 11 Nov 2015 00:47:32 GMT
142
+ - request:
143
+ method: get
144
+ uri: http://localhost:8983/solr/select?q=id:%22cb077vs7846%22&wt=ruby
145
+ body:
146
+ encoding: US-ASCII
147
+ string: ''
148
+ headers: {}
149
+ response:
150
+ status:
151
+ code: 200
152
+ message: OK
153
+ headers:
154
+ Last-Modified:
155
+ - Wed, 11 Nov 2015 00:47:32 GMT
156
+ Etag:
157
+ - '"NDI5MDAwMDAwMDAwMDAwMFNvbHI="'
158
+ Content-Type:
159
+ - text/plain;charset=UTF-8
160
+ Transfer-Encoding:
161
+ - chunked
162
+ body:
163
+ encoding: UTF-8
164
+ string: |
165
+ {'responseHeader'=>{'status'=>0,'QTime'=>1},'response'=>{'numFound'=>1,'start'=>0,'docs'=>[{'id'=>'cb077vs7846','score_isi'=>10,'title'=>'First title','_version_'=>1517502178483240960,'timestamp'=>'2015-11-11T00:47:32.71Z'}]}}
166
+ http_version:
167
+ recorded_at: Wed, 11 Nov 2015 00:47:32 GMT
168
+ - request:
169
+ method: get
170
+ uri: http://localhost:8983/solr/select?q=id:%22cb077vs7846%22&wt=ruby
171
+ body:
172
+ encoding: US-ASCII
173
+ string: ''
174
+ headers: {}
175
+ response:
176
+ status:
177
+ code: 200
178
+ message: OK
179
+ headers:
180
+ Last-Modified:
181
+ - Wed, 11 Nov 2015 00:47:32 GMT
182
+ Etag:
183
+ - '"NDI5MDAwMDAwMDAwMDAwMFNvbHI="'
184
+ Content-Type:
185
+ - text/plain;charset=UTF-8
186
+ Transfer-Encoding:
187
+ - chunked
188
+ body:
189
+ encoding: UTF-8
190
+ string: |
191
+ {'responseHeader'=>{'status'=>0,'QTime'=>0},'response'=>{'numFound'=>1,'start'=>0,'docs'=>[{'id'=>'cb077vs7846','score_isi'=>10,'title'=>'First title','_version_'=>1517502178483240960,'timestamp'=>'2015-11-11T00:47:32.71Z'}]}}
192
+ http_version:
193
+ recorded_at: Wed, 11 Nov 2015 00:47:32 GMT
194
+ - request:
195
+ method: post
196
+ uri: http://localhost:8983/solr/update?commit=true
197
+ body:
198
+ encoding: UTF-8
199
+ string: '[{"id":"cb077vs7846","title":{"set":["New title"]}}]'
200
+ headers:
201
+ Accept:
202
+ - application/json
203
+ Accept-Encoding:
204
+ - gzip, deflate
205
+ Content-Type:
206
+ - application/json
207
+ Content-Length:
208
+ - '52'
209
+ User-Agent:
210
+ - Ruby
211
+ response:
212
+ status:
213
+ code: 200
214
+ message: OK
215
+ headers:
216
+ Content-Type:
217
+ - application/json; charset=UTF-8
218
+ Transfer-Encoding:
219
+ - chunked
220
+ body:
221
+ encoding: UTF-8
222
+ string: |
223
+ {"responseHeader":{"status":0,"QTime":17}}
224
+ http_version:
225
+ recorded_at: Wed, 11 Nov 2015 00:47:32 GMT
226
+ - request:
227
+ method: post
228
+ uri: http://localhost:8983/solr/update?commit=true
229
+ body:
230
+ encoding: ASCII-8BIT
231
+ string: ''
232
+ headers:
233
+ Accept:
234
+ - application/json
235
+ Accept-Encoding:
236
+ - gzip, deflate
237
+ Content-Type:
238
+ - application/x-www-form-urlencoded
239
+ Content-Length:
240
+ - '0'
241
+ User-Agent:
242
+ - Ruby
243
+ response:
244
+ status:
245
+ code: 200
246
+ message: OK
247
+ headers:
248
+ Content-Type:
249
+ - application/xml; charset=UTF-8
250
+ Transfer-Encoding:
251
+ - chunked
252
+ body:
253
+ encoding: UTF-8
254
+ string: |
255
+ <?xml version="1.0" encoding="UTF-8"?>
256
+ <response>
257
+ <lst name="responseHeader"><int name="status">0</int><int name="QTime">1</int></lst>
258
+ </response>
259
+ http_version:
260
+ recorded_at: Wed, 11 Nov 2015 00:47:32 GMT
261
+ - request:
262
+ method: get
263
+ uri: http://localhost:8983/solr/select?q=id:%22cb077vs7846%22&wt=ruby
264
+ body:
265
+ encoding: US-ASCII
266
+ string: ''
267
+ headers: {}
268
+ response:
269
+ status:
270
+ code: 200
271
+ message: OK
272
+ headers:
273
+ Last-Modified:
274
+ - Wed, 11 Nov 2015 00:47:32 GMT
275
+ Etag:
276
+ - '"NjI5MDAwMDAwMDAwMDAwMFNvbHI="'
277
+ Content-Type:
278
+ - text/plain;charset=UTF-8
279
+ Transfer-Encoding:
280
+ - chunked
281
+ body:
282
+ encoding: UTF-8
283
+ string: |
284
+ {'responseHeader'=>{'status'=>0,'QTime'=>1},'response'=>{'numFound'=>1,'start'=>0,'docs'=>[{'id'=>'cb077vs7846','score_isi'=>10,'title'=>'New title','timestamp'=>'2015-11-11T00:47:32.71Z','_version_'=>1517502178555592704}]}}
285
+ http_version:
286
+ recorded_at: Wed, 11 Nov 2015 00:47:32 GMT
287
+ - request:
288
+ method: get
289
+ uri: http://localhost:8983/solr/select?q=id:%22cb077vs7846%22&wt=ruby
290
+ body:
291
+ encoding: US-ASCII
292
+ string: ''
293
+ headers: {}
294
+ response:
295
+ status:
296
+ code: 200
297
+ message: OK
298
+ headers:
299
+ Last-Modified:
300
+ - Wed, 11 Nov 2015 00:47:32 GMT
301
+ Etag:
302
+ - '"NjI5MDAwMDAwMDAwMDAwMFNvbHI="'
303
+ Content-Type:
304
+ - text/plain;charset=UTF-8
305
+ Transfer-Encoding:
306
+ - chunked
307
+ body:
308
+ encoding: UTF-8
309
+ string: |
310
+ {'responseHeader'=>{'status'=>0,'QTime'=>1},'response'=>{'numFound'=>1,'start'=>0,'docs'=>[{'id'=>'cb077vs7846','score_isi'=>10,'title'=>'New title','timestamp'=>'2015-11-11T00:47:32.71Z','_version_'=>1517502178555592704}]}}
311
+ http_version:
312
+ recorded_at: Wed, 11 Nov 2015 00:47:32 GMT
313
+ recorded_with: VCR 2.9.3
@@ -0,0 +1,112 @@
1
+ # This file was generated by the `rspec --init` command. Conventionally, all
2
+ # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
3
+ # The generated `.rspec` file contains `--require spec_helper` which will cause
4
+ # this file to always be loaded, without a need to explicitly require it in any
5
+ # files.
6
+ #
7
+ # Given that it is always loaded, you are encouraged to keep this file as
8
+ # light-weight as possible. Requiring heavyweight dependencies from this file
9
+ # will add to the boot time of your test suite on EVERY test run, even for an
10
+ # individual file that may not need all of that loaded. Instead, consider making
11
+ # a separate helper file that requires the additional dependencies and performs
12
+ # the additional setup, and require it from the spec files that actually need
13
+ # it.
14
+ #
15
+ # The `.rspec` file also contains a few flags that are not defaults but that
16
+ # users commonly want.
17
+ #
18
+ # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
19
+
20
+ require 'coveralls'
21
+ Coveralls.wear!('rails')
22
+
23
+ require 'engine_cart'
24
+ EngineCart.load_application!
25
+
26
+ require 'vcr'
27
+ VCR.configure do |c|
28
+ c.cassette_library_dir = 'spec/fixtures/vcr_cassettes'
29
+ c.hook_into :webmock
30
+ c.allow_http_connections_when_no_cassette = true
31
+ c.default_cassette_options = { record: :new_episodes, re_record_interval: 28.days }
32
+ c.configure_rspec_metadata!
33
+ end
34
+
35
+ # require 'rspec'
36
+ require 'rspec/rails'
37
+ require 'base_indexer'
38
+
39
+ # require 'rspec/autorun'
40
+ # require 'factory_girl_rails'
41
+
42
+ RSpec.configure do |config|
43
+ # rspec-expectations config goes here. You can use an alternate
44
+ # assertion/expectation library such as wrong or the stdlib/minitest
45
+ # assertions if you prefer.
46
+ config.expect_with :rspec do |expectations|
47
+ # This option will default to `true` in RSpec 4. It makes the `description`
48
+ # and `failure_message` of custom matchers include text for helper methods
49
+ # defined using `chain`, e.g.:
50
+ # be_bigger_than(2).and_smaller_than(4).description
51
+ # # => "be bigger than 2 and smaller than 4"
52
+ # ...rather than:
53
+ # # => "be bigger than 2"
54
+ expectations.include_chain_clauses_in_custom_matcher_descriptions = true
55
+ end
56
+
57
+ # rspec-mocks config goes here. You can use an alternate test double
58
+ # library (such as bogus or mocha) by changing the `mock_with` option here.
59
+ config.mock_with :rspec do |mocks|
60
+ # Prevents you from mocking or stubbing a method that does not exist on
61
+ # a real object. This is generally recommended, and will default to
62
+ # `true` in RSpec 4.
63
+ mocks.verify_partial_doubles = true
64
+ end
65
+
66
+ # The settings below are suggested to provide a good initial experience
67
+ # with RSpec, but feel free to customize to your heart's content.
68
+ # # These two settings work together to allow you to limit a spec run
69
+ # # to individual examples or groups you care about by tagging them with
70
+ # # `:focus` metadata. When nothing is tagged with `:focus`, all examples
71
+ # # get run.
72
+ # config.filter_run :focus
73
+ # config.run_all_when_everything_filtered = true
74
+ #
75
+ # # Limits the available syntax to the non-monkey patched syntax that is
76
+ # # recommended. For more details, see:
77
+ # # - http://myronmars.to/n/dev-blog/2012/06/rspecs-new-expectation-syntax
78
+ # # - http://teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/
79
+ # # - http://myronmars.to/n/dev-blog/2014/05/notable-changes-in-rspec-3#new__config_option_to_disable_rspeccore_monkey_patching
80
+ # config.disable_monkey_patching!
81
+ #
82
+ # # This setting enables warnings. It's recommended, but in some cases may
83
+ # # be too noisy due to issues in dependencies.
84
+ # config.warnings = true
85
+ #
86
+ # # Many RSpec users commonly either run the entire suite or an individual
87
+ # # file, and it's useful to allow more verbose output when running an
88
+ # # individual spec file.
89
+ # if config.files_to_run.one?
90
+ # # Use the documentation formatter for detailed output,
91
+ # # unless a formatter has already been configured
92
+ # # (e.g. via a command-line flag).
93
+ # config.default_formatter = 'doc'
94
+ # end
95
+ #
96
+ # # Print the 10 slowest examples and example groups at the
97
+ # # end of the spec run, to help surface which specs are running
98
+ # # particularly slow.
99
+ # config.profile_examples = 10
100
+ #
101
+ # # Run specs in random order to surface order dependencies. If you find an
102
+ # # order dependency and want to debug it, you can fix the order by providing
103
+ # # the seed, which is printed after each run.
104
+ # # --seed 1234
105
+ # config.order = :random
106
+ #
107
+ # # Seed global randomization in this process using the `--seed` CLI option.
108
+ # # Setting this allows you to use `--seed` to deterministically reproduce
109
+ # # test failures related to randomization by passing the same `--seed` value
110
+ # # as the one that triggered the failure.
111
+ # Kernel.srand config.seed
112
+ end