exlibris-aleph 0.0.2 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -3,14 +3,10 @@ class TabHelperBenchmarks < ActiveSupport::TestCase
3
3
  def setup
4
4
  @adms = ["NYU50", "NYU51"]
5
5
  @tab_path = "/mnt/aleph_tab"
6
+ dummy_path = "#{File.dirname(__FILE__)}/../dummy"
7
+ @yml_path = File.join(dummy_path, "config/aleph")
8
+ @log_path = File.join(dummy_path, "log/aleph")
6
9
  Exlibris::Aleph::TabHelper.class_variable_set(:@@adms, [])
7
- [ :@@patrons_path,
8
- :@@items_path,
9
- :@@item_permissions_by_item_status_path,
10
- :@@item_permissions_by_item_process_status_path,
11
- :@@collections_path,
12
- :@@pickup_locations_path ].each { |class_variable|
13
- Exlibris::Aleph::TabHelper.class_variable_set(class_variable, {}) }
14
10
  @TESTS = 10
15
11
  end
16
12
 
@@ -24,24 +20,40 @@ class TabHelperBenchmarks < ActiveSupport::TestCase
24
20
  end
25
21
  end
26
22
 
23
+ # Get benchmarks for the Aleph TabHelper
24
+ test "benchmarks_refresh_yml" do
25
+ Exlibris::Aleph::TabHelper.init(@tab_path, @adms)
26
+ # Display performance benchmarks.
27
+ time = Benchmark.bmbm do |results|
28
+ results.report("TabHelper refresh_yml:") { @TESTS.times {
29
+ Exlibris::Aleph::TabHelper.refresh_yml()
30
+ } }
31
+ end
32
+ end
33
+
27
34
  # Get benchmarks for the Aleph TabHelper
28
35
  test "benchmarks_new" do
29
36
  Exlibris::Aleph::TabHelper.init(@tab_path, @adms)
30
37
  # Display performance benchmarks.
31
38
  time = Benchmark.bmbm do |results|
32
39
  results.report("TabHelper new:") { @TESTS.times {
33
- [ :@@patrons_path,
34
- :@@items_path,
35
- :@@item_permissions_by_item_status_path,
36
- :@@item_permissions_by_item_process_status_path,
37
- :@@collections_path,
38
- :@@pickup_locations_path ].each { |class_variable|
39
- Exlibris::Aleph::TabHelper.class_variable_set(class_variable, {}) }
40
40
  Exlibris::Aleph::TabHelper.send(:new)
41
41
  } }
42
42
  end
43
43
  end
44
44
 
45
+ # Get benchmarks for the Aleph TabHelper
46
+ test "benchmarks_instance" do
47
+ Exlibris::Aleph::TabHelper.init(@tab_path, @adms)
48
+ Exlibris::Aleph::TabHelper.send(:new)
49
+ # Display performance benchmarks.
50
+ time = Benchmark.bmbm do |results|
51
+ results.report("TabHelper instance:") { @TESTS.times {
52
+ Exlibris::Aleph::TabHelper.instance
53
+ } }
54
+ end
55
+ end
56
+
45
57
  # Get benchmarks for the Aleph TabHelper
46
58
  test "benchmarks_refresh" do
47
59
  Exlibris::Aleph::TabHelper.init(@tab_path, @adms)
@@ -49,7 +61,7 @@ class TabHelperBenchmarks < ActiveSupport::TestCase
49
61
  # Display performance benchmarks.
50
62
  time = Benchmark.bmbm do |results|
51
63
  results.report("TabHelper refresh:") { @TESTS.times {
52
- helper.refresh
64
+ helper.send(:refresh)
53
65
  } }
54
66
  end
55
67
  end
@@ -2,14 +2,7 @@ require 'test_helper'
2
2
  class ConfigHelperTest < ActiveSupport::TestCase
3
3
  def setup
4
4
  Exlibris::Aleph::TabHelper.class_variable_set(:@@adms, [])
5
- [ :@@patrons_path,
6
- :@@items_path,
7
- :@@item_permissions_by_item_status_path,
8
- :@@item_permissions_by_item_process_status_path,
9
- :@@collections_path,
10
- :@@pickup_locations_path ].each do |class_variable|
11
- Exlibris::Aleph::TabHelper.class_variable_set(class_variable, {})
12
- end
5
+ Exlibris::Aleph::TabHelper.class_variable_set(:@@refresh_time, ->{1.day.ago})
13
6
  @adms = ["NYU50", "NYU51"]
14
7
  @tab_path = "/mnt/aleph_tab"
15
8
  dummy_path = "#{File.dirname(__FILE__)}/../dummy"
@@ -21,20 +14,83 @@ class ConfigHelperTest < ActiveSupport::TestCase
21
14
  assert_raise(ArgumentError) { Exlibris::Aleph::TabHelper.send(:new) }
22
15
  end
23
16
 
17
+ test "instance_with_wrong_init" do
18
+ Exlibris::Aleph::TabHelper.init(nil, nil)
19
+ assert_raise(ArgumentError) { Exlibris::Aleph::TabHelper.send(:new) }
20
+ Exlibris::Aleph::TabHelper.init(@tab_path, nil)
21
+ assert_raise(ArgumentError) { Exlibris::Aleph::TabHelper.send(:new) }
22
+ Exlibris::Aleph::TabHelper.init(@tab_path, [])
23
+ assert_raise(ArgumentError) { Exlibris::Aleph::TabHelper.send(:new) }
24
+ Exlibris::Aleph::TabHelper.init(@tab_path, @adms, nil)
25
+ assert_raise(ArgumentError) { Exlibris::Aleph::TabHelper.send(:new) }
26
+ end
27
+
24
28
  test "init" do
25
- Exlibris::Aleph::TabHelper.init(@tab_path, @yml_path, @log_path, @adms)
29
+ Exlibris::Aleph::TabHelper.init(@tab_path, @adms)
26
30
  helper = Exlibris::Aleph::TabHelper.instance
27
31
  assert_equal(@adms, helper.adms)
28
32
  end
29
33
 
30
34
  test "instance" do
31
- Exlibris::Aleph::TabHelper.init(@tab_path, @yml_path, @log_path, @adms)
35
+ Exlibris::Aleph::TabHelper.init(@tab_path, @adms)
32
36
  assert_nothing_raised() { Exlibris::Aleph::TabHelper.send(:new) }
33
37
  assert_same(Exlibris::Aleph::TabHelper.instance, Exlibris::Aleph::TabHelper.instance)
34
38
  end
35
39
 
40
+ test "refresh" do
41
+ Exlibris::Aleph::TabHelper.init(@tab_path, @adms, ->{1.second.ago})
42
+ helper = Exlibris::Aleph::TabHelper.instance
43
+ helper.sub_libraries
44
+ updated_at_1 = helper.updated_at
45
+ helper.sub_libraries
46
+ updated_at_2 = helper.updated_at
47
+ assert_equal(updated_at_1, updated_at_2)
48
+ sleep 1
49
+ helper.sub_libraries
50
+ assert_not_equal(updated_at_1, helper.updated_at)
51
+ end
52
+
53
+ test "sub_library_text" do
54
+ Exlibris::Aleph::TabHelper.init(@tab_path, @adms)
55
+ helper = Exlibris::Aleph::TabHelper.instance
56
+ assert_equal("NYU Bobst", helper.sub_library_text("BOBST"))
57
+ end
58
+
59
+ test "sub_library_adm" do
60
+ Exlibris::Aleph::TabHelper.init(@tab_path, @adms)
61
+ helper = Exlibris::Aleph::TabHelper.instance
62
+ assert_equal("NYU50", helper.sub_library_adm("BOBST"))
63
+ end
64
+
65
+ test "item_pickup_locations" do
66
+ Exlibris::Aleph::TabHelper.init(@tab_path, @adms)
67
+ helper = Exlibris::Aleph::TabHelper.instance
68
+ assert_equal(
69
+ ["BOBST", "NCOUR", "NIFA", "NISAW", "NREI", "NPOLY", "NYUAB", "NYUSE", "NYUSS"],
70
+ helper.item_pickup_locations({:adm_library_code => "nyu50", :sub_library_code => "BOBST", :bor_status => "51"}))
71
+ end
72
+
73
+ test "collection_text" do
74
+ Exlibris::Aleph::TabHelper.init(@tab_path, @adms)
75
+ helper = Exlibris::Aleph::TabHelper.instance
76
+ assert_equal(
77
+ "Main Collection",
78
+ helper.collection_text({:adm_library_code => "nyu50", :sub_library_code => "BOBST", :collection_code => "MAIN"}))
79
+ end
80
+
81
+ test "item_web_text" do
82
+ Exlibris::Aleph::TabHelper.init(@tab_path, @adms)
83
+ helper = Exlibris::Aleph::TabHelper.instance
84
+ assert_equal(
85
+ "Offsite Available",
86
+ helper.item_web_text({:adm_library_code => "nyu50", :item_process_status => "Depository"}))
87
+ assert_equal(
88
+ "Offsite Available",
89
+ helper.item_web_text({:adm_library_code => "nyu50", :sub_library_code => "BOBST", :item_process_status_code => "DP"}))
90
+ end
91
+
36
92
  test "sub_libraries" do
37
- Exlibris::Aleph::TabHelper.init(@tab_path, @yml_path, @log_path, @adms)
93
+ Exlibris::Aleph::TabHelper.init(@tab_path, @adms)
38
94
  helper = Exlibris::Aleph::TabHelper.instance
39
95
  assert_equal("BOBST", helper.sub_libraries["BOBST"][:code])
40
96
  assert_equal("NYU Bobst", helper.sub_libraries["BOBST"][:text])
@@ -42,14 +98,14 @@ class ConfigHelperTest < ActiveSupport::TestCase
42
98
  end
43
99
 
44
100
  test "patrons" do
45
- Exlibris::Aleph::TabHelper.init(@tab_path, @yml_path, @log_path, @adms)
101
+ Exlibris::Aleph::TabHelper.init(@tab_path, @adms)
46
102
  helper = Exlibris::Aleph::TabHelper.instance
47
103
  assert_equal("51", helper.patrons["nyu50"]["51"][:code])
48
104
  assert_equal("NYU Administrator", helper.patrons["nyu50"]["51"][:text])
49
105
  end
50
106
 
51
107
  test "patron_permissions" do
52
- Exlibris::Aleph::TabHelper.init(@tab_path, @yml_path, @log_path, @adms)
108
+ Exlibris::Aleph::TabHelper.init(@tab_path, @adms)
53
109
  helper = Exlibris::Aleph::TabHelper.instance
54
110
  assert_equal("BOBST", helper.patron_permissions["nyu50"]["BOBST"]["51"][:sub_library])
55
111
  assert_equal("51", helper.patron_permissions["nyu50"]["BOBST"]["51"][:patron_status])
@@ -69,7 +125,7 @@ class ConfigHelperTest < ActiveSupport::TestCase
69
125
  end
70
126
 
71
127
  test "items" do
72
- Exlibris::Aleph::TabHelper.init(@tab_path, @yml_path, @log_path, @adms)
128
+ Exlibris::Aleph::TabHelper.init(@tab_path, @adms)
73
129
  helper = Exlibris::Aleph::TabHelper.instance
74
130
  assert_equal("ITEM-STATUS", helper.items["nyu50"]["Billed as lost"][:code])
75
131
  assert_equal("Billed as lost", helper.items["nyu50"]["Billed as lost"][:original_text])
@@ -77,7 +133,7 @@ class ConfigHelperTest < ActiveSupport::TestCase
77
133
  end
78
134
 
79
135
  test "item_permissions_by_item_status" do
80
- Exlibris::Aleph::TabHelper.init(@tab_path, @yml_path, @log_path, @adms)
136
+ Exlibris::Aleph::TabHelper.init(@tab_path, @adms)
81
137
  helper = Exlibris::Aleph::TabHelper.instance
82
138
  assert_equal("BOBST", helper.item_permissions_by_item_status["nyu50"]["BOBST"]["01"][:sub_library])
83
139
  assert_equal("01", helper.item_permissions_by_item_status["nyu50"]["BOBST"]["01"][:item_status])
@@ -97,7 +153,7 @@ class ConfigHelperTest < ActiveSupport::TestCase
97
153
  end
98
154
 
99
155
  test "item_permissions_by_item_process_status" do
100
- Exlibris::Aleph::TabHelper.init(@tab_path, @yml_path, @log_path, @adms)
156
+ Exlibris::Aleph::TabHelper.init(@tab_path, @adms)
101
157
  helper = Exlibris::Aleph::TabHelper.instance
102
158
  assert_equal("BOBST", helper.item_permissions_by_item_process_status["nyu50"]["BOBST"]["AC"][:sub_library])
103
159
  assert_equal("AC", helper.item_permissions_by_item_process_status["nyu50"]["BOBST"]["AC"][:item_process_status])
@@ -117,7 +173,7 @@ class ConfigHelperTest < ActiveSupport::TestCase
117
173
  end
118
174
 
119
175
  test "collections" do
120
- Exlibris::Aleph::TabHelper.init(@tab_path, @yml_path, @log_path, @adms)
176
+ Exlibris::Aleph::TabHelper.init(@tab_path, @adms)
121
177
  helper = Exlibris::Aleph::TabHelper.instance
122
178
  assert_equal("BOBST", helper.collections["nyu50"]["BOBST"]["MAIN"][:sub_library])
123
179
  assert_equal("MAIN", helper.collections["nyu50"]["BOBST"]["MAIN"][:collection_code])
@@ -125,7 +181,7 @@ class ConfigHelperTest < ActiveSupport::TestCase
125
181
  end
126
182
 
127
183
  test "pickup_locations" do
128
- Exlibris::Aleph::TabHelper.init(@tab_path, @yml_path, @log_path, @adms)
184
+ Exlibris::Aleph::TabHelper.init(@tab_path, @adms)
129
185
  helper = Exlibris::Aleph::TabHelper.instance
130
186
  assert_equal("BOBST", helper.pickup_locations["nyu50"]["BOBST"]["##"]["DP"]["51"]["Y"][:sub_library])
131
187
  assert_equal("##", helper.pickup_locations["nyu50"]["BOBST"]["##"]["DP"]["51"]["Y"][:item_status])
@@ -136,7 +192,7 @@ class ConfigHelperTest < ActiveSupport::TestCase
136
192
  end
137
193
 
138
194
  test "refresh_yml" do
139
- Exlibris::Aleph::TabHelper.init(@tab_path, @yml_path, @log_path, @adms)
195
+ Exlibris::Aleph::TabHelper.init(@tab_path, @adms)
140
196
  helper = Exlibris::Aleph::TabHelper.instance
141
197
  assert_nil(helper.sub_libraries["NEW__"])
142
198
  sub_library_file = "/mnt/aleph_tab/alephe/tab/tab_sub_library.eng"
@@ -146,7 +202,7 @@ class ConfigHelperTest < ActiveSupport::TestCase
146
202
  # Update the file.
147
203
  File.open(sub_library_file, 'a') {|f| f.puts "NEW__ 1 NYU50 L NYU TEST BOBST BOBST BOBST BOBST NYU50 ALEPH" }
148
204
  Exlibris::Aleph::TabHelper.refresh_yml
149
- helper.refresh
205
+ helper.send(:refresh)
150
206
  assert_not_nil(helper.sub_libraries["NEW__"])
151
207
  assert_equal("NEW__", helper.sub_libraries["NEW__"][:code])
152
208
  assert_equal("NYU TEST", helper.sub_libraries["NEW__"][:text])
@@ -156,25 +212,4 @@ class ConfigHelperTest < ActiveSupport::TestCase
156
212
  file.truncate(old_size)
157
213
  file.close
158
214
  end
159
-
160
- # test "refresh" do
161
- # Exlibris::Aleph::TabHelper.init(@tab_path, @yml_path, @log_path, @adms)
162
- # helper = Exlibris::Aleph::TabHelper.instance
163
- # assert_nil(helper.sub_libraries["NEW__"])
164
- # sub_library_file = "/mnt/aleph_tab/alephe/tab/tab_sub_library.eng"
165
- # file = File.open(sub_library_file, 'r')
166
- # old_size = file.size
167
- # file.close
168
- # # Update the file.
169
- # File.open(sub_library_file, 'a') {|f| f.puts "NEW__ 1 NYU50 L NYU TEST BOBST BOBST BOBST BOBST NYU50 ALEPH" }
170
- # helper.refresh
171
- # assert_not_nil(helper.sub_libraries["NEW__"])
172
- # assert_equal("NEW__", helper.sub_libraries["NEW__"][:code])
173
- # assert_equal("NYU TEST", helper.sub_libraries["NEW__"][:text])
174
- # assert_equal("NYU50", helper.sub_libraries["NEW__"][:library])
175
- # # Revert the file to what it was
176
- # file = File.open(sub_library_file, 'r+')
177
- # file.truncate(old_size)
178
- # file.close
179
- # end
180
215
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: exlibris-aleph
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.1.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-03-29 00:00:00.000000000 Z
12
+ date: 2012-04-09 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails
16
- requirement: &2151812780 !ruby/object:Gem::Requirement
16
+ requirement: &2151812580 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ~>
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: 3.2.0
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *2151812780
24
+ version_requirements: *2151812580
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: nokogiri
27
- requirement: &2151810860 !ruby/object:Gem::Requirement
27
+ requirement: &2151810720 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: '0'
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *2151810860
35
+ version_requirements: *2151810720
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: httparty
38
- requirement: &2151808580 !ruby/object:Gem::Requirement
38
+ requirement: &2151808880 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: '0'
44
44
  type: :runtime
45
45
  prerelease: false
46
- version_requirements: *2151808580
46
+ version_requirements: *2151808880
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: sqlite3
49
- requirement: &2151805420 !ruby/object:Gem::Requirement
49
+ requirement: &2151805340 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ! '>='
@@ -54,7 +54,7 @@ dependencies:
54
54
  version: '0'
55
55
  type: :development
56
56
  prerelease: false
57
- version_requirements: *2151805420
57
+ version_requirements: *2151805340
58
58
  description: Library to handle Exlibris' Aleph ILS.
59
59
  email:
60
60
  - scotdalton@gmail.com
@@ -74,6 +74,7 @@ files:
74
74
  - lib/exlibris/aleph/config/tab_sub_library.rb
75
75
  - lib/exlibris/aleph/config/tab_www_item_desc.rb
76
76
  - lib/exlibris/aleph/patron.rb
77
+ - lib/exlibris/aleph/railtie.rb
77
78
  - lib/exlibris/aleph/record.rb
78
79
  - lib/exlibris/aleph/rest.rb
79
80
  - lib/exlibris/aleph/tab_helper.rb
@@ -88,6 +89,7 @@ files:
88
89
  - test/dummy/app/controllers/application_controller.rb
89
90
  - test/dummy/app/helpers/application_helper.rb
90
91
  - test/dummy/app/views/layouts/application.html.erb
92
+ - test/dummy/config/aleph/alephe/sub_libraries.yml
91
93
  - test/dummy/config/aleph/NYU50/collections.yml
92
94
  - test/dummy/config/aleph/NYU50/item_permissions_by_item_process_status.yml
93
95
  - test/dummy/config/aleph/NYU50/item_permissions_by_item_status.yml
@@ -124,6 +126,7 @@ files:
124
126
  - test/dummy/db/test.sqlite3
125
127
  - test/dummy/log/aleph/aleph_tab_helper.log
126
128
  - test/dummy/log/aleph/tab_helper.log
129
+ - test/dummy/log/tab_helper.log
127
130
  - test/dummy/log/test.log
128
131
  - test/dummy/public/404.html
129
132
  - test/dummy/public/422.html
@@ -170,6 +173,7 @@ test_files:
170
173
  - test/dummy/app/controllers/application_controller.rb
171
174
  - test/dummy/app/helpers/application_helper.rb
172
175
  - test/dummy/app/views/layouts/application.html.erb
176
+ - test/dummy/config/aleph/alephe/sub_libraries.yml
173
177
  - test/dummy/config/aleph/NYU50/collections.yml
174
178
  - test/dummy/config/aleph/NYU50/item_permissions_by_item_process_status.yml
175
179
  - test/dummy/config/aleph/NYU50/item_permissions_by_item_status.yml
@@ -206,6 +210,7 @@ test_files:
206
210
  - test/dummy/db/test.sqlite3
207
211
  - test/dummy/log/aleph/aleph_tab_helper.log
208
212
  - test/dummy/log/aleph/tab_helper.log
213
+ - test/dummy/log/tab_helper.log
209
214
  - test/dummy/log/test.log
210
215
  - test/dummy/public/404.html
211
216
  - test/dummy/public/422.html