bento_search 0.6.0 → 0.7.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.
- data/README.md +131 -74
- data/app/assets/javascripts/bento_search/ajax_load.js +12 -4
- data/app/assets/stylesheets/bento_search/suggested_styles.css +4 -4
- data/app/helpers/bento_search_helper.rb +114 -27
- data/app/item_decorators/bento_search/decorator_base.rb +53 -0
- data/app/item_decorators/bento_search/ebscohost/conditional_openurl_main_link.rb +36 -0
- data/app/item_decorators/bento_search/no_links.rb +3 -2
- data/app/item_decorators/bento_search/only_premade_openurl.rb +4 -0
- data/app/item_decorators/bento_search/openurl_add_other_link.rb +4 -0
- data/app/item_decorators/bento_search/openurl_main_link.rb +4 -0
- data/app/item_decorators/bento_search/standard_decorator.rb +122 -0
- data/app/models/bento_search/multi_searcher.rb +13 -6
- data/app/models/bento_search/openurl_creator.rb +25 -5
- data/app/models/bento_search/result_item.rb +25 -83
- data/app/models/bento_search/results/pagination.rb +8 -2
- data/app/models/bento_search/search_engine.rb +29 -23
- data/app/search_engines/bento_search/ebsco_host_engine.rb +161 -25
- data/app/search_engines/bento_search/eds_engine.rb +1 -44
- data/app/search_engines/bento_search/google_books_engine.rb +61 -14
- data/app/search_engines/bento_search/google_site_search_engine.rb +3 -1
- data/app/search_engines/bento_search/mock_engine.rb +4 -0
- data/app/search_engines/bento_search/primo_engine.rb +2 -3
- data/app/search_engines/bento_search/scopus_engine.rb +1 -0
- data/app/search_engines/bento_search/summon_engine.rb +5 -1
- data/app/search_engines/bento_search/worldcat_sru_dc_engine.rb +36 -8
- data/app/views/bento_search/_item_title.html.erb +29 -0
- data/app/views/bento_search/_no_results.html.erb +3 -0
- data/app/views/bento_search/_search_error.html.erb +19 -15
- data/app/views/bento_search/_std_item.html.erb +55 -30
- data/app/views/bento_search/search/search.html.erb +7 -0
- data/config/locales/en.yml +22 -0
- data/lib/bento_search/util.rb +63 -1
- data/lib/bento_search/version.rb +1 -1
- data/test/decorator/decorator_base_test.rb +72 -0
- data/test/decorator/standard_decorator_test.rb +55 -0
- data/test/dummy/db/development.sqlite3 +0 -0
- data/test/dummy/log/development.log +12 -0
- data/test/dummy/log/test.log +119757 -0
- data/test/functional/bento_search/search_controller_test.rb +28 -0
- data/test/helper/bento_search_helper_test.rb +71 -0
- data/test/helper/bento_truncate_helper_test.rb +71 -0
- data/test/unit/ebsco_host_engine_test.rb +110 -3
- data/test/unit/google_books_engine_test.rb +22 -14
- data/test/unit/google_site_search_test.rb +11 -4
- data/test/unit/item_decorators_test.rb +6 -65
- data/test/unit/openurl_creator_test.rb +87 -8
- data/test/unit/result_item_test.rb +1 -11
- data/test/unit/search_engine_base_test.rb +25 -2
- data/test/unit/search_engine_test.rb +16 -0
- data/test/unit/summon_engine_test.rb +3 -0
- data/test/vcr_cassettes/ebscohost/another_dissertation.yml +148 -0
- data/test/vcr_cassettes/ebscohost/dissertation_example.yml +218 -0
- data/test/vcr_cassettes/ebscohost/fulltext_info.yml +1306 -0
- data/test/vcr_cassettes/ebscohost/live_book_example.yml +130 -0
- data/test/vcr_cassettes/ebscohost/live_dissertation.yml +148 -0
- data/test/vcr_cassettes/ebscohost/live_pathological_book_item_example.yml +215 -0
- data/test/vcr_cassettes/google_site/gets_format_string.yml +232 -0
- data/test/vcr_cassettes/max_out_pagination.yml +155 -0
- data/test/vcr_cassettes/worldcat_sru_dc/max_out_pagination.yml +167 -0
- data/test/view/std_item_test.rb +25 -8
- metadata +45 -12
- data/test/unit/result_item_display_test.rb +0 -39
- data/test/unit/worldcat_sru_dc_engine_test.rb +0 -120
data/test/view/std_item_test.rb
CHANGED
@@ -12,8 +12,10 @@ class StdItemTest < ActionView::TestCase
|
|
12
12
|
assert_select ".bento_item_title", item.title do
|
13
13
|
assert_select "a", false
|
14
14
|
end
|
15
|
+
|
16
|
+
|
15
17
|
# No author/title/etc rows, cause we don't have data
|
16
|
-
assert_select ".
|
18
|
+
assert_select ".authors", false
|
17
19
|
assert_select ".bento_item_key_meta", false
|
18
20
|
|
19
21
|
assert_select ".bento_item_row", false
|
@@ -24,16 +26,28 @@ class StdItemTest < ActionView::TestCase
|
|
24
26
|
assert_select(".bento_item_other_links", 0)
|
25
27
|
end
|
26
28
|
|
29
|
+
def test_has_counter_when_results_passed_in
|
30
|
+
results = BentoSearch::Results.new
|
31
|
+
results.start = 9
|
32
|
+
results << (item = BentoSearch::ResultItem.new(:title => "Some Title"))
|
33
|
+
|
34
|
+
render :partial => "bento_search/std_item", :object => item, :as => "item", :locals => { :results => results, :item_counter => 5}
|
35
|
+
|
36
|
+
assert_select ".bento_index", :text => "15."
|
37
|
+
end
|
38
|
+
|
27
39
|
def test_complete_article_item
|
28
40
|
hash = {}
|
29
41
|
hash[:title] = "Some Title"
|
30
42
|
hash[:link] = "http://example.org/1"
|
43
|
+
hash[:year] = "2001"
|
31
44
|
hash[:journal_title] = "Journal of Invalid Results"
|
32
45
|
hash[:volume] = "10"
|
33
46
|
hash[:issue] = "1"
|
34
47
|
hash[:start_page] = "101"
|
35
48
|
hash[:end_page] = "120"
|
36
49
|
hash[:format] = "MusicRecording"
|
50
|
+
hash[:abstract] = "This is an abstract."
|
37
51
|
item = BentoSearch::ResultItem.new( hash )
|
38
52
|
item.authors.push BentoSearch::Author.new(:display => "Smith, J.")
|
39
53
|
|
@@ -46,14 +60,17 @@ class StdItemTest < ActionView::TestCase
|
|
46
60
|
|
47
61
|
# Make sure we have the items for complete citation
|
48
62
|
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
63
|
+
assert_select ".bento_item_row.first_about" do
|
64
|
+
assert_select ".authors"
|
65
|
+
assert_select ".date"
|
66
|
+
end
|
54
67
|
|
55
|
-
assert_select ".bento_item_row"
|
56
|
-
|
68
|
+
assert_select ".bento_item_row.abstract"
|
69
|
+
|
70
|
+
assert_select ".bento_item_about" ,
|
71
|
+
Regexp.new(Regexp.escape( I18n.t(item.format, :scope => [:bento_search, :format]) ))
|
72
|
+
|
73
|
+
assert_select ".bento_item_row.second_about"
|
57
74
|
end
|
58
75
|
|
59
76
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bento_search
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.7.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-12-26 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|
@@ -70,17 +70,23 @@ dependencies:
|
|
70
70
|
requirement: !ruby/object:Gem::Requirement
|
71
71
|
none: false
|
72
72
|
requirements:
|
73
|
-
- -
|
73
|
+
- - ! '>='
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: 1.0.4
|
76
|
+
- - <
|
74
77
|
- !ruby/object:Gem::Version
|
75
|
-
version: '
|
78
|
+
version: '2.0'
|
76
79
|
type: :runtime
|
77
80
|
prerelease: false
|
78
81
|
version_requirements: !ruby/object:Gem::Requirement
|
79
82
|
none: false
|
80
83
|
requirements:
|
81
|
-
- -
|
84
|
+
- - ! '>='
|
85
|
+
- !ruby/object:Gem::Version
|
86
|
+
version: 1.0.4
|
87
|
+
- - <
|
82
88
|
- !ruby/object:Gem::Version
|
83
|
-
version: '
|
89
|
+
version: '2.0'
|
84
90
|
- !ruby/object:Gem::Dependency
|
85
91
|
name: nokogiri
|
86
92
|
requirement: !ruby/object:Gem::Requirement
|
@@ -221,9 +227,11 @@ files:
|
|
221
227
|
- app/models/bento_search/openurl_creator.rb
|
222
228
|
- app/models/bento_search/author.rb
|
223
229
|
- app/models/bento_search/search_engine.rb
|
230
|
+
- app/views/bento_search/_no_results.html.erb
|
224
231
|
- app/views/bento_search/_wrap_with_count.html.erb
|
225
232
|
- app/views/bento_search/_search_error.html.erb
|
226
233
|
- app/views/bento_search/search/search.html.erb
|
234
|
+
- app/views/bento_search/_item_title.html.erb
|
227
235
|
- app/views/bento_search/_std_item.html.erb
|
228
236
|
- app/views/bento_search/_link.html.erb
|
229
237
|
- app/helpers/bento_search_helper.rb
|
@@ -237,6 +245,9 @@ files:
|
|
237
245
|
- app/search_engines/bento_search/eds_engine.rb
|
238
246
|
- app/search_engines/bento_search/mock_engine.rb
|
239
247
|
- app/search_engines/bento_search/xerxes_engine.rb
|
248
|
+
- app/item_decorators/bento_search/standard_decorator.rb
|
249
|
+
- app/item_decorators/bento_search/ebscohost/conditional_openurl_main_link.rb
|
250
|
+
- app/item_decorators/bento_search/decorator_base.rb
|
240
251
|
- app/item_decorators/bento_search/openurl_add_other_link.rb
|
241
252
|
- app/item_decorators/bento_search/openurl_main_link.rb
|
242
253
|
- app/item_decorators/bento_search/only_premade_openurl.rb
|
@@ -286,20 +297,29 @@ files:
|
|
286
297
|
- test/dummy/script/rails
|
287
298
|
- test/dummy/config.ru
|
288
299
|
- test/dummy/db/test.sqlite3
|
300
|
+
- test/dummy/db/development.sqlite3
|
289
301
|
- test/dummy/log/test.log
|
290
302
|
- test/dummy/log/development.log
|
291
303
|
- test/helper/bento_search_helper_test.rb
|
304
|
+
- test/helper/bento_truncate_helper_test.rb
|
292
305
|
- test/vcr_cassettes/summon/proper_tags_for_snippets.yml
|
293
306
|
- test/vcr_cassettes/summon/search.yml
|
294
307
|
- test/vcr_cassettes/summon/bad_auth.yml
|
295
308
|
- test/vcr_cassettes/xerxes/live_search.yml
|
296
309
|
- test/vcr_cassettes/worldcat_sru_dc/smoke_test.yml
|
310
|
+
- test/vcr_cassettes/worldcat_sru_dc/max_out_pagination.yml
|
297
311
|
- test/vcr_cassettes/primo/search_smoke_test.yml
|
298
312
|
- test/vcr_cassettes/primo/proper_tags_for_snippets.yml
|
313
|
+
- test/vcr_cassettes/ebscohost/another_dissertation.yml
|
299
314
|
- test/vcr_cassettes/ebscohost/live_search.yml
|
315
|
+
- test/vcr_cassettes/ebscohost/fulltext_info.yml
|
300
316
|
- test/vcr_cassettes/ebscohost/error_bad_db.yml
|
317
|
+
- test/vcr_cassettes/ebscohost/live_pathological_book_item_example.yml
|
301
318
|
- test/vcr_cassettes/ebscohost/error_bad_password.yml
|
319
|
+
- test/vcr_cassettes/ebscohost/dissertation_example.yml
|
320
|
+
- test/vcr_cassettes/ebscohost/live_dissertation.yml
|
302
321
|
- test/vcr_cassettes/ebscohost/get_info.yml
|
322
|
+
- test/vcr_cassettes/ebscohost/live_book_example.yml
|
303
323
|
- test/vcr_cassettes/ebscohost/live_search_smoke_test.yml
|
304
324
|
- test/vcr_cassettes/eds/basic_search_smoke_test.yml
|
305
325
|
- test/vcr_cassettes/eds/get_auth_token.yml
|
@@ -308,6 +328,7 @@ files:
|
|
308
328
|
- test/vcr_cassettes/eds/get_with_auth_recovers_from_bad_auth.yml
|
309
329
|
- test/vcr_cassettes/google_site/empty_result_set.yml
|
310
330
|
- test/vcr_cassettes/google_site/without_highlighting.yml
|
331
|
+
- test/vcr_cassettes/google_site/gets_format_string.yml
|
311
332
|
- test/vcr_cassettes/google_site/with_highlighting.yml
|
312
333
|
- test/vcr_cassettes/google_site/basic_smoke_test.yml
|
313
334
|
- test/vcr_cassettes/google_site/pagination_object_is_correct_for_actual_page_when_you_ask_for_too_far.yml
|
@@ -316,11 +337,11 @@ files:
|
|
316
337
|
- test/vcr_cassettes/scopus/bad_api_key_should_return_error_response.yml
|
317
338
|
- test/vcr_cassettes/scopus/escaped_chars.yml
|
318
339
|
- test/vcr_cassettes/scopus/zero_results_search.yml
|
340
|
+
- test/vcr_cassettes/max_out_pagination.yml
|
319
341
|
- test/vcr_cassettes/gbs/pagination.yml
|
320
342
|
- test/vcr_cassettes/gbs/error_condition.yml
|
321
343
|
- test/vcr_cassettes/gbs/search.yml
|
322
344
|
- test/vcr_cassettes/gbs/empty_results.yml
|
323
|
-
- test/unit/result_item_display_test.rb
|
324
345
|
- test/unit/eds_engine_test.rb
|
325
346
|
- test/unit/result_item_test.rb
|
326
347
|
- test/unit/item_decorators_test.rb
|
@@ -328,7 +349,6 @@ files:
|
|
328
349
|
- test/unit/google_site_search_test.rb
|
329
350
|
- test/unit/search_engine_test.rb
|
330
351
|
- test/unit/search_engine_base_test.rb
|
331
|
-
- test/unit/worldcat_sru_dc_engine_test.rb
|
332
352
|
- test/unit/register_engine_test.rb
|
333
353
|
- test/unit/google_books_engine_test.rb
|
334
354
|
- test/unit/summon_engine_test.rb
|
@@ -340,6 +360,8 @@ files:
|
|
340
360
|
- test/unit/multi_searcher_test.rb
|
341
361
|
- test/unit/pagination_test.rb
|
342
362
|
- test/test_helper.rb
|
363
|
+
- test/decorator/standard_decorator_test.rb
|
364
|
+
- test/decorator/decorator_base_test.rb
|
343
365
|
- test/functional/bento_search/search_controller_test.rb
|
344
366
|
homepage: http://github.com/jrochkind/bento_search
|
345
367
|
licenses: []
|
@@ -355,7 +377,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
355
377
|
version: '0'
|
356
378
|
segments:
|
357
379
|
- 0
|
358
|
-
hash:
|
380
|
+
hash: 328039758736182277
|
359
381
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
360
382
|
none: false
|
361
383
|
requirements:
|
@@ -364,7 +386,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
364
386
|
version: '0'
|
365
387
|
segments:
|
366
388
|
- 0
|
367
|
-
hash:
|
389
|
+
hash: 328039758736182277
|
368
390
|
requirements: []
|
369
391
|
rubyforge_project:
|
370
392
|
rubygems_version: 1.8.24
|
@@ -405,20 +427,29 @@ test_files:
|
|
405
427
|
- test/dummy/script/rails
|
406
428
|
- test/dummy/config.ru
|
407
429
|
- test/dummy/db/test.sqlite3
|
430
|
+
- test/dummy/db/development.sqlite3
|
408
431
|
- test/dummy/log/test.log
|
409
432
|
- test/dummy/log/development.log
|
410
433
|
- test/helper/bento_search_helper_test.rb
|
434
|
+
- test/helper/bento_truncate_helper_test.rb
|
411
435
|
- test/vcr_cassettes/summon/proper_tags_for_snippets.yml
|
412
436
|
- test/vcr_cassettes/summon/search.yml
|
413
437
|
- test/vcr_cassettes/summon/bad_auth.yml
|
414
438
|
- test/vcr_cassettes/xerxes/live_search.yml
|
415
439
|
- test/vcr_cassettes/worldcat_sru_dc/smoke_test.yml
|
440
|
+
- test/vcr_cassettes/worldcat_sru_dc/max_out_pagination.yml
|
416
441
|
- test/vcr_cassettes/primo/search_smoke_test.yml
|
417
442
|
- test/vcr_cassettes/primo/proper_tags_for_snippets.yml
|
443
|
+
- test/vcr_cassettes/ebscohost/another_dissertation.yml
|
418
444
|
- test/vcr_cassettes/ebscohost/live_search.yml
|
445
|
+
- test/vcr_cassettes/ebscohost/fulltext_info.yml
|
419
446
|
- test/vcr_cassettes/ebscohost/error_bad_db.yml
|
447
|
+
- test/vcr_cassettes/ebscohost/live_pathological_book_item_example.yml
|
420
448
|
- test/vcr_cassettes/ebscohost/error_bad_password.yml
|
449
|
+
- test/vcr_cassettes/ebscohost/dissertation_example.yml
|
450
|
+
- test/vcr_cassettes/ebscohost/live_dissertation.yml
|
421
451
|
- test/vcr_cassettes/ebscohost/get_info.yml
|
452
|
+
- test/vcr_cassettes/ebscohost/live_book_example.yml
|
422
453
|
- test/vcr_cassettes/ebscohost/live_search_smoke_test.yml
|
423
454
|
- test/vcr_cassettes/eds/basic_search_smoke_test.yml
|
424
455
|
- test/vcr_cassettes/eds/get_auth_token.yml
|
@@ -427,6 +458,7 @@ test_files:
|
|
427
458
|
- test/vcr_cassettes/eds/get_with_auth_recovers_from_bad_auth.yml
|
428
459
|
- test/vcr_cassettes/google_site/empty_result_set.yml
|
429
460
|
- test/vcr_cassettes/google_site/without_highlighting.yml
|
461
|
+
- test/vcr_cassettes/google_site/gets_format_string.yml
|
430
462
|
- test/vcr_cassettes/google_site/with_highlighting.yml
|
431
463
|
- test/vcr_cassettes/google_site/basic_smoke_test.yml
|
432
464
|
- test/vcr_cassettes/google_site/pagination_object_is_correct_for_actual_page_when_you_ask_for_too_far.yml
|
@@ -435,11 +467,11 @@ test_files:
|
|
435
467
|
- test/vcr_cassettes/scopus/bad_api_key_should_return_error_response.yml
|
436
468
|
- test/vcr_cassettes/scopus/escaped_chars.yml
|
437
469
|
- test/vcr_cassettes/scopus/zero_results_search.yml
|
470
|
+
- test/vcr_cassettes/max_out_pagination.yml
|
438
471
|
- test/vcr_cassettes/gbs/pagination.yml
|
439
472
|
- test/vcr_cassettes/gbs/error_condition.yml
|
440
473
|
- test/vcr_cassettes/gbs/search.yml
|
441
474
|
- test/vcr_cassettes/gbs/empty_results.yml
|
442
|
-
- test/unit/result_item_display_test.rb
|
443
475
|
- test/unit/eds_engine_test.rb
|
444
476
|
- test/unit/result_item_test.rb
|
445
477
|
- test/unit/item_decorators_test.rb
|
@@ -447,7 +479,6 @@ test_files:
|
|
447
479
|
- test/unit/google_site_search_test.rb
|
448
480
|
- test/unit/search_engine_test.rb
|
449
481
|
- test/unit/search_engine_base_test.rb
|
450
|
-
- test/unit/worldcat_sru_dc_engine_test.rb
|
451
482
|
- test/unit/register_engine_test.rb
|
452
483
|
- test/unit/google_books_engine_test.rb
|
453
484
|
- test/unit/summon_engine_test.rb
|
@@ -459,4 +490,6 @@ test_files:
|
|
459
490
|
- test/unit/multi_searcher_test.rb
|
460
491
|
- test/unit/pagination_test.rb
|
461
492
|
- test/test_helper.rb
|
493
|
+
- test/decorator/standard_decorator_test.rb
|
494
|
+
- test/decorator/decorator_base_test.rb
|
462
495
|
- test/functional/bento_search/search_controller_test.rb
|
@@ -1,39 +0,0 @@
|
|
1
|
-
require 'test_helper'
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
class ResultItemDisplayTest < ActiveSupport::TestCase
|
6
|
-
Author = BentoSearch::Author
|
7
|
-
ResultItem = BentoSearch::ResultItem
|
8
|
-
|
9
|
-
test "author with first and last" do
|
10
|
-
author = Author.new(:last => "Smith", :first => "John")
|
11
|
-
|
12
|
-
str = ResultItem.new.author_display(author)
|
13
|
-
|
14
|
-
assert_equal "Smith, J", str
|
15
|
-
end
|
16
|
-
|
17
|
-
test "author with display form and just last" do
|
18
|
-
author = Author.new(:last => "Smith", :display => "Display Form")
|
19
|
-
|
20
|
-
str = ResultItem.new.author_display(author)
|
21
|
-
|
22
|
-
assert_equal "Display Form", str
|
23
|
-
end
|
24
|
-
|
25
|
-
test "Author with just last" do
|
26
|
-
author = Author.new(:last => "Johnson")
|
27
|
-
|
28
|
-
str = ResultItem.new.author_display(author)
|
29
|
-
|
30
|
-
assert_equal "Johnson", str
|
31
|
-
|
32
|
-
end
|
33
|
-
|
34
|
-
test "Missing title" do
|
35
|
-
assert_equal I18n.translate("bento_search.missing_title"), ResultItem.new.complete_title
|
36
|
-
end
|
37
|
-
|
38
|
-
|
39
|
-
end
|
@@ -1,120 +0,0 @@
|
|
1
|
-
require 'test_helper'
|
2
|
-
|
3
|
-
require 'cgi'
|
4
|
-
require 'uri'
|
5
|
-
|
6
|
-
#
|
7
|
-
#
|
8
|
-
# Using the MARCXML response is way too much work, but the XML 'DC' response
|
9
|
-
# is awfully stunted. We do what we can with it, but resulting metadata
|
10
|
-
# is weird.
|
11
|
-
#
|
12
|
-
class WorldcatSruDcEngineTest < ActiveSupport::TestCase
|
13
|
-
extend TestWithCassette
|
14
|
-
|
15
|
-
@@api_key = ENV["WORLDCAT_API_KEY"] || "DUMMY_API_KEY"
|
16
|
-
|
17
|
-
VCR.configure do |c|
|
18
|
-
c.filter_sensitive_data("DUMMY_API_KEY", :worldcat_sru_dc) { @@api_key }
|
19
|
-
end
|
20
|
-
|
21
|
-
|
22
|
-
def setup
|
23
|
-
@config = {:api_key => @@api_key}
|
24
|
-
@engine = BentoSearch::WorldcatSruDcEngine.new(@config)
|
25
|
-
end
|
26
|
-
|
27
|
-
def test_construct_url
|
28
|
-
query = 'cancer\'s "one two"'
|
29
|
-
url = @engine.construct_query_url(:query => query, :per_page => 10)
|
30
|
-
|
31
|
-
query_hash = CGI.parse(URI.parse(url).query)
|
32
|
-
|
33
|
-
assert_equal [@engine.configuration.api_key], query_hash["wskey"]
|
34
|
-
assert_equal ['info:srw/schema/1/dc'], query_hash["recordSchema"]
|
35
|
-
assert_equal [@engine.construct_cql_query(:query => query)], query_hash["query"]
|
36
|
-
end
|
37
|
-
|
38
|
-
def test_construct_pagination
|
39
|
-
url = @engine.construct_query_url(:query => "cancer", :per_page => 20, :start => 20)
|
40
|
-
|
41
|
-
query_hash = CGI.parse(URI.parse(url).query)
|
42
|
-
|
43
|
-
assert_equal ["20"], query_hash["maximumRecords"]
|
44
|
-
assert_equal ["21"], query_hash["startRecord"]
|
45
|
-
end
|
46
|
-
|
47
|
-
def test_construct_sort
|
48
|
-
url = @engine.construct_query_url(:query => "cancer", :sort => "date_desc")
|
49
|
-
|
50
|
-
query_hash = CGI.parse(URI.parse(url).query)
|
51
|
-
|
52
|
-
assert_present query_hash["sortKeys"]
|
53
|
-
end
|
54
|
-
|
55
|
-
def test_construct_fielded_search
|
56
|
-
cql = @engine.construct_cql_query(:query => "cancer", :search_field => "srw.ti")
|
57
|
-
|
58
|
-
assert_equal 'srw.ti = "cancer"', cql
|
59
|
-
end
|
60
|
-
|
61
|
-
def test_construct_servicelevel
|
62
|
-
url = @engine.construct_query_url(:query => "cancer")
|
63
|
-
query_hash = CGI.parse(URI.parse(url).query)
|
64
|
-
assert_not_include query_hash["servicelevel"], "full"
|
65
|
-
|
66
|
-
url = @engine.construct_query_url(:query => "cancer auth", :auth => true)
|
67
|
-
query_hash = CGI.parse(URI.parse(url).query)
|
68
|
-
assert_include query_hash["servicelevel"], "full"
|
69
|
-
|
70
|
-
default_on = BentoSearch::WorldcatSruDcEngine.new(@config.merge(:auth => true))
|
71
|
-
|
72
|
-
url = default_on.construct_query_url(:query => "cancer")
|
73
|
-
query_hash = CGI.parse(URI.parse(url).query)
|
74
|
-
assert_include query_hash["servicelevel"], "full"
|
75
|
-
|
76
|
-
url = default_on.construct_query_url(:query => "cancer", :auth => false)
|
77
|
-
query_hash = CGI.parse(URI.parse(url).query)
|
78
|
-
assert_not_include query_hash["servicelevel"], "full"
|
79
|
-
end
|
80
|
-
|
81
|
-
def test_construct_cql
|
82
|
-
# test proper escaping and such
|
83
|
-
cql = @engine.construct_cql_query(:query => "alpha's beta \"one two\" thr\"ee")
|
84
|
-
|
85
|
-
components = cql.split(" AND ")
|
86
|
-
|
87
|
-
assert_equal 4, components.length
|
88
|
-
|
89
|
-
["srw.kw = \"beta\"",
|
90
|
-
"srw.kw = \"alpha's\"",
|
91
|
-
"srw.kw = \"one two\"",
|
92
|
-
"srw.kw = \"thr\\\"ee\""].each do |clause|
|
93
|
-
assert_include components, clause
|
94
|
-
end
|
95
|
-
end
|
96
|
-
|
97
|
-
test_with_cassette("smoke test", :worldcat_sru_dc) do
|
98
|
-
results = @engine.search("anarchism")
|
99
|
-
|
100
|
-
assert_present results
|
101
|
-
|
102
|
-
assert_present results.total_items
|
103
|
-
|
104
|
-
first = results.first
|
105
|
-
|
106
|
-
assert_present first.title
|
107
|
-
assert_present first.authors
|
108
|
-
assert_present first.publisher
|
109
|
-
assert_present first.oclcnum
|
110
|
-
|
111
|
-
assert_present first.year
|
112
|
-
|
113
|
-
assert_present first.abstract
|
114
|
-
|
115
|
-
assert_present first.link
|
116
|
-
|
117
|
-
assert_present first.language_code
|
118
|
-
end
|
119
|
-
|
120
|
-
end
|