exlibris-primo 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (50) hide show
  1. data/MIT-LICENSE +20 -0
  2. data/README.rdoc +3 -0
  3. data/Rakefile +38 -0
  4. data/lib/exlibris-primo.rb +11 -0
  5. data/lib/exlibris/primo/holding.rb +185 -0
  6. data/lib/exlibris/primo/related_link.rb +19 -0
  7. data/lib/exlibris/primo/rsrc.rb +19 -0
  8. data/lib/exlibris/primo/searcher.rb +292 -0
  9. data/lib/exlibris/primo/source/aleph.rb +50 -0
  10. data/lib/exlibris/primo/toc.rb +19 -0
  11. data/lib/exlibris/primo/version.rb +5 -0
  12. data/lib/exlibris/primo/web_service.rb +145 -0
  13. data/lib/tasks/exlibris-primo_tasks.rake +4 -0
  14. data/test/dummy/README.rdoc +261 -0
  15. data/test/dummy/Rakefile +7 -0
  16. data/test/dummy/app/assets/javascripts/application.js +15 -0
  17. data/test/dummy/app/assets/stylesheets/application.css +13 -0
  18. data/test/dummy/app/controllers/application_controller.rb +3 -0
  19. data/test/dummy/app/helpers/application_helper.rb +2 -0
  20. data/test/dummy/app/views/layouts/application.html.erb +14 -0
  21. data/test/dummy/config.ru +4 -0
  22. data/test/dummy/config/application.rb +56 -0
  23. data/test/dummy/config/boot.rb +10 -0
  24. data/test/dummy/config/database.yml +25 -0
  25. data/test/dummy/config/environment.rb +5 -0
  26. data/test/dummy/config/environments/development.rb +37 -0
  27. data/test/dummy/config/environments/production.rb +67 -0
  28. data/test/dummy/config/environments/test.rb +37 -0
  29. data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
  30. data/test/dummy/config/initializers/inflections.rb +15 -0
  31. data/test/dummy/config/initializers/mime_types.rb +5 -0
  32. data/test/dummy/config/initializers/secret_token.rb +7 -0
  33. data/test/dummy/config/initializers/session_store.rb +8 -0
  34. data/test/dummy/config/initializers/wrap_parameters.rb +14 -0
  35. data/test/dummy/config/locales/en.yml +5 -0
  36. data/test/dummy/config/routes.rb +58 -0
  37. data/test/dummy/db/test.sqlite3 +0 -0
  38. data/test/dummy/log/test.log +410 -0
  39. data/test/dummy/public/404.html +26 -0
  40. data/test/dummy/public/422.html +26 -0
  41. data/test/dummy/public/500.html +25 -0
  42. data/test/dummy/public/favicon.ico +0 -0
  43. data/test/dummy/script/rails +6 -0
  44. data/test/exlibris-primo_test.rb +7 -0
  45. data/test/test_helper.rb +10 -0
  46. data/test/unit/searcher_benchmarks.rb +82 -0
  47. data/test/unit/searcher_test.rb +383 -0
  48. data/test/unit/web_service_benchmarks.rb +60 -0
  49. data/test/unit/web_service_test.rb +124 -0
  50. metadata +174 -0
@@ -0,0 +1,60 @@
1
+ require 'test_helper'
2
+
3
+ class WebServiceBenchmarks < ActiveSupport::TestCase
4
+ PNX_NS = {'pnx' => 'http://www.exlibrisgroup.com/xsd/primo/primo_nm_bib'}
5
+ SEARCH_NS = {'search' => 'http://www.exlibrisgroup.com/xsd/jaguar/search'}
6
+
7
+ def setup
8
+ @primo_definition = YAML.load( %{
9
+ type: PrimoService
10
+ priority: 2 # After SFX, to get SFX metadata enhancement
11
+ status: active
12
+ base_url: http://bobcat.library.nyu.edu
13
+ vid: NYU
14
+ institution: NYU
15
+ holding_search_institution: NYU
16
+ holding_search_text: Search for this title in BobCat.
17
+ suppress_holdings: [ !ruby/regexp '/\$\$LBWEB/', !ruby/regexp '/\$\$LNWEB/', !ruby/regexp '/\$\$LTWEB/', !ruby/regexp '/\$\$LWEB/', !ruby/regexp '/\$\$1Restricted Internet Resources/' ]
18
+ ez_proxy: !ruby/regexp '/https\:\/\/ezproxy\.library\.nyu\.edu\/login\?url=/'
19
+ service_types:
20
+ - primo_source
21
+ - holding_search
22
+ - fulltext
23
+ - table_of_contents
24
+ - referent_enhance
25
+ - cover_image
26
+ })
27
+
28
+ @base_url = @primo_definition["base_url"]
29
+ @bogus_404_url = "http://library.nyu.edu/bogus"
30
+ @bogus_200_url = "http://library.nyu.edu"
31
+ @primo_test_doc_id = "nyu_aleph000062856"
32
+ @primo_invalid_doc_id = "thisIsNotAValidDocId"
33
+ @primo_test_problem_doc_id = "nyu_aleph000509288"
34
+ @isbn_search_params = {:isbn => "0143039008"}
35
+ @issn_search_params = {:issn => "0090-5720"}
36
+ @title_search_params = {:title => "Travels with My Aunt"}
37
+ @author_search_params = {:author => "Graham Greene"}
38
+ @title_author_genre_search_params = {:title => "Travels with My Aunt", :author => "Graham Greene", :genre => "Book"}
39
+ end
40
+
41
+ test "benchmarks" do
42
+ Benchmark.bmbm do |results|
43
+ results.report("Get Record:") {
44
+ (1..10).each {
45
+ get_record = Exlibris::Primo::WebService::GetRecord.new(@primo_test_doc_id, @base_url)
46
+ }
47
+ }
48
+ results.report("SearchBrief by ISBN:") {
49
+ (1..10).each {
50
+ get_record = Exlibris::Primo::WebService::SearchBrief.new(@isbn_search_params, @base_url)
51
+ }
52
+ }
53
+ results.report("SearchBrief by title:") {
54
+ (1..10).each {
55
+ get_record = Exlibris::Primo::WebService::SearchBrief.new(@title_search_params, @base_url)
56
+ }
57
+ }
58
+ end
59
+ end
60
+ end
@@ -0,0 +1,124 @@
1
+ require 'test_helper'
2
+
3
+ class WebServiceTest < ActiveSupport::TestCase
4
+ PNX_NS = {'pnx' => 'http://www.exlibrisgroup.com/xsd/primo/primo_nm_bib'}
5
+ SEARCH_NS = {'search' => 'http://www.exlibrisgroup.com/xsd/jaguar/search'}
6
+
7
+ def setup
8
+ @primo_definition = YAML.load( %{
9
+ type: PrimoService
10
+ priority: 2 # After SFX, to get SFX metadata enhancement
11
+ status: active
12
+ base_url: http://bobcat.library.nyu.edu
13
+ vid: NYU
14
+ institution: NYU
15
+ holding_search_institution: NYU
16
+ holding_search_text: Search for this title in BobCat.
17
+ suppress_holdings: [ !ruby/regexp '/\$\$LBWEB/', !ruby/regexp '/\$\$LNWEB/', !ruby/regexp '/\$\$LTWEB/', !ruby/regexp '/\$\$LWEB/', !ruby/regexp '/\$\$1Restricted Internet Resources/' ]
18
+ ez_proxy: !ruby/regexp '/https\:\/\/ezproxy\.library\.nyu\.edu\/login\?url=/'
19
+ service_types:
20
+ - primo_source
21
+ - holding_search
22
+ - fulltext
23
+ - table_of_contents
24
+ - referent_enhance
25
+ - cover_image
26
+ })
27
+
28
+ @base_url = @primo_definition["base_url"]
29
+ @bogus_404_url = "http://library.nyu.edu/bogus"
30
+ @bogus_200_url = "http://library.nyu.edu"
31
+ @primo_test_doc_id = "nyu_aleph000062856"
32
+ @primo_invalid_doc_id = "thisIsNotAValidDocId"
33
+ @primo_test_problem_doc_id = "nyu_aleph000509288"
34
+ @isbn_search_params = {:isbn => "0143039008"}
35
+ @issn_search_params = {:issn => "0090-5720"}
36
+ @title_search_params = {:title => "Travels with My Aunt"}
37
+ @author_search_params = {:author => "Graham Greene"}
38
+ @title_author_genre_search_params = {:title => "Travels with My Aunt", :author => "Graham Greene", :genre => "Book"}
39
+ end
40
+
41
+ def test_bogus_response
42
+ assert_raise(SOAP::HTTPStreamError) {
43
+ ws = Exlibris::Primo::WebService::GetRecord.new(@primo_test_doc_id, @bogus_404_url)
44
+ }
45
+ assert_raise(SOAP::HTTPStreamError) {
46
+ ws = Exlibris::Primo::WebService::GetRecord.new(@primo_test_doc_id, @bogus_200_url)
47
+ }
48
+ end
49
+
50
+ # Test GetRecord for a single Primo document.
51
+ def test_get_record
52
+ ws = Exlibris::Primo::WebService::GetRecord.new(@primo_test_doc_id, @base_url)
53
+ assert_not_nil(ws, "#{ws.class} returned nil when instantiated.")
54
+ assert_instance_of( Nokogiri::XML::Document, ws.response, "#{ws.class} response is an unexpected object: #{ws.response.class}")
55
+ assert_equal([], ws.error, "#{ws.class} encountered errors: #{ws.error}")
56
+ assert_equal(@primo_test_doc_id, ws.response.at("//pnx:control/pnx:recordid", PNX_NS).inner_text, "#{ws.class} returned an unexpected record: #{ws.response.to_xml(:indent => 5, :encoding => 'UTF-8')}")
57
+ end
58
+
59
+ def test_count_get_record
60
+ ws = Exlibris::Primo::WebService::GetRecord.new(@primo_test_doc_id, @base_url)
61
+ assert_equal("1", ws.response.at("//search:DOCSET", SEARCH_NS)["TOTALHITS"])
62
+ end
63
+
64
+ def test_count_search_brief
65
+ ws = Exlibris::Primo::WebService::SearchBrief.new(@isbn_search_params, @base_url)
66
+ assert_equal("1", ws.response.at("//search:DOCSET", SEARCH_NS)["TOTALHITS"])
67
+ end
68
+
69
+ def test_get_genre_discrepancy
70
+ ws = Exlibris::Primo::WebService::GetRecord.new(@primo_test_problem_doc_id, @base_url)
71
+ assert_not_nil(ws, "#{ws.class} returned nil when instantiated.")
72
+ assert_instance_of( Nokogiri::XML::Document, ws.response, "#{ws.class} response is an unexpected object: #{ws.response.class}")
73
+ assert_equal([], ws.error, "#{ws.class} encountered errors: #{ws.error}")
74
+ assert_equal(@primo_test_problem_doc_id, ws.response.at("//pnx:control/pnx:recordid", PNX_NS).inner_text, "#{ws.class} returned an unexpected record: #{ws.response.to_xml(:indent => 5, :encoding => 'UTF-8')}")
75
+ assert_not_nil(ws.response.at("//pnx:display/pnx:availlibrary", PNX_NS).inner_text, "#{ws.class} returned an unexpected record: #{ws.response.to_xml(:indent => 5, :encoding => 'UTF-8')}")
76
+ end
77
+
78
+ # Test GetRecord with invalid Primo doc id.
79
+ def test_get_bogus_record
80
+ assert_raise(RuntimeError) {
81
+ ws = Exlibris::Primo::WebService::GetRecord.new(@primo_invalid_doc_id, @base_url)
82
+ }
83
+ end
84
+
85
+ # Test SearchBrief by isbn.
86
+ def test_isbn_search
87
+ ws = Exlibris::Primo::WebService::SearchBrief.new(@isbn_search_params, @base_url)
88
+ assert_not_nil(ws, "#{ws.class} returned nil when instantiated.")
89
+ assert_instance_of( Nokogiri::XML::Document, ws.response, "#{ws.class} response is an unexpected object: #{ws.response.class}")
90
+ assert_equal([], ws.error, "#{ws.class} encountered errors: #{ws.error}")
91
+ end
92
+
93
+ # Test SearchBrief by issn.
94
+ def test_issn_search
95
+ ws = Exlibris::Primo::WebService::SearchBrief.new(@issn_search_params, @base_url)
96
+ assert_not_nil(ws, "#{ws.class} returned nil when instantiated.")
97
+ assert_instance_of( Nokogiri::XML::Document, ws.response, "#{ws.class} response is an unexpected object: #{ws.response.class}")
98
+ assert_equal([], ws.error, "#{ws.class} encountered errors: #{ws.error}")
99
+ end
100
+
101
+ # Test SearchBrief by title.
102
+ def test_title_search
103
+ ws = Exlibris::Primo::WebService::SearchBrief.new(@title_search_params, @base_url)
104
+ assert_not_nil(ws, "#{ws.class} returned nil when instantiated.")
105
+ assert_instance_of( Nokogiri::XML::Document, ws.response, "#{ws.class} response is an unexpected object: #{ws.response.class}")
106
+ assert_equal([], ws.error, "#{ws.class} encountered errors: #{ws.error}")
107
+ end
108
+
109
+ # Test SearchBrief by author.
110
+ def test_author_search
111
+ ws = Exlibris::Primo::WebService::SearchBrief.new(@author_search_params, @base_url)
112
+ assert_not_nil(ws, "#{ws.class} returned nil when instantiated.")
113
+ assert_instance_of( Nokogiri::XML::Document, ws.response, "#{ws.class} response is an unexpected object: #{ws.response.class}")
114
+ assert_equal([], ws.error, "#{ws.class} encountered errors: #{ws.error}")
115
+ end
116
+
117
+ # Test SearchBrief by title/author/genre.
118
+ def test_title_author_genre_search
119
+ ws = Exlibris::Primo::WebService::SearchBrief.new(@title_author_genre_search_params, @base_url)
120
+ assert_not_nil(ws, "#{ws.class} returned nil when instantiated.")
121
+ assert_instance_of( Nokogiri::XML::Document, ws.response, "#{ws.class} response is an unexpected object: #{ws.response.class}")
122
+ assert_equal([], ws.error, "#{ws.class} encountered errors: #{ws.error}")
123
+ end
124
+ end
metadata ADDED
@@ -0,0 +1,174 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: exlibris-primo
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Scot Dalton
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-03-23 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: rails
16
+ requirement: &2151859300 !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ~>
20
+ - !ruby/object:Gem::Version
21
+ version: 3.2.0
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: *2151859300
25
+ - !ruby/object:Gem::Dependency
26
+ name: nokogiri
27
+ requirement: &2151857480 !ruby/object:Gem::Requirement
28
+ none: false
29
+ requirements:
30
+ - - ! '>='
31
+ - !ruby/object:Gem::Version
32
+ version: '0'
33
+ type: :runtime
34
+ prerelease: false
35
+ version_requirements: *2151857480
36
+ - !ruby/object:Gem::Dependency
37
+ name: soap4r-ruby1.9
38
+ requirement: &2151856320 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ! '>='
42
+ - !ruby/object:Gem::Version
43
+ version: '0'
44
+ type: :runtime
45
+ prerelease: false
46
+ version_requirements: *2151856320
47
+ - !ruby/object:Gem::Dependency
48
+ name: sqlite3
49
+ requirement: &2151854780 !ruby/object:Gem::Requirement
50
+ none: false
51
+ requirements:
52
+ - - ! '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ type: :development
56
+ prerelease: false
57
+ version_requirements: *2151854780
58
+ description: Library to work with Exlibris' Primo discovery system.
59
+ email:
60
+ - scotdalton@gmail.com
61
+ executables: []
62
+ extensions: []
63
+ extra_rdoc_files: []
64
+ files:
65
+ - lib/exlibris/primo/holding.rb
66
+ - lib/exlibris/primo/related_link.rb
67
+ - lib/exlibris/primo/rsrc.rb
68
+ - lib/exlibris/primo/searcher.rb
69
+ - lib/exlibris/primo/source/aleph.rb
70
+ - lib/exlibris/primo/toc.rb
71
+ - lib/exlibris/primo/version.rb
72
+ - lib/exlibris/primo/web_service.rb
73
+ - lib/exlibris-primo.rb
74
+ - lib/tasks/exlibris-primo_tasks.rake
75
+ - MIT-LICENSE
76
+ - Rakefile
77
+ - README.rdoc
78
+ - test/dummy/app/assets/javascripts/application.js
79
+ - test/dummy/app/assets/stylesheets/application.css
80
+ - test/dummy/app/controllers/application_controller.rb
81
+ - test/dummy/app/helpers/application_helper.rb
82
+ - test/dummy/app/views/layouts/application.html.erb
83
+ - test/dummy/config/application.rb
84
+ - test/dummy/config/boot.rb
85
+ - test/dummy/config/database.yml
86
+ - test/dummy/config/environment.rb
87
+ - test/dummy/config/environments/development.rb
88
+ - test/dummy/config/environments/production.rb
89
+ - test/dummy/config/environments/test.rb
90
+ - test/dummy/config/initializers/backtrace_silencers.rb
91
+ - test/dummy/config/initializers/inflections.rb
92
+ - test/dummy/config/initializers/mime_types.rb
93
+ - test/dummy/config/initializers/secret_token.rb
94
+ - test/dummy/config/initializers/session_store.rb
95
+ - test/dummy/config/initializers/wrap_parameters.rb
96
+ - test/dummy/config/locales/en.yml
97
+ - test/dummy/config/routes.rb
98
+ - test/dummy/config.ru
99
+ - test/dummy/db/test.sqlite3
100
+ - test/dummy/log/test.log
101
+ - test/dummy/public/404.html
102
+ - test/dummy/public/422.html
103
+ - test/dummy/public/500.html
104
+ - test/dummy/public/favicon.ico
105
+ - test/dummy/Rakefile
106
+ - test/dummy/README.rdoc
107
+ - test/dummy/script/rails
108
+ - test/exlibris-primo_test.rb
109
+ - test/test_helper.rb
110
+ - test/unit/searcher_benchmarks.rb
111
+ - test/unit/searcher_test.rb
112
+ - test/unit/web_service_benchmarks.rb
113
+ - test/unit/web_service_test.rb
114
+ homepage: https://github.com/scotdalton/exlibris-primo
115
+ licenses: []
116
+ post_install_message:
117
+ rdoc_options: []
118
+ require_paths:
119
+ - lib
120
+ required_ruby_version: !ruby/object:Gem::Requirement
121
+ none: false
122
+ requirements:
123
+ - - ! '>='
124
+ - !ruby/object:Gem::Version
125
+ version: '0'
126
+ required_rubygems_version: !ruby/object:Gem::Requirement
127
+ none: false
128
+ requirements:
129
+ - - ! '>='
130
+ - !ruby/object:Gem::Version
131
+ version: '0'
132
+ requirements: []
133
+ rubyforge_project:
134
+ rubygems_version: 1.8.15
135
+ signing_key:
136
+ specification_version: 3
137
+ summary: Library to work with Exlibris' Primo discovery system.
138
+ test_files:
139
+ - test/dummy/app/assets/javascripts/application.js
140
+ - test/dummy/app/assets/stylesheets/application.css
141
+ - test/dummy/app/controllers/application_controller.rb
142
+ - test/dummy/app/helpers/application_helper.rb
143
+ - test/dummy/app/views/layouts/application.html.erb
144
+ - test/dummy/config/application.rb
145
+ - test/dummy/config/boot.rb
146
+ - test/dummy/config/database.yml
147
+ - test/dummy/config/environment.rb
148
+ - test/dummy/config/environments/development.rb
149
+ - test/dummy/config/environments/production.rb
150
+ - test/dummy/config/environments/test.rb
151
+ - test/dummy/config/initializers/backtrace_silencers.rb
152
+ - test/dummy/config/initializers/inflections.rb
153
+ - test/dummy/config/initializers/mime_types.rb
154
+ - test/dummy/config/initializers/secret_token.rb
155
+ - test/dummy/config/initializers/session_store.rb
156
+ - test/dummy/config/initializers/wrap_parameters.rb
157
+ - test/dummy/config/locales/en.yml
158
+ - test/dummy/config/routes.rb
159
+ - test/dummy/config.ru
160
+ - test/dummy/db/test.sqlite3
161
+ - test/dummy/log/test.log
162
+ - test/dummy/public/404.html
163
+ - test/dummy/public/422.html
164
+ - test/dummy/public/500.html
165
+ - test/dummy/public/favicon.ico
166
+ - test/dummy/Rakefile
167
+ - test/dummy/README.rdoc
168
+ - test/dummy/script/rails
169
+ - test/exlibris-primo_test.rb
170
+ - test/test_helper.rb
171
+ - test/unit/searcher_benchmarks.rb
172
+ - test/unit/searcher_test.rb
173
+ - test/unit/web_service_benchmarks.rb
174
+ - test/unit/web_service_test.rb