bento_search 1.7.0 → 2.0.0.rc1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (31) hide show
  1. checksums.yaml +5 -5
  2. data/README.md +2 -6
  3. data/app/assets/javascripts/bento_search/ajax_load.js +17 -1
  4. data/app/controllers/bento_search/search_controller.rb +2 -2
  5. data/app/models/bento_search/concurrent_searcher.rb +2 -2
  6. data/app/models/bento_search/result_item.rb +5 -2
  7. data/app/views/bento_search/_item_title.html.erb +2 -4
  8. data/lib/bento_search/version.rb +1 -1
  9. data/lib/generators/bento_search/install/ajax_load_js_generator.rb +15 -0
  10. data/test/decorator/standard_decorator_test.rb +30 -30
  11. data/test/dummy/app/assets/config/manifest.js +4 -0
  12. data/test/dummy/config/application.rb +7 -0
  13. data/test/dummy/config/environments/development.rb +2 -0
  14. data/test/dummy/config/environments/production.rb +7 -1
  15. data/test/dummy/config/environments/test.rb +10 -3
  16. data/test/functional/bento_search/search_controller_test.rb +5 -1
  17. data/test/search_engines/google_site_search_test.rb +48 -48
  18. data/test/search_engines/scopus_engine_test.rb +51 -51
  19. data/test/support/atom.xsd.xml +3 -3
  20. data/test/support/xml.xsd +117 -0
  21. data/test/view/atom_results_test.rb +94 -94
  22. metadata +27 -49
  23. data/app/assets/javascripts/bento_search.js +0 -3
  24. data/app/item_decorators/bento_search/ebscohost/conditional_openurl_main_link.rb +0 -36
  25. data/app/item_decorators/bento_search/only_premade_openurl.rb +0 -20
  26. data/app/item_decorators/bento_search/openurl_add_other_link.rb +0 -39
  27. data/app/item_decorators/bento_search/openurl_main_link.rb +0 -34
  28. data/app/models/bento_search/multi_searcher.rb +0 -132
  29. data/test/dummy/config/initializers/secret_token.rb +0 -8
  30. data/test/dummy/db/schema.rb +0 -15
  31. data/test/unit/multi_searcher_test.rb +0 -46
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bento_search
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.7.0
4
+ version: 2.0.0.rc1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jonathan Rochkind
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-02-13 00:00:00.000000000 Z
11
+ date: 2021-07-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -16,20 +16,20 @@ dependencies:
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: 3.2.3
19
+ version: '5.2'
20
20
  - - "<"
21
21
  - !ruby/object:Gem::Version
22
- version: '6'
22
+ version: '7'
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
- version: 3.2.3
29
+ version: '5.2'
30
30
  - - "<"
31
31
  - !ruby/object:Gem::Version
32
- version: '6'
32
+ version: '7'
33
33
  - !ruby/object:Gem::Dependency
34
34
  name: confstruct
35
35
  requirement: !ruby/object:Gem::Requirement
@@ -166,44 +166,30 @@ dependencies:
166
166
  requirements:
167
167
  - - "~>"
168
168
  - !ruby/object:Gem::Version
169
- version: '2.4'
169
+ version: '6.0'
170
170
  type: :development
171
171
  prerelease: false
172
172
  version_requirements: !ruby/object:Gem::Requirement
173
173
  requirements:
174
174
  - - "~>"
175
175
  - !ruby/object:Gem::Version
176
- version: '2.4'
176
+ version: '6.0'
177
177
  - !ruby/object:Gem::Dependency
178
178
  name: webmock
179
179
  requirement: !ruby/object:Gem::Requirement
180
180
  requirements:
181
181
  - - "~>"
182
182
  - !ruby/object:Gem::Version
183
- version: 1.11.0
183
+ version: '3.0'
184
184
  type: :development
185
185
  prerelease: false
186
186
  version_requirements: !ruby/object:Gem::Requirement
187
187
  requirements:
188
188
  - - "~>"
189
189
  - !ruby/object:Gem::Version
190
- version: 1.11.0
191
- - !ruby/object:Gem::Dependency
192
- name: celluloid
193
- requirement: !ruby/object:Gem::Requirement
194
- requirements:
195
- - - ">="
196
- - !ruby/object:Gem::Version
197
- version: '0'
198
- type: :development
199
- prerelease: false
200
- version_requirements: !ruby/object:Gem::Requirement
201
- requirements:
202
- - - ">="
203
- - !ruby/object:Gem::Version
204
- version: '0'
205
- description:
206
- email:
190
+ version: '3.0'
191
+ description:
192
+ email:
207
193
  executables: []
208
194
  extensions: []
209
195
  extra_rdoc_files: []
@@ -212,23 +198,17 @@ files:
212
198
  - README.md
213
199
  - Rakefile
214
200
  - app/assets/images/bento_search/large_loader.gif
215
- - app/assets/javascripts/bento_search.js
216
201
  - app/assets/javascripts/bento_search/ajax_load.js
217
202
  - app/assets/stylesheets/bento_search/suggested_styles.css
218
203
  - app/controllers/bento_search/bento_search_controller.rb
219
204
  - app/controllers/bento_search/search_controller.rb
220
205
  - app/helpers/bento_search_helper.rb
221
206
  - app/item_decorators/bento_search/decorator_base.rb
222
- - app/item_decorators/bento_search/ebscohost/conditional_openurl_main_link.rb
223
207
  - app/item_decorators/bento_search/no_links.rb
224
- - app/item_decorators/bento_search/only_premade_openurl.rb
225
- - app/item_decorators/bento_search/openurl_add_other_link.rb
226
- - app/item_decorators/bento_search/openurl_main_link.rb
227
208
  - app/item_decorators/bento_search/standard_decorator.rb
228
209
  - app/models/bento_search/author.rb
229
210
  - app/models/bento_search/concurrent_searcher.rb
230
211
  - app/models/bento_search/link.rb
231
- - app/models/bento_search/multi_searcher.rb
232
212
  - app/models/bento_search/openurl_creator.rb
233
213
  - app/models/bento_search/registrar.rb
234
214
  - app/models/bento_search/result_item.rb
@@ -266,6 +246,7 @@ files:
266
246
  - lib/bento_search/routes.rb
267
247
  - lib/bento_search/util.rb
268
248
  - lib/bento_search/version.rb
249
+ - lib/generators/bento_search/install/ajax_load_js_generator.rb
269
250
  - lib/generators/bento_search/pull_ebsco_dbs_generator.rb
270
251
  - lib/generators/bento_search/templates/ebsco_global_var.erb
271
252
  - lib/http_client_patch/include_client.rb
@@ -274,6 +255,7 @@ files:
274
255
  - test/decorator/standard_decorator_test.rb
275
256
  - test/dummy/README.rdoc
276
257
  - test/dummy/Rakefile
258
+ - test/dummy/app/assets/config/manifest.js
277
259
  - test/dummy/app/assets/javascripts/application.js
278
260
  - test/dummy/app/assets/stylesheets/application.css
279
261
  - test/dummy/app/controllers/application_controller.rb
@@ -291,12 +273,10 @@ files:
291
273
  - test/dummy/config/initializers/backtrace_silencers.rb
292
274
  - test/dummy/config/initializers/inflections.rb
293
275
  - test/dummy/config/initializers/mime_types.rb
294
- - test/dummy/config/initializers/secret_token.rb
295
276
  - test/dummy/config/initializers/session_store.rb
296
277
  - test/dummy/config/initializers/wrap_parameters.rb
297
278
  - test/dummy/config/locales/en.yml
298
279
  - test/dummy/config/routes.rb
299
- - test/dummy/db/schema.rb
300
280
  - test/dummy/public/404.html
301
281
  - test/dummy/public/422.html
302
282
  - test/dummy/public/500.html
@@ -320,11 +300,11 @@ files:
320
300
  - test/search_engines/xerxes_engine_test.rb
321
301
  - test/support/atom.xsd.xml
322
302
  - test/support/test_with_cassette.rb
303
+ - test/support/xml.xsd
323
304
  - test/test_helper.rb
324
305
  - test/unit/concurrent_searcher_test.rb
325
306
  - test/unit/handle_highlight_tags_test.rb
326
307
  - test/unit/item_decorators_test.rb
327
- - test/unit/multi_searcher_test.rb
328
308
  - test/unit/openurl_creator_test.rb
329
309
  - test/unit/pagination_test.rb
330
310
  - test/unit/register_engine_test.rb
@@ -410,7 +390,7 @@ files:
410
390
  homepage: http://github.com/jrochkind/bento_search
411
391
  licenses: []
412
392
  metadata: {}
413
- post_install_message:
393
+ post_install_message:
414
394
  rdoc_options: []
415
395
  require_paths:
416
396
  - lib
@@ -421,19 +401,21 @@ required_ruby_version: !ruby/object:Gem::Requirement
421
401
  version: '0'
422
402
  required_rubygems_version: !ruby/object:Gem::Requirement
423
403
  requirements:
424
- - - ">="
404
+ - - ">"
425
405
  - !ruby/object:Gem::Version
426
- version: '0'
406
+ version: 1.3.1
427
407
  requirements: []
428
- rubyforge_project:
429
- rubygems_version: 2.5.2
430
- signing_key:
408
+ rubygems_version: 3.2.22
409
+ signing_key:
431
410
  specification_version: 4
432
411
  summary: An abstraction/normalization layer for querying and displaying results for
433
412
  external search engines, in Ruby on Rails.
434
413
  test_files:
435
414
  - test/decorator/decorator_base_test.rb
436
415
  - test/decorator/standard_decorator_test.rb
416
+ - test/dummy/README.rdoc
417
+ - test/dummy/Rakefile
418
+ - test/dummy/app/assets/config/manifest.js
437
419
  - test/dummy/app/assets/javascripts/application.js
438
420
  - test/dummy/app/assets/stylesheets/application.css
439
421
  - test/dummy/app/controllers/application_controller.rb
@@ -450,19 +432,15 @@ test_files:
450
432
  - test/dummy/config/initializers/backtrace_silencers.rb
451
433
  - test/dummy/config/initializers/inflections.rb
452
434
  - test/dummy/config/initializers/mime_types.rb
453
- - test/dummy/config/initializers/secret_token.rb
454
435
  - test/dummy/config/initializers/session_store.rb
455
436
  - test/dummy/config/initializers/wrap_parameters.rb
456
437
  - test/dummy/config/locales/en.yml
457
438
  - test/dummy/config/routes.rb
458
439
  - test/dummy/config.ru
459
- - test/dummy/db/schema.rb
460
440
  - test/dummy/public/404.html
461
441
  - test/dummy/public/422.html
462
442
  - test/dummy/public/500.html
463
443
  - test/dummy/public/favicon.ico
464
- - test/dummy/Rakefile
465
- - test/dummy/README.rdoc
466
444
  - test/dummy/script/rails
467
445
  - test/functional/bento_search/search_controller_test.rb
468
446
  - test/helper/bento_search_helper_test.rb
@@ -482,11 +460,11 @@ test_files:
482
460
  - test/search_engines/xerxes_engine_test.rb
483
461
  - test/support/atom.xsd.xml
484
462
  - test/support/test_with_cassette.rb
463
+ - test/support/xml.xsd
485
464
  - test/test_helper.rb
486
465
  - test/unit/concurrent_searcher_test.rb
487
466
  - test/unit/handle_highlight_tags_test.rb
488
467
  - test/unit/item_decorators_test.rb
489
- - test/unit/multi_searcher_test.rb
490
468
  - test/unit/openurl_creator_test.rb
491
469
  - test/unit/pagination_test.rb
492
470
  - test/unit/register_engine_test.rb
@@ -500,6 +478,7 @@ test_files:
500
478
  - test/vcr_cassettes/doaj_articles/live_get_identifier__raises_on_no_results.yml
501
479
  - test/vcr_cassettes/doaj_articles/multifield_author-title.yml
502
480
  - test/vcr_cassettes/doaj_articles/pagination.yml
481
+ - test/vcr_cassettes/ebscohost/RILM_record_with_ISSN_in__jid__element.yml
503
482
  - test/vcr_cassettes/ebscohost/affiliation_search.yml
504
483
  - test/vcr_cassettes/ebscohost/another_dissertation.yml
505
484
  - test/vcr_cassettes/ebscohost/dissertation_example.yml
@@ -517,11 +496,10 @@ test_files:
517
496
  - test/vcr_cassettes/ebscohost/live_search_smoke_test.yml
518
497
  - test/vcr_cassettes/ebscohost/multi-field_author_title.yml
519
498
  - test/vcr_cassettes/ebscohost/multi-field_citation_numbers.yml
520
- - test/vcr_cassettes/ebscohost/RILM_record_with_ISSN_in__jid__element.yml
499
+ - test/vcr_cassettes/eds/FullText_CustomLink.yml
521
500
  - test/vcr_cassettes/eds/basic_search_smoke_test.yml
522
501
  - test/vcr_cassettes/eds/catalog_ebook_query.yml
523
502
  - test/vcr_cassettes/eds/catalog_query.yml
524
- - test/vcr_cassettes/eds/FullText_CustomLink.yml
525
503
  - test/vcr_cassettes/eds/get_auth_token.yml
526
504
  - test/vcr_cassettes/eds/get_auth_token_failure.yml
527
505
  - test/vcr_cassettes/eds/get_with_auth.yml
@@ -1,3 +0,0 @@
1
- // require all bento_search javascript.
2
- //
3
- //= require_tree ./bento_search
@@ -1,36 +0,0 @@
1
- # DEPRECATED. Just write the logic into a custom Decorator yourself.
2
- # See wiki on decorators.
3
- #
4
- #
5
- # For ebscohost connector, example of an Item Decorator that replaces the main
6
- # 'link' with an openurl ONLY if there is NOT fulltext avail from EBSCO.
7
- #
8
- # This example uses crazy metaprogramming to dynamically create
9
- # a module configured with your base url etc. You don't need to use
10
- # crazy method like that; just define your own local decorator doing
11
- # exactly what you need, it's meant to be simple.
12
- #
13
- # config.item_decorators = [ BentoSearch::Ebscohost::ConditionalOpenurlMainLink[:base_url => "http://resolve.somewhere.edu/foo", :extra_query => "&foo=bar"] ]
14
- #
15
- module BentoSearch::Ebscohost::ConditionalOpenurlMainLink
16
- def self.[](options)
17
- base_url = options[:base_url]
18
- extra_query = options[:extra_query] || ""
19
- Module.new do
20
-
21
- define_method :link do
22
- if custom_data["fulltext_formats"]
23
- super()
24
- elsif (ou = to_openurl)
25
- "#{base_url}?#{ou.kev}#{extra_query}"
26
- else
27
- nil
28
- end
29
- end
30
-
31
- end
32
- end
33
-
34
-
35
-
36
- end
@@ -1,20 +0,0 @@
1
- # DEPRECATED. Just write the logic into a custom Decorator yourself.
2
- # See wiki on decorators.
3
-
4
-
5
- require 'openurl'
6
-
7
- # A Decorator that will make #to_openurl refuse to construct
8
- # an openurl from individual elements, it'll use the #openurl_kev_co
9
- # or nothing.
10
- module BentoSearch::OnlyPremadeOpenurl
11
-
12
- def to_openurl
13
- if self.openurl_kev_co
14
- return OpenURL::ContextObject.new_from_kev( self.openurl_kev_co )
15
- else
16
- return nil
17
- end
18
- end
19
-
20
- end
@@ -1,39 +0,0 @@
1
- # DEPRECATED. Just write the logic into a custom Decorator yourself.
2
- # See wiki on decorators.
3
- #
4
- #
5
- # Example of an Item Decorator that ADDs an 'other link' with an openurl.
6
- #
7
- # This example uses crazy metaprogramming to dynamically create
8
- # a module configured with your base url etc. You don't need to use
9
- # crazy method like that; just define your own local decorator doing
10
- # exactly what you need, it's meant to be simple.
11
- #
12
- # config.item_decorators = [ BentoSearch::OpenurlAddOtherLink[:base_url => "http://resolve.somewhere.edu/foo", :extra_query => "&foo=bar"] ]
13
- #
14
- module BentoSearch::OpenurlAddOtherLink
15
- def self.[](options)
16
- base_url = options[:base_url]
17
- extra_query = options[:extra_query] || ""
18
- link_name = options[:link_name] || "Find It"
19
- # overwrite: if true, overwrite previously existing other_links, if
20
- # false add on to previously existing.
21
- overwrite = options.has_key?(:overwrite) ? options[:overwrite] : false
22
-
23
- Module.new do
24
-
25
- define_method :other_links do
26
- start = overwrite ? [] : super()
27
- if (ou = to_openurl)
28
- start + [BentoSearch::Link.new(:url => "#{base_url}?#{ou.kev}#{extra_query}", :label => link_name)]
29
- else
30
- start
31
- end
32
- end
33
-
34
- end
35
- end
36
-
37
-
38
-
39
- end
@@ -1,34 +0,0 @@
1
- # DEPRECATED. Just write the logic into a custom Decorator yourself.
2
- # See wiki on decorators.
3
-
4
-
5
- # Example of an Item Decorator that replaces the main 'link'
6
- # with an openurl.
7
- #
8
- # This example uses crazy metaprogramming to dynamically create
9
- # a module configured with your base url etc. You don't need to use
10
- # crazy method like that; just define your own local decorator doing
11
- # exactly what you need, it's meant to be simple.
12
- #
13
- # config.item_decorators = [ BentoSearch::OpenurlMainLink[:base_url => "http://resolve.somewhere.edu/foo", :extra_query => "&foo=bar"] ]
14
- #
15
- module BentoSearch::OpenurlMainLink
16
- def self.[](options)
17
- base_url = options[:base_url]
18
- extra_query = options[:extra_query] || ""
19
- Module.new do
20
-
21
- define_method :link do
22
- if (ou = to_openurl)
23
- "#{base_url}?#{ou.kev}#{extra_query}"
24
- else
25
- nil
26
- end
27
- end
28
-
29
- end
30
- end
31
-
32
-
33
-
34
- end
@@ -1,132 +0,0 @@
1
- begin
2
- require 'celluloid'
3
-
4
- # Based on Celluloid, concurrently runs multiple searches in
5
- # seperate threads. You must include 'celluloid' gem dependency
6
- # into your local app to use this class. Requires celluloid 0.12.0
7
- # or above (for new preferred async syntax).
8
- #
9
- # Warning, if you don't have celluloid in your app, this class simply
10
- # won't load. TODO: We should put this file in a different directory
11
- # so it's never auto-loaded, and requires a "require 'bento_search/multi_searcher'",
12
- # such that it will raise without celluloid only then, and we don't need this
13
- # rescue LoadError stuff.
14
- #
15
- # I am not an expert at use of Celluloid, it's possible there's a better
16
- # way to do this all, but seems to work.
17
- #
18
- # ## Usage
19
- #
20
- # initialize with id's of registered engines:
21
- # searcher = BentoBox::MultiSearcher.new(:gbs, :scopus)
22
- #
23
- # start the concurrent searches, params same as engine.search
24
- # searcher.search( query_params )
25
- #
26
- # retrieve results, blocking until each is completed:
27
- # searcher.results
28
- #
29
- # returns a Hash keyed by engine id, values BentoSearch::Results objects.
30
- #
31
- # Can only call #results once per #start, after that it'll return empty hash.
32
- # (should we make it actually raise instead?). .
33
- #
34
- # important to call results at some point after calling start, in order
35
- # to make sure Celluloid::Actors are properly terminated to avoid
36
- # resource leakage. May want to do it in an ensure block.
37
- #
38
- # Note that celluloid uses multi-threading in such a way that you
39
- # may have to set config.cache_classes=true even in development
40
- # to avoid problems. Rails class reloading is not thread-safe.
41
- #
42
- #
43
- # TODO: have a method that returns Futures instead of only supplying the blocking
44
- # results method? Several tricks, including making sure to properly terminate actors.
45
- class BentoSearch::MultiSearcher
46
-
47
- def initialize(*engine_ids)
48
- ActiveSupport::Deprecation.warn('BentoSearch::MultiSearcher is deprecated and will be removed in bento_search 2.0. Please use BentoSearch::ConcurrentSearcher instead.', caller.slice(1..-1))
49
-
50
- @engines = []
51
- @actors = []
52
- engine_ids.each do |id|
53
- add_engine( BentoSearch.get_engine id )
54
- end
55
- end
56
-
57
- # Adds an instantiated engine directly, rather than by id from global
58
- # registry.
59
- def add_engine(engine)
60
- @engines << engine
61
- end
62
-
63
- # Starts all searches, returns self so you can chain method calls if you like.
64
- def search(*search_args)
65
- @engines.each do |engine|
66
- a = Actor.new(engine)
67
- @actors << a
68
- a.async.start *search_args
69
- end
70
- return self
71
- end
72
- alias_method :start, :search # backwards compat
73
-
74
- # Call after #start. Blocks until each included engine is finished
75
- # then returns a Hash keyed by engine registered id, value is a
76
- # BentoSearch::Results object.
77
- #
78
- # Can only call _once_ per invocation of #start, after that it'll return
79
- # an empty hash.
80
- def results
81
- results = {}
82
-
83
- # we use #delete_if to get an iterator that deletes
84
- # each item after iteration.
85
- @actors.delete_if do |actor|
86
- result_key = (actor.engine.configuration.id || actor.engine.class.name)
87
- results[result_key] = actor.results
88
- actor.terminate
89
-
90
- true
91
- end
92
-
93
- return results
94
- end
95
-
96
-
97
- class Actor
98
- include Celluloid
99
-
100
- attr_accessor :engine
101
-
102
- def initialize(a_engine)
103
- self.engine = a_engine
104
- end
105
-
106
- # call as .async.start, to invoke async.
107
- def start(*search_args)
108
- begin
109
- @results = self.engine.search(*search_args)
110
- rescue StandardError => e
111
- Rails.logger.error("\nBentoSearch:MultiSearcher caught exception: #{e}\n#{e.backtrace.join(" \n")}")
112
- # Make a fake results with caught exception.
113
- @results = BentoSearch::Results.new
114
- self.engine.fill_in_search_metadata_for(@results, self.engine.normalized_search_arguments(search_args))
115
-
116
- @results.error ||= {}
117
- @results.error["exception"] = e
118
- end
119
- end
120
-
121
- def results
122
- @results
123
- end
124
-
125
- end
126
- end
127
-
128
- rescue LoadError
129
- # you can use bento_search without celluloid, just not
130
- # this class.
131
- end
132
-