exlibris-aleph 1.0.5 → 1.0.6
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.
- checksums.yaml +8 -8
- data/lib/exlibris/aleph/tab_helper.rb +35 -21
- data/lib/exlibris/aleph/version.rb +1 -1
- data/test/tab_helper_test.rb +9 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
NjZlNDU1MDg1Y2QwNjU3ZjgwMmFhOTgzZjNkMzkzOGJiNDJmMGY0Mw==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
ZTY3YzgxZWEwMTFiYjdmN2Q3MWNmOWQ5N2E1ZjAwNDQ2OTRkNzI1Yw==
|
7
7
|
!binary "U0hBNTEy":
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
ZmQ3OTJiY2ZhNTI5N2FkODhmOGMyMmNhN2JiNmM2Y2RhMjM2NGU2MTM0M2E2
|
10
|
+
ZjMyZDQ2ZmMxZGI0Y2U0YjAxMGI5YWUxZmFkYjYyMzNmMTBhODIxOTk2ODE1
|
11
|
+
ZjA0NTlhYzc4YWEwYjU2M2Y2MzkxNjM4MzdiODEwZDQzYzEwYTM=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
OTFkNWMyNzM3N2I0NzUzZDQ2ZmFkZDAxZjNhZWE3MjI3ZTcwOGE2YTA0NTUw
|
14
|
+
NjRhMzg1MjI2MTBhYjIwNDcxYmZmZDNiMDAwZTBlOWZkMWQ4ODFlZTY4Njk5
|
15
|
+
NGEyNDQ0Y2FlNjlhZTI2YzA3MTQzMGQ1NjdmNmZkYmE4Yjk0N2M=
|
@@ -63,8 +63,8 @@ module Exlibris
|
|
63
63
|
instance_variable_set("@#{tab}".to_sym, {})
|
64
64
|
# Define reader w/ refresh
|
65
65
|
self.class.send(:define_method, tab) {
|
66
|
-
|
67
|
-
|
66
|
+
refresh if refresh?
|
67
|
+
instance_variable_get("@#{tab}".to_sym)
|
68
68
|
}
|
69
69
|
}
|
70
70
|
refresh
|
@@ -223,18 +223,15 @@ module Exlibris
|
|
223
223
|
sublibrary_permissions[params[:item_status_code]] unless sublibrary_permissions.nil?
|
224
224
|
end
|
225
225
|
rescue => e
|
226
|
-
logger.
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
)
|
226
|
+
logger.error(%Q{
|
227
|
+
Error in #{self.class}.
|
228
|
+
Returning empty item permissions.
|
229
|
+
Parameters:
|
230
|
+
ADM library: #{params[:adm_library_code]}
|
231
|
+
Sub library: #{params[:sub_library_code]}
|
232
|
+
Item status: #{params[:item_status_code]}
|
233
|
+
Item process status: #{params[:item_process_status_code]}}.strip)
|
235
234
|
logger.error("Error: \n\t#{e}")
|
236
|
-
logger.error("\titem_permissions_by_item_process_status is #{item_permissions_by_item_process_status.inspect}")
|
237
|
-
logger.error("\titem_permissions_by_item_status is #{item_permissions_by_item_process_status.inspect}")
|
238
235
|
ensure
|
239
236
|
return item_permissions
|
240
237
|
end
|
@@ -245,21 +242,38 @@ module Exlibris
|
|
245
242
|
private :refresh?
|
246
243
|
|
247
244
|
def refresh
|
248
|
-
@@alephe_tabs.each_key do |
|
249
|
-
instance_variable_set("@#{
|
245
|
+
@@alephe_tabs.each_key do |tab|
|
246
|
+
instance_variable_set("@#{tab}".to_sym, YAML.load_file(File.join(yml_path, "alephe", "#{tab}.yml")))
|
250
247
|
end
|
251
|
-
@@adm_tabs.each_key do |
|
248
|
+
@@adm_tabs.each_key do |tab|
|
252
249
|
adms.each do |adm|
|
253
|
-
|
254
|
-
|
255
|
-
instance_variable_set("@#{key}".to_sym, tab)
|
250
|
+
instance_variable_get("@#{tab}".to_sym)[adm] =
|
251
|
+
YAML.load_file(File.join(yml_path, adm, "#{tab}.yml"))
|
256
252
|
end
|
257
253
|
end
|
258
254
|
# Delete irrelevant sub libraries from @sub_library
|
259
255
|
@sub_libraries.delete_if {|key,value| irrelevant_sub_libraries.include? key }
|
260
|
-
|
256
|
+
# Since we update the YAML files in a separate process, don't overwrite
|
257
|
+
# unless everything got some valid data.
|
258
|
+
@updated_at = Time.now() if successful_refresh?
|
261
259
|
end
|
262
|
-
private :refresh
|
260
|
+
private :refresh
|
261
|
+
|
262
|
+
# Did the refresh actually work?
|
263
|
+
def successful_refresh?
|
264
|
+
# No "false" entries in alephe tab variables
|
265
|
+
(@@alephe_tabs.keys.find { |tab| (not instance_variable_get("@#{tab}".to_sym))}.nil? and
|
266
|
+
# AND no "false" entries in adm tab variables
|
267
|
+
@@adm_tabs.keys.find{ |tab| adms.find { |adm| (not (instance_variable_get("@#{tab}".to_sym)[adm])) }}.nil?)
|
268
|
+
end
|
269
|
+
private :successful_refresh?
|
270
|
+
|
271
|
+
# Since we update the YAML files in a separate process, we need to
|
272
|
+
# wait until we actually get some YAML to load it into the hash.
|
273
|
+
def hash_from_yaml_file(file)
|
274
|
+
yaml = YAML.load_file(file)
|
275
|
+
end
|
276
|
+
private :hash_from_yaml_file
|
263
277
|
|
264
278
|
def adms
|
265
279
|
@adms ||= self.class.adms
|
data/test/tab_helper_test.rb
CHANGED
@@ -36,6 +36,15 @@ class TabHelperTest < ActiveSupport::TestCase
|
|
36
36
|
@helper.instance_variable_set(:@refresh_time, @helper.class.refresh_time)
|
37
37
|
end
|
38
38
|
|
39
|
+
test "successful refresh?" do
|
40
|
+
@helper.send(:refresh)
|
41
|
+
assert @helper.send(:successful_refresh?)
|
42
|
+
@helper.instance_variable_get(:@patrons)["nyu50"] = false
|
43
|
+
assert((not @helper.send(:successful_refresh?)))
|
44
|
+
@helper.send(:refresh)
|
45
|
+
assert @helper.send(:successful_refresh?)
|
46
|
+
end
|
47
|
+
|
39
48
|
test "sub_library_text" do
|
40
49
|
assert_equal("NYU Bobst", @helper.sub_library_text("BOBST"))
|
41
50
|
end
|