voyager_api 0.1.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 (43) hide show
  1. data/.document +5 -0
  2. data/.rvmrc.07.27.2011-15:02:08 +47 -0
  3. data/Gemfile +20 -0
  4. data/Gemfile.lock +36 -0
  5. data/Guardfile +10 -0
  6. data/LICENSE.txt +20 -0
  7. data/README.rdoc +19 -0
  8. data/Rakefile +53 -0
  9. data/VERSION +1 -0
  10. data/lib/holdings/collection.rb +44 -0
  11. data/lib/holdings/item.rb +253 -0
  12. data/lib/holdings/order.rb +68 -0
  13. data/lib/holdings/record.rb +229 -0
  14. data/lib/voyager_api.rb +10 -0
  15. data/lib/voyager_connection.rb +35 -0
  16. data/test/fixtures/fixtures_readme +65 -0
  17. data/test/fixtures/holdings_289196.xml +2 -0
  18. data/test/fixtures/holdings_4191079.xml +2 -0
  19. data/test/fixtures/holdings_4949188.xml +2 -0
  20. data/test/fixtures/holdings_4949188_2.xml +2 -0
  21. data/test/fixtures/holdings_526843.xml +2 -0
  22. data/test/fixtures/holdings_5656993.xml +2 -0
  23. data/test/fixtures/holdings_6269409.xml +2 -0
  24. data/test/fixtures/holdings_7471326.xml +2 -0
  25. data/test/fixtures/holdings_7658449.xml +2 -0
  26. data/test/fixtures/holdings_7658454.xml +2 -0
  27. data/test/fixtures/holdings_7784963.xml +2 -0
  28. data/test/fixtures/holdings_8267323.xml +2 -0
  29. data/test/fixtures/holdings_8615744.xml +2 -0
  30. data/test/fixtures/holdings_8889994.xml +2 -0
  31. data/test/fixtures/holdings_8891001.xml +2 -0
  32. data/test/fixtures/holdings_8891001_2.xml +2 -0
  33. data/test/fixtures/holdings_8918502.xml +2 -0
  34. data/test/helper.rb +29 -0
  35. data/test/holdings/test_collection.rb +15 -0
  36. data/test/holdings/test_collection_output.rb +24 -0
  37. data/test/holdings/test_holdings_test_case.rb +14 -0
  38. data/test/holdings/test_item.rb +48 -0
  39. data/test/holdings/test_order.rb +34 -0
  40. data/test/holdings/test_record.rb +147 -0
  41. data/test/test_voyager_api.rb +4 -0
  42. data/test/test_voyager_connection.rb +28 -0
  43. metadata +253 -0
@@ -0,0 +1,34 @@
1
+ require "helper"
2
+ require "minitest/autorun"
3
+
4
+ class TestOrder < HoldingsTestCase
5
+
6
+ def test_no_current_issues
7
+ record = load_fixture('holdings_289196.xml').records[0]
8
+ assert_equal [], record.current_issues
9
+ record = load_fixture('holdings_289196.xml').records[1]
10
+ assert_equal [], record.current_issues
11
+ end
12
+
13
+ def test_current_issues
14
+ record = load_fixture('holdings_289196.xml').records[2]
15
+ assert_kind_of Array, record.current_issues
16
+ assert_equal "v. 116, no. 3 (2011 June)", record.current_issues[0]
17
+ end
18
+
19
+ def test_order_statuses
20
+ record = load_fixture('holdings_8615744.xml').records.first
21
+ assert_kind_of Array, record.orders
22
+ assert_equal 'In the Pre-Order Process. Try Borrow Direct or ILL.', record.orders.first, "status 0"
23
+ record = load_fixture('holdings_8267323.xml').records.first
24
+ assert_kind_of Array, record.orders
25
+ assert_equal 'Received 2011-08-09. Place an In Process item request.', record.orders.first, "status 1"
26
+ record = load_fixture('holdings_7471326.xml').records.first
27
+ assert_kind_of Array, record.orders
28
+ assert_equal 'Not yet received; claimed 2011-08-08. Try Borrow Direct or ILL.', record.orders.first, "status 4"
29
+ record = load_fixture('holdings_8918502.xml').records.first
30
+ assert_kind_of Array, record.orders
31
+ assert_equal 'Copy On Order 2011-08-09. Try Borrow Direct or ILL.', record.orders.first, "status 8"
32
+ end
33
+
34
+ end
@@ -0,0 +1,147 @@
1
+ require "helper"
2
+ require "minitest/autorun"
3
+
4
+ class TestHoldings < HoldingsTestCase
5
+ def test_has_holding_ids
6
+ record = load_fixture("holdings_7658449.xml").records.first
7
+ assert_equal "10746154", record.holding_id
8
+ end
9
+
10
+ def test_location_name
11
+ record = load_fixture("holdings_7658449.xml").records.first
12
+ assert_equal 'Butler Stacks (Enter at the Butler Circulation Desk)', record.location_name
13
+ end
14
+
15
+ def test_call_number
16
+ record = load_fixture("holdings_7658449.xml").records.first
17
+ assert_equal 'GB500 .G23', record.call_number
18
+
19
+ record2 = load_fixture("holdings_7658454.xml").records.first
20
+ assert_equal 'REF GB450 .G23 FF', record2.call_number
21
+ end
22
+
23
+ def test_summary_holdings
24
+ record = load_fixture("holdings_7658449.xml").records.first
25
+ assert_kind_of Array, record.summary_holdings
26
+ assert_equal 'v.1-2', record.summary_holdings.first
27
+
28
+ record2 = load_fixture("holdings_7658454.xml").records.first
29
+ assert_kind_of Array, record2.summary_holdings
30
+ assert_equal 'v.1-2', record2.summary_holdings[0]
31
+ assert_equal 'v.3-4', record2.summary_holdings[1]
32
+ assert_nil record2.summary_holdings[2]
33
+
34
+ record3 = load_fixture("holdings_6269409.xml").records.first
35
+ assert_kind_of Array, record3.summary_holdings
36
+ assert_equal [], record3.summary_holdings
37
+
38
+ record4 = load_fixture("holdings_8889994.xml").records.first
39
+ assert_kind_of Array, record4.summary_holdings
40
+ assert_equal [], record3.summary_holdings, '866 fields with no 866 a'
41
+ end
42
+
43
+ def test_notes_852_single_occurrence
44
+ record = load_fixture("holdings_4949188.xml").records
45
+ assert_kind_of Array, record[0].notes_852
46
+ assert_equal 'znote text', record[0].notes_852.first, 'Single 852 $z'
47
+ assert_kind_of Array, record[1].notes_852
48
+ assert_equal [], record[1].notes_852, 'No 852 $z'
49
+ end
50
+
51
+ def test_notes_852_multiple_occurrences
52
+ record = load_fixture("holdings_4949188_2.xml").records
53
+ assert_kind_of Array, record[1].notes_852
54
+ assert_equal 'znote 1', record[1].notes_852[0], 'First 852 $z'
55
+ assert_equal 'znote 2', record[1].notes_852[1], 'Second 852 $z'
56
+ end
57
+
58
+ def test_notes_866_single_occurrence
59
+ record = load_fixture("holdings_4949188.xml").records
60
+ assert_kind_of Array, record[0].notes_866
61
+ assert_equal '866 note text', record[0].notes_866.first, 'Single 866 $z'
62
+ assert_kind_of Array, record[1].notes_866
63
+ assert_equal [], record[1].notes_852, 'No 866 $z'
64
+ end
65
+
66
+ def test_notes_866_multiple_occurrences
67
+ record = load_fixture("holdings_4949188_2.xml").records
68
+ assert_kind_of Array, record[1].notes_866
69
+ assert_equal '866 znote 1', record[1].notes_866[0], 'First 866 $z'
70
+ assert_equal '866 znote 2', record[1].notes_866[1], 'Second 866 $z'
71
+ end
72
+
73
+ def test_notes_866_no_occurrences
74
+ record = load_fixture("holdings_7658449.xml").records.first
75
+ assert_kind_of Array, record.notes_866
76
+ assert_equal [], record.notes_866, '866 fields with no 866 z'
77
+ end
78
+
79
+ def test_notes_combined
80
+ record = load_fixture("holdings_4949188.xml").records
81
+ assert_kind_of Array, record[0].notes
82
+ assert_equal 'znote text', record[0].notes[0], 'Single 852 $z'
83
+ assert_equal '866 note text', record[0].notes[1], 'Single 866 $z'
84
+ end
85
+
86
+ def test_shelving_title
87
+ record = load_fixture("holdings_8891001.xml").records.first
88
+ assert_kind_of String, record.shelving_title
89
+ assert_equal 'Shelving title', record.shelving_title, '852 l'
90
+ end
91
+
92
+ def test_supplements
93
+ record = load_fixture("holdings_8891001.xml").records.first
94
+ assert_kind_of Array, record.supplements
95
+ assert_equal 'Supplement', record.supplements[0], '867 fields'
96
+ end
97
+
98
+ def test_indexes
99
+ record = load_fixture("holdings_8891001.xml").records.first
100
+ assert_kind_of Array, record.indexes
101
+ assert_equal 'Index', record.indexes[0], '868 fields'
102
+ end
103
+
104
+ def test_reproduction_note
105
+ record = load_fixture("holdings_8891001.xml").records.first
106
+ assert_kind_of String, record.shelving_title
107
+ assert_equal 'Microfilm. 1950-1963. Webster, N.Y. : Photographic Sciences Corp., 1974- 2 microfilm reels ; 35 mm.', record.reproduction_note, '843 field'
108
+ end
109
+
110
+ def test_urls_simple_case
111
+ record = load_fixture("holdings_8891001.xml").records.first
112
+ assert_kind_of Array, record.urls
113
+ assert_equal 'http://www.columbia.edu', record.urls.first[:url]
114
+ assert_equal 'Part 1 Full text', record.urls.first[:link_text]
115
+ end
116
+
117
+ def test_urls_multiple_urls
118
+ record = load_fixture("holdings_8891001_2.xml").records[1]
119
+ assert_kind_of Array, record.urls
120
+ assert_equal 3, record.urls.length
121
+ assert_equal 'http://www.columbia.edu', record.urls.first[:url]
122
+ assert_equal 'http://www.columbia.edu', record.urls.first[:link_text]
123
+ assert_equal 'http://libraries.columbia.edu', record.urls[1][:url]
124
+ assert_equal 'Library Website', record.urls[1][:link_text]
125
+ assert_equal 'http://website 1', record.urls[2][:url]
126
+ assert_equal 'Part 1', record.urls[2][:link_text]
127
+ end
128
+
129
+ def test_temp_location_substitution
130
+ record = load_fixture("holdings_4191079.xml").records[1]
131
+ assert_equal 'Butler Reserves, 208 Butler', record.location_name, 'location name'
132
+ assert_equal [], record.temp_locations, 'temp location array'
133
+ record = load_fixture("holdings_4191079.xml").records[3]
134
+ assert_equal 'Butler Stacks (Enter at the Butler Circulation Desk)', record.location_name, 'location name'
135
+ assert_equal ["v.2 Shelved in Butler Stacks Folios"], record.temp_locations, 'temp location array'
136
+ end
137
+
138
+ def test_online_record
139
+ record = load_fixture("holdings_5656993.xml").records[0]
140
+ assert_equal 'Online', record.location_name, 'location name'
141
+ assert_equal 'online', record.item_status[:status]
142
+ end
143
+
144
+
145
+
146
+ end
147
+
@@ -0,0 +1,4 @@
1
+ require 'helper'
2
+
3
+ class TestVoyagerApi < MiniTest::Unit::TestCase
4
+ end
@@ -0,0 +1,28 @@
1
+ require "helper"
2
+ require "minitest/autorun"
3
+
4
+ class TestVoyagerConnection < MiniTest::Unit::TestCase
5
+ def test_creates_cookies
6
+ cookie_dir = File.join(File.dirname(__FILE__), "tmp", "cookies")
7
+ cookie_file = File.join(cookie_dir, "cookies.dat")
8
+ FileUtils.rm_rf(File.dirname(cookie_dir))
9
+
10
+
11
+ cookie_manager = mock
12
+ cookie_manager.expects(:save_all_cookies).with(true)
13
+ hc = HTTPClient.new
14
+ hc.expects(:set_cookie_store).with(cookie_file)
15
+ hc.expects(:get_content).with("http://www.google.com",{})
16
+ hc.expects(:cookie_manager).returns(cookie_manager)
17
+
18
+
19
+ vc = Voyager::Connection.new(:http_client => hc, :cookie_path => cookie_file)
20
+
21
+ vc.request("http://www.google.com")
22
+
23
+ assert File.exists?(cookie_dir)
24
+ FileUtils.rm_rf(File.dirname(cookie_dir))
25
+
26
+ end
27
+
28
+ end
metadata ADDED
@@ -0,0 +1,253 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: voyager_api
3
+ version: !ruby/object:Gem::Version
4
+ hash: 27
5
+ prerelease:
6
+ segments:
7
+ - 0
8
+ - 1
9
+ - 0
10
+ version: 0.1.0
11
+ platform: ruby
12
+ authors:
13
+ - James Stuart
14
+ - Gary Bertchume
15
+ autorequire:
16
+ bindir: bin
17
+ cert_chain: []
18
+
19
+ date: 2011-08-09 00:00:00 -04:00
20
+ default_executable:
21
+ dependencies:
22
+ - !ruby/object:Gem::Dependency
23
+ prerelease: false
24
+ type: :runtime
25
+ requirement: &id001 !ruby/object:Gem::Requirement
26
+ none: false
27
+ requirements:
28
+ - - ">="
29
+ - !ruby/object:Gem::Version
30
+ hash: 3
31
+ segments:
32
+ - 0
33
+ version: "0"
34
+ name: httpclient
35
+ version_requirements: *id001
36
+ - !ruby/object:Gem::Dependency
37
+ prerelease: false
38
+ type: :runtime
39
+ requirement: &id002 !ruby/object:Gem::Requirement
40
+ none: false
41
+ requirements:
42
+ - - ">="
43
+ - !ruby/object:Gem::Version
44
+ hash: 3
45
+ segments:
46
+ - 0
47
+ version: "0"
48
+ name: nokogiri
49
+ version_requirements: *id002
50
+ - !ruby/object:Gem::Dependency
51
+ prerelease: false
52
+ type: :development
53
+ requirement: &id003 !ruby/object:Gem::Requirement
54
+ none: false
55
+ requirements:
56
+ - - ">="
57
+ - !ruby/object:Gem::Version
58
+ hash: 3
59
+ segments:
60
+ - 0
61
+ version: "0"
62
+ name: minitest
63
+ version_requirements: *id003
64
+ - !ruby/object:Gem::Dependency
65
+ prerelease: false
66
+ type: :development
67
+ requirement: &id004 !ruby/object:Gem::Requirement
68
+ none: false
69
+ requirements:
70
+ - - ~>
71
+ - !ruby/object:Gem::Version
72
+ hash: 23
73
+ segments:
74
+ - 1
75
+ - 0
76
+ - 0
77
+ version: 1.0.0
78
+ name: bundler
79
+ version_requirements: *id004
80
+ - !ruby/object:Gem::Dependency
81
+ prerelease: false
82
+ type: :development
83
+ requirement: &id005 !ruby/object:Gem::Requirement
84
+ none: false
85
+ requirements:
86
+ - - ~>
87
+ - !ruby/object:Gem::Version
88
+ hash: 7
89
+ segments:
90
+ - 1
91
+ - 6
92
+ - 4
93
+ version: 1.6.4
94
+ name: jeweler
95
+ version_requirements: *id005
96
+ - !ruby/object:Gem::Dependency
97
+ prerelease: false
98
+ type: :development
99
+ requirement: &id006 !ruby/object:Gem::Requirement
100
+ none: false
101
+ requirements:
102
+ - - ">="
103
+ - !ruby/object:Gem::Version
104
+ hash: 3
105
+ segments:
106
+ - 0
107
+ version: "0"
108
+ name: rcov
109
+ version_requirements: *id006
110
+ - !ruby/object:Gem::Dependency
111
+ prerelease: false
112
+ type: :development
113
+ requirement: &id007 !ruby/object:Gem::Requirement
114
+ none: false
115
+ requirements:
116
+ - - ">="
117
+ - !ruby/object:Gem::Version
118
+ hash: 3
119
+ segments:
120
+ - 0
121
+ version: "0"
122
+ name: guard-minitest
123
+ version_requirements: *id007
124
+ - !ruby/object:Gem::Dependency
125
+ prerelease: false
126
+ type: :development
127
+ requirement: &id008 !ruby/object:Gem::Requirement
128
+ none: false
129
+ requirements:
130
+ - - ">="
131
+ - !ruby/object:Gem::Version
132
+ hash: 3
133
+ segments:
134
+ - 0
135
+ version: "0"
136
+ name: rb-fsevent
137
+ version_requirements: *id008
138
+ - !ruby/object:Gem::Dependency
139
+ prerelease: false
140
+ type: :development
141
+ requirement: &id009 !ruby/object:Gem::Requirement
142
+ none: false
143
+ requirements:
144
+ - - ">="
145
+ - !ruby/object:Gem::Version
146
+ hash: 3
147
+ segments:
148
+ - 0
149
+ version: "0"
150
+ name: mocha
151
+ version_requirements: *id009
152
+ - !ruby/object:Gem::Dependency
153
+ prerelease: false
154
+ type: :development
155
+ requirement: &id010 !ruby/object:Gem::Requirement
156
+ none: false
157
+ requirements:
158
+ - - ">="
159
+ - !ruby/object:Gem::Version
160
+ hash: 3
161
+ segments:
162
+ - 0
163
+ version: "0"
164
+ name: growl
165
+ version_requirements: *id010
166
+ description: "Middleware gem for Voyager 7 API calls, specificially holdings information "
167
+ email: github@jamesstuart.org
168
+ executables: []
169
+
170
+ extensions: []
171
+
172
+ extra_rdoc_files:
173
+ - LICENSE.txt
174
+ - README.rdoc
175
+ files:
176
+ - .document
177
+ - .rvmrc.07.27.2011-15:02:08
178
+ - Gemfile
179
+ - Gemfile.lock
180
+ - Guardfile
181
+ - LICENSE.txt
182
+ - README.rdoc
183
+ - Rakefile
184
+ - VERSION
185
+ - lib/holdings/collection.rb
186
+ - lib/holdings/item.rb
187
+ - lib/holdings/order.rb
188
+ - lib/holdings/record.rb
189
+ - lib/voyager_api.rb
190
+ - lib/voyager_connection.rb
191
+ - test/fixtures/fixtures_readme
192
+ - test/fixtures/holdings_289196.xml
193
+ - test/fixtures/holdings_4191079.xml
194
+ - test/fixtures/holdings_4949188.xml
195
+ - test/fixtures/holdings_4949188_2.xml
196
+ - test/fixtures/holdings_526843.xml
197
+ - test/fixtures/holdings_5656993.xml
198
+ - test/fixtures/holdings_6269409.xml
199
+ - test/fixtures/holdings_7471326.xml
200
+ - test/fixtures/holdings_7658449.xml
201
+ - test/fixtures/holdings_7658454.xml
202
+ - test/fixtures/holdings_7784963.xml
203
+ - test/fixtures/holdings_8267323.xml
204
+ - test/fixtures/holdings_8615744.xml
205
+ - test/fixtures/holdings_8889994.xml
206
+ - test/fixtures/holdings_8891001.xml
207
+ - test/fixtures/holdings_8891001_2.xml
208
+ - test/fixtures/holdings_8918502.xml
209
+ - test/helper.rb
210
+ - test/holdings/test_collection.rb
211
+ - test/holdings/test_collection_output.rb
212
+ - test/holdings/test_holdings_test_case.rb
213
+ - test/holdings/test_item.rb
214
+ - test/holdings/test_order.rb
215
+ - test/holdings/test_record.rb
216
+ - test/test_voyager_api.rb
217
+ - test/test_voyager_connection.rb
218
+ has_rdoc: true
219
+ homepage: http://github.com/cul/voyager_api
220
+ licenses:
221
+ - MIT
222
+ post_install_message:
223
+ rdoc_options: []
224
+
225
+ require_paths:
226
+ - lib
227
+ required_ruby_version: !ruby/object:Gem::Requirement
228
+ none: false
229
+ requirements:
230
+ - - ">="
231
+ - !ruby/object:Gem::Version
232
+ hash: 3
233
+ segments:
234
+ - 0
235
+ version: "0"
236
+ required_rubygems_version: !ruby/object:Gem::Requirement
237
+ none: false
238
+ requirements:
239
+ - - ">="
240
+ - !ruby/object:Gem::Version
241
+ hash: 3
242
+ segments:
243
+ - 0
244
+ version: "0"
245
+ requirements: []
246
+
247
+ rubyforge_project:
248
+ rubygems_version: 1.6.2
249
+ signing_key:
250
+ specification_version: 3
251
+ summary: Columbia University Voyager 7 API wrapper
252
+ test_files: []
253
+