exlibris-aleph 1.1.0 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +199 -82
- data/Rakefile +8 -14
- data/lib/exlibris-aleph.rb +0 -3
- data/lib/exlibris/aleph/admin_library.rb +27 -0
- data/lib/exlibris/aleph/api/base.rb +27 -0
- data/lib/exlibris/aleph/api/client/base.rb +86 -0
- data/lib/exlibris/aleph/api/client/patron.rb +20 -0
- data/lib/exlibris/aleph/api/client/patron/address.rb +22 -0
- data/lib/exlibris/aleph/api/client/patron/record.rb +23 -0
- data/lib/exlibris/aleph/api/client/patron/record/item.rb +26 -0
- data/lib/exlibris/aleph/api/client/patron/record/item/create_hold.rb +31 -0
- data/lib/exlibris/aleph/api/client/patron/record/item/create_hold/parameters.rb +55 -0
- data/lib/exlibris/aleph/api/client/patron/record/item/hold.rb +29 -0
- data/lib/exlibris/aleph/api/client/patron/status.rb +22 -0
- data/lib/exlibris/aleph/api/client/record.rb +21 -0
- data/lib/exlibris/aleph/api/client/record/filters.rb +23 -0
- data/lib/exlibris/aleph/api/client/record/holding.rb +23 -0
- data/lib/exlibris/aleph/api/client/record/holdings.rb +23 -0
- data/lib/exlibris/aleph/api/client/record/item.rb +23 -0
- data/lib/exlibris/aleph/api/client/record/items.rb +23 -0
- data/lib/exlibris/aleph/api/reader/base.rb +15 -0
- data/lib/exlibris/aleph/api/reader/patron.rb +19 -0
- data/lib/exlibris/aleph/api/reader/patron/address.rb +90 -0
- data/lib/exlibris/aleph/api/reader/patron/record.rb +38 -0
- data/lib/exlibris/aleph/api/reader/patron/record/item.rb +77 -0
- data/lib/exlibris/aleph/api/reader/patron/record/item/create_hold.rb +33 -0
- data/lib/exlibris/aleph/api/reader/patron/record/item/hold.rb +56 -0
- data/lib/exlibris/aleph/api/reader/patron/status.rb +33 -0
- data/lib/exlibris/aleph/api/reader/record.rb +10 -0
- data/lib/exlibris/aleph/api/reader/record/item.rb +45 -0
- data/lib/exlibris/aleph/collection.rb +26 -0
- data/lib/exlibris/aleph/config.rb +17 -57
- data/lib/exlibris/aleph/holding.rb +59 -0
- data/lib/exlibris/aleph/holding/metadata.rb +28 -0
- data/lib/exlibris/aleph/holdings.rb +51 -0
- data/lib/exlibris/aleph/item.rb +138 -0
- data/lib/exlibris/aleph/item/call_number.rb +14 -0
- data/lib/exlibris/aleph/item/circulation_policy.rb +30 -0
- data/lib/exlibris/aleph/item/circulation_policy/display.rb +16 -0
- data/lib/exlibris/aleph/item/circulation_policy/identifier.rb +34 -0
- data/lib/exlibris/aleph/item/circulation_policy/privileges.rb +72 -0
- data/lib/exlibris/aleph/item/circulation_status.rb +31 -0
- data/lib/exlibris/aleph/item/display_mask.rb +19 -0
- data/lib/exlibris/aleph/item/opac_note.rb +17 -0
- data/lib/exlibris/aleph/item/processing_status.rb +23 -0
- data/lib/exlibris/aleph/item/queue.rb +32 -0
- data/lib/exlibris/aleph/item/status.rb +23 -0
- data/lib/exlibris/aleph/items.rb +51 -0
- data/lib/exlibris/aleph/metadata.rb +25 -0
- data/lib/exlibris/aleph/patron.rb +18 -82
- data/lib/exlibris/aleph/patron/address.rb +56 -0
- data/lib/exlibris/aleph/patron/circulation_policy.rb +26 -0
- data/lib/exlibris/aleph/patron/circulation_policy/identifier.rb +29 -0
- data/lib/exlibris/aleph/patron/circulation_policy/privileges.rb +56 -0
- data/lib/exlibris/aleph/patron/record.rb +39 -0
- data/lib/exlibris/aleph/patron/record/circulation_policy.rb +18 -0
- data/lib/exlibris/aleph/patron/record/circulation_policy/privileges.rb +42 -0
- data/lib/exlibris/aleph/patron/record/item.rb +63 -0
- data/lib/exlibris/aleph/patron/record/item/circulation_policy.rb +21 -0
- data/lib/exlibris/aleph/patron/record/item/circulation_policy/privileges.rb +39 -0
- data/lib/exlibris/aleph/patron/record/item/create_hold.rb +43 -0
- data/lib/exlibris/aleph/patron/record/item/hold.rb +41 -0
- data/lib/exlibris/aleph/patron/status.rb +19 -0
- data/lib/exlibris/aleph/pickup_location.rb +12 -0
- data/lib/exlibris/aleph/record.rb +14 -43
- data/lib/exlibris/aleph/record/metadata.rb +8 -0
- data/lib/exlibris/aleph/sub_library.rb +30 -0
- data/lib/exlibris/aleph/table/base.rb +22 -0
- data/lib/exlibris/aleph/table/collections.rb +17 -0
- data/lib/exlibris/aleph/table/item/circulation_policies.rb +65 -0
- data/lib/exlibris/aleph/table/item/display_masks.rb +19 -0
- data/lib/exlibris/aleph/table/patron/circulation_policies.rb +47 -0
- data/lib/exlibris/aleph/table/patron/statuses.rb +19 -0
- data/lib/exlibris/aleph/table/reader/base.rb +57 -0
- data/lib/exlibris/aleph/table/reader/collections.rb +35 -0
- data/lib/exlibris/aleph/table/reader/item_circulation_policies.rb +50 -0
- data/lib/exlibris/aleph/table/reader/item_display_masks.rb +19 -0
- data/lib/exlibris/aleph/table/reader/matcher/base.rb +30 -0
- data/lib/exlibris/aleph/table/reader/matcher/collections.rb +17 -0
- data/lib/exlibris/aleph/table/reader/matcher/item_circulation_policies.rb +17 -0
- data/lib/exlibris/aleph/table/reader/matcher/item_display_masks.rb +17 -0
- data/lib/exlibris/aleph/table/reader/matcher/patron_circulation_policies.rb +17 -0
- data/lib/exlibris/aleph/table/reader/matcher/patron_statuses.rb +17 -0
- data/lib/exlibris/aleph/table/reader/matcher/sub_libraries.rb +17 -0
- data/lib/exlibris/aleph/table/reader/patron_circulation_policies.rb +51 -0
- data/lib/exlibris/aleph/table/reader/patron_statuses.rb +19 -0
- data/lib/exlibris/aleph/table/reader/row/base.rb +25 -0
- data/lib/exlibris/aleph/table/reader/row/collections.rb +13 -0
- data/lib/exlibris/aleph/table/reader/row/item_circulation_policies.rb +17 -0
- data/lib/exlibris/aleph/table/reader/row/item_display_masks.rb +13 -0
- data/lib/exlibris/aleph/table/reader/row/patron_circulation_policies.rb +20 -0
- data/lib/exlibris/aleph/table/reader/row/patron_statuses.rb +13 -0
- data/lib/exlibris/aleph/table/reader/row/sub_libraries.rb +13 -0
- data/lib/exlibris/aleph/table/reader/sub_libraries.rb +32 -0
- data/lib/exlibris/aleph/table/sub_libraries.rb +11 -0
- data/lib/exlibris/aleph/tables_manager.rb +66 -0
- data/lib/exlibris/aleph/version.rb +1 -1
- data/spec/exlibris/aleph/admin_library_spec.rb +83 -0
- data/spec/exlibris/aleph/api/base_spec.rb +23 -0
- data/spec/exlibris/aleph/api/client/base_spec.rb +40 -0
- data/spec/exlibris/aleph/api/client/patron/address_spec.rb +40 -0
- data/spec/exlibris/aleph/api/client/patron/record/item/create_hold/parameters_spec.rb +101 -0
- data/spec/exlibris/aleph/api/client/patron/record/item/create_hold_spec.rb +102 -0
- data/spec/exlibris/aleph/api/client/patron/record/item/hold_spec.rb +89 -0
- data/spec/exlibris/aleph/api/client/patron/record/item_spec.rb +52 -0
- data/spec/exlibris/aleph/api/client/patron/record_spec.rb +45 -0
- data/spec/exlibris/aleph/api/client/patron/status_spec.rb +40 -0
- data/spec/exlibris/aleph/api/client/patron_spec.rb +38 -0
- data/spec/exlibris/aleph/api/client/record/filters_spec.rb +46 -0
- data/spec/exlibris/aleph/api/client/record/holding_spec.rb +41 -0
- data/spec/exlibris/aleph/api/client/record/holdings_spec.rb +46 -0
- data/spec/exlibris/aleph/api/client/record/item_spec.rb +41 -0
- data/spec/exlibris/aleph/api/client/record/items_spec.rb +46 -0
- data/spec/exlibris/aleph/api/client/record_spec.rb +43 -0
- data/spec/exlibris/aleph/api/reader/base_spec.rb +18 -0
- data/spec/exlibris/aleph/api/reader/patron/address_spec.rb +151 -0
- data/spec/exlibris/aleph/api/reader/patron/record/item/create_hold_spec.rb +65 -0
- data/spec/exlibris/aleph/api/reader/patron/record/item/hold_spec.rb +145 -0
- data/spec/exlibris/aleph/api/reader/patron/record/item_spec.rb +266 -0
- data/spec/exlibris/aleph/api/reader/patron/record_spec.rb +98 -0
- data/spec/exlibris/aleph/api/reader/patron/status_spec.rb +57 -0
- data/spec/exlibris/aleph/api/reader/patron_spec.rb +28 -0
- data/spec/exlibris/aleph/api/reader/record/item_spec.rb +178 -0
- data/spec/exlibris/aleph/collection_spec.rb +95 -0
- data/spec/exlibris/aleph/config_spec.rb +17 -0
- data/spec/exlibris/aleph/holding/metadata_spec.rb +57 -0
- data/spec/exlibris/aleph/holding_spec.rb +53 -0
- data/spec/exlibris/aleph/holdings_spec.rb +59 -0
- data/spec/exlibris/aleph/item/call_number_spec.rb +20 -0
- data/spec/exlibris/aleph/item/circulation_policy/display_spec.rb +33 -0
- data/spec/exlibris/aleph/item/circulation_policy/identifier_spec.rb +154 -0
- data/spec/exlibris/aleph/item/circulation_policy/privileges_spec.rb +183 -0
- data/spec/exlibris/aleph/item/circulation_policy_spec.rb +146 -0
- data/spec/exlibris/aleph/item/circulation_status_spec.rb +83 -0
- data/spec/exlibris/aleph/item/display_mask_spec.rb +72 -0
- data/spec/exlibris/aleph/item/opac_note_spec.rb +19 -0
- data/spec/exlibris/aleph/item/processing_status_spec.rb +75 -0
- data/spec/exlibris/aleph/item/queue_spec.rb +31 -0
- data/spec/exlibris/aleph/item/status_spec.rb +80 -0
- data/spec/exlibris/aleph/item_spec.rb +97 -0
- data/spec/exlibris/aleph/items_spec.rb +59 -0
- data/spec/exlibris/aleph/metadata_spec.rb +118 -0
- data/spec/exlibris/aleph/patron/address_spec.rb +68 -0
- data/spec/exlibris/aleph/patron/circulation_policy/identifier_spec.rb +115 -0
- data/spec/exlibris/aleph/patron/circulation_policy/privileges_spec.rb +128 -0
- data/spec/exlibris/aleph/patron/circulation_policy_spec.rb +119 -0
- data/spec/exlibris/aleph/patron/record/circulation_policy/privileges_spec.rb +88 -0
- data/spec/exlibris/aleph/patron/record/circulation_policy_spec.rb +37 -0
- data/spec/exlibris/aleph/patron/record/item/circulation_policy/privileges_spec.rb +76 -0
- data/spec/exlibris/aleph/patron/record/item/circulation_policy_spec.rb +52 -0
- data/spec/exlibris/aleph/patron/record/item/create_hold_spec.rb +49 -0
- data/spec/exlibris/aleph/patron/record/item/hold_spec.rb +41 -0
- data/spec/exlibris/aleph/patron/record/item_spec.rb +64 -0
- data/spec/exlibris/aleph/patron/record_spec.rb +30 -0
- data/spec/exlibris/aleph/patron/status_spec.rb +72 -0
- data/spec/exlibris/aleph/patron_spec.rb +28 -0
- data/spec/exlibris/aleph/pickup_location_spec.rb +19 -0
- data/spec/exlibris/aleph/record/metadata_spec.rb +120 -0
- data/spec/exlibris/aleph/record_spec.rb +44 -0
- data/spec/exlibris/aleph/sub_library_spec.rb +110 -0
- data/spec/exlibris/aleph/table/base_spec.rb +17 -0
- data/spec/exlibris/aleph/table/collections_spec.rb +24 -0
- data/spec/exlibris/aleph/table/item/circulation_policies_spec.rb +65 -0
- data/spec/exlibris/aleph/table/item/display_masks_spec.rb +26 -0
- data/spec/exlibris/aleph/table/patron/circulation_policies_spec.rb +47 -0
- data/spec/exlibris/aleph/table/patron/statuses_spec.rb +26 -0
- data/spec/exlibris/aleph/table/reader/base_spec.rb +28 -0
- data/spec/exlibris/aleph/table/reader/collections_spec.rb +33 -0
- data/spec/exlibris/aleph/table/reader/item_circulation_policies_spec.rb +33 -0
- data/spec/exlibris/aleph/table/reader/item_display_masks_spec.rb +27 -0
- data/spec/exlibris/aleph/table/reader/matcher/base_spec.rb +32 -0
- data/spec/exlibris/aleph/table/reader/matcher/collections_spec.rb +39 -0
- data/spec/exlibris/aleph/table/reader/matcher/item_circulation_policies_spec.rb +39 -0
- data/spec/exlibris/aleph/table/reader/matcher/item_display_masks_spec.rb +40 -0
- data/spec/exlibris/aleph/table/reader/matcher/patron_circulation_policies_spec.rb +40 -0
- data/spec/exlibris/aleph/table/reader/matcher/patron_statuses_spec.rb +40 -0
- data/spec/exlibris/aleph/table/reader/matcher/sub_libraries_spec.rb +40 -0
- data/spec/exlibris/aleph/table/reader/patron_circulation_policies_spec.rb +27 -0
- data/spec/exlibris/aleph/table/reader/patron_statuses_spec.rb +27 -0
- data/spec/exlibris/aleph/table/reader/row/base_spec.rb +20 -0
- data/spec/exlibris/aleph/table/reader/row/collections_spec.rb +37 -0
- data/spec/exlibris/aleph/table/reader/row/item_circulation_policies_spec.rb +89 -0
- data/spec/exlibris/aleph/table/reader/row/item_display_masks_spec.rb +29 -0
- data/spec/exlibris/aleph/table/reader/row/patron_circulation_policies_spec.rb +115 -0
- data/spec/exlibris/aleph/table/reader/row/patron_statuses_spec.rb +29 -0
- data/spec/exlibris/aleph/table/reader/row/sub_libraries_spec.rb +41 -0
- data/spec/exlibris/aleph/table/reader/sub_libraries_spec.rb +36 -0
- data/spec/exlibris/aleph/table/sub_libraries_spec.rb +19 -0
- data/spec/exlibris/aleph/tables_manager_spec.rb +120 -0
- data/spec/exlibris/aleph_spec.rb +5 -0
- data/spec/spec_helper.rb +27 -0
- data/spec/support/mnt/aleph_tab/adm50/tab/filename +0 -0
- data/{test → spec/support}/mnt/aleph_tab/alephe/tab/tab_sub_library.eng +0 -0
- data/{test → spec/support}/mnt/aleph_tab/nyu50/tab/pc_tab_exp_field_extended.eng +0 -0
- data/{test/mnt/aleph_tab → spec/support/mnt/aleph_tab/nyu50/tab}/tab15.eng +2 -0
- data/{test → spec/support}/mnt/aleph_tab/nyu50/tab/tab16 +0 -0
- data/{test → spec/support}/mnt/aleph_tab/nyu50/tab/tab31 +0 -0
- data/{test → spec/support}/mnt/aleph_tab/nyu50/tab/tab37 +0 -0
- data/{test → spec/support}/mnt/aleph_tab/nyu50/tab/tab40.eng +0 -0
- data/{test → spec/support}/mnt/aleph_tab/nyu50/tab/tab_www_item_desc.eng +0 -0
- data/{test → spec/support}/mnt/aleph_tab/nyu51/tab/pc_tab_exp_field_extended.eng +0 -0
- data/{test → spec/support}/mnt/aleph_tab/nyu51/tab/tab15.eng +0 -0
- data/{test → spec/support}/mnt/aleph_tab/nyu51/tab/tab16 +0 -0
- data/{test → spec/support}/mnt/aleph_tab/nyu51/tab/tab31 +0 -0
- data/{test → spec/support}/mnt/aleph_tab/nyu51/tab/tab37 +0 -0
- data/{test → spec/support}/mnt/aleph_tab/nyu51/tab/tab40.eng +0 -0
- data/{test → spec/support}/mnt/aleph_tab/nyu51/tab/tab_www_item_desc.eng +0 -0
- data/spec/vcr_cassettes/patron.yml +1443 -0
- data/spec/vcr_cassettes/record.yml +763 -0
- metadata +351 -165
- data/lib/exlibris/aleph/abstract.rb +0 -28
- data/lib/exlibris/aleph/rest/base.rb +0 -56
- data/lib/exlibris/aleph/tab_helper.rb +0 -303
- data/lib/exlibris/aleph/tabs_parser/base.rb +0 -49
- data/lib/exlibris/aleph/tabs_parser/pc_tab_exp_field_extended.rb +0 -20
- data/lib/exlibris/aleph/tabs_parser/sub_library.rb +0 -32
- data/lib/exlibris/aleph/tabs_parser/tab15_by_item_process_status.rb +0 -33
- data/lib/exlibris/aleph/tabs_parser/tab15_by_item_status.rb +0 -33
- data/lib/exlibris/aleph/tabs_parser/tab31.rb +0 -39
- data/lib/exlibris/aleph/tabs_parser/tab37.rb +0 -63
- data/lib/exlibris/aleph/tabs_parser/tab40.rb +0 -20
- data/lib/exlibris/aleph/tabs_parser/tab_sub_library.rb +0 -21
- data/lib/exlibris/aleph/tabs_parser/tab_www_item_desc.rb +0 -20
- data/lib/exlibris/aleph/task_installer.rb +0 -25
- data/lib/exlibris/aleph/write_attributes.rb +0 -38
- data/lib/exlibris/aleph/xml_util.rb +0 -50
- data/lib/exlibris/aleph/xservice/bor_auth.rb +0 -47
- data/lib/tasks/exlibris-aleph_tasks.rake +0 -48
- data/test/config/aleph/alephe/sub_libraries.yml +0 -801
- data/test/config/aleph/nyu50/collections.yml +0 -1168
- data/test/config/aleph/nyu50/item_permissions_by_item_process_status.yml +0 -61876
- data/test/config/aleph/nyu50/item_permissions_by_item_status.yml +0 -17319
- data/test/config/aleph/nyu50/items.yml +0 -617
- data/test/config/aleph/nyu50/patron_permissions.yml +0 -19720
- data/test/config/aleph/nyu50/patrons.yml +0 -249
- data/test/config/aleph/nyu50/pickup_locations.yml +0 -2910
- data/test/config/aleph/nyu51/collections.yml +0 -41
- data/test/config/aleph/nyu51/item_permissions_by_item_process_status.yml +0 -7689
- data/test/config/aleph/nyu51/item_permissions_by_item_status.yml +0 -430
- data/test/config/aleph/nyu51/items.yml +0 -617
- data/test/config/aleph/nyu51/patron_permissions.yml +0 -6588
- data/test/config/aleph/nyu51/patrons.yml +0 -237
- data/test/config/aleph/nyu51/pickup_locations.yml +0 -456
- data/test/config_test.rb +0 -24
- data/test/exlibris-aleph_test.rb +0 -7
- data/test/mnt/aleph_tab/nyu50/tab/tab15.eng +0 -4742
- data/test/mnt/aleph_tab/pc_tab_exp_field_extended.eng +0 -158
- data/test/mnt/aleph_tab/tab16 +0 -3792
- data/test/mnt/aleph_tab/tab31 +0 -998
- data/test/mnt/aleph_tab/tab37 +0 -405
- data/test/mnt/aleph_tab/tab40.eng +0 -335
- data/test/mnt/aleph_tab/tab_sub_library.eng +0 -378
- data/test/mnt/aleph_tab/tab_www_item_desc.eng +0 -208
- data/test/patron_test.rb +0 -98
- data/test/record_benchmarks.rb +0 -26
- data/test/record_test.rb +0 -64
- data/test/support/config.yml +0 -2
- data/test/tab_helper_benchmarks.rb +0 -53
- data/test/tab_helper_test.rb +0 -192
- data/test/test_helper.rb +0 -46
- data/test/vcr_cassettes/bor_auth.yml +0 -42
- data/test/vcr_cassettes/patron.yml +0 -142
- data/test/vcr_cassettes/patron_address.yml +0 -45
- data/test/vcr_cassettes/patron_bogus_url.yml +0 -731
- data/test/vcr_cassettes/patron_error.yml +0 -93
- data/test/vcr_cassettes/record.yml +0 -146
- data/test/vcr_cassettes/record_bogus_url.yml +0 -690
- data/test/xservice/bor_auth_test.rb +0 -28
@@ -1,28 +0,0 @@
|
|
1
|
-
module Exlibris
|
2
|
-
module Aleph
|
3
|
-
#
|
4
|
-
# If a class is abstract, it can't be instantiated.
|
5
|
-
#
|
6
|
-
module Abstract
|
7
|
-
def self.included(klass)
|
8
|
-
klass.class_eval do
|
9
|
-
extend ClassAttributes
|
10
|
-
end
|
11
|
-
end
|
12
|
-
|
13
|
-
module ClassAttributes
|
14
|
-
def abstract
|
15
|
-
@abstract ||= false
|
16
|
-
end
|
17
|
-
alias :abstract? :abstract
|
18
|
-
|
19
|
-
attr_writer :abstract
|
20
|
-
protected :abstract=
|
21
|
-
end
|
22
|
-
|
23
|
-
def initialize *args
|
24
|
-
raise NotImplementedError.new("Cannot instantiate #{self.class.name}. It is abstract") if self.class.abstract?
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|
@@ -1,56 +0,0 @@
|
|
1
|
-
module Exlibris
|
2
|
-
module Aleph
|
3
|
-
module Rest
|
4
|
-
require 'httparty'
|
5
|
-
# ==Overview
|
6
|
-
# Base implementation for Aleph REST APIs.
|
7
|
-
# Not intended for use on its own, but should
|
8
|
-
# instead be extended by implementing classes.
|
9
|
-
class Base
|
10
|
-
include HTTParty
|
11
|
-
include Abstract
|
12
|
-
include Config::Attributes
|
13
|
-
include XmlUtil
|
14
|
-
include WriteAttributes
|
15
|
-
self.format :xml
|
16
|
-
self.abstract = true
|
17
|
-
|
18
|
-
attr_writer :rest_url
|
19
|
-
attr_accessor :response
|
20
|
-
protected :response=
|
21
|
-
|
22
|
-
# Returns the error associated with the request.
|
23
|
-
# Returns nil if no error.
|
24
|
-
def error
|
25
|
-
return nil if reply_code == "0000"
|
26
|
-
return "#{reply_text}"
|
27
|
-
end
|
28
|
-
|
29
|
-
# Returns the reply code associate with the request.
|
30
|
-
def reply_code
|
31
|
-
return "No response." if response.nil?
|
32
|
-
return (not response.first.last.kind_of?(Hash) or response.first.last["reply_code"].nil?) ? "Unexpected response hash." : response.first.last["reply_code"] if response.instance_of?(Hash)
|
33
|
-
response_match = response.match(/\<reply-code\>(.+)\<\/reply-code\>/) if response.instance_of?(String)
|
34
|
-
return (response_match.nil?) ? "Unexpected response string." : response_match[1] if response.instance_of?(String)
|
35
|
-
return "Unexpected response type."
|
36
|
-
end
|
37
|
-
|
38
|
-
# Returns the reply text associate with the request.
|
39
|
-
def reply_text
|
40
|
-
return "No response." if response.nil?
|
41
|
-
return (not response.first.last.kind_of?(Hash) or response.first.last["reply_text"].nil?) ? "Unexpected response hash." : response.first.last["reply_text"] if response.instance_of?(Hash)
|
42
|
-
response_match = response.match(/\<reply-text\>(.+)\<\/reply-text\>/) if response.instance_of?(String)
|
43
|
-
return (response_match.nil?) ? "Unexpected response string." : response_match[1] if response.instance_of?(String)
|
44
|
-
return "Unexpected response type."
|
45
|
-
end
|
46
|
-
|
47
|
-
def raise_error_if *args, &block
|
48
|
-
message = (args.shift || "Error in the Aleph REST APIs.")
|
49
|
-
block_value = (block_given?) ? yield : false
|
50
|
-
raise "#{message} #{error}" if error or block_value
|
51
|
-
end
|
52
|
-
protected :raise_error_if
|
53
|
-
end
|
54
|
-
end
|
55
|
-
end
|
56
|
-
end
|
@@ -1,303 +0,0 @@
|
|
1
|
-
module Exlibris
|
2
|
-
module Aleph
|
3
|
-
require 'singleton'
|
4
|
-
require 'yaml'
|
5
|
-
# ==Overview
|
6
|
-
# Exlibris::Aleph::TabHelper assumes a mount of Aleph tab files and provides
|
7
|
-
# a way to access the various tab settings for patrons, patron_permissions,
|
8
|
-
# items, item_permission (both by item status and by item processing status),
|
9
|
-
# collections and pickup locations.
|
10
|
-
# It also provides convenience methods for common tasks like getting the
|
11
|
-
# pickup location for a given combination of item status, item process status
|
12
|
-
# and borrower status or getting an item's web text.
|
13
|
-
# To initialize Exlibris::Aleph::TabHelper call Exlibris::Aleph::TabHelper.init
|
14
|
-
# in an initializer.
|
15
|
-
class TabHelper
|
16
|
-
extend Config::Attributes
|
17
|
-
include Singleton
|
18
|
-
attr_reader :updated_at
|
19
|
-
@@alephe_tabs = {
|
20
|
-
:sub_libraries => :TabSubLibrary
|
21
|
-
}
|
22
|
-
@@adm_tabs = {
|
23
|
-
:patrons => :PcTabExpFieldExtended,
|
24
|
-
:patron_permissions => :Tab31,
|
25
|
-
:items => :TabWwwItemDesc,
|
26
|
-
:item_permissions_by_item_status => :Tab15ByItemStatus,
|
27
|
-
:item_permissions_by_item_process_status => :Tab15ByItemProcessStatus,
|
28
|
-
:collections => :Tab40,
|
29
|
-
:pickup_locations => :Tab37 }
|
30
|
-
@@tabs = @@alephe_tabs.keys + @@adm_tabs.keys
|
31
|
-
|
32
|
-
# Refreshes the yml files that are used to parse the tables.
|
33
|
-
def self.refresh_yml
|
34
|
-
mkdirs
|
35
|
-
@@alephe_tabs.each do |key, klass|
|
36
|
-
tab = Exlibris::Aleph::TabParser.const_get(klass).new(:aleph_library => "ALEPHE", :aleph_mnt_path => tab_path).to_h
|
37
|
-
File.open( File.join(yml_path, "alephe", "#{key}.yml"), 'w' ) { |out| YAML.dump( tab, out ) } unless tab.empty?
|
38
|
-
end
|
39
|
-
@@adm_tabs.each do |key, klass|
|
40
|
-
adms.each do |adm|
|
41
|
-
tab = Exlibris::Aleph::TabParser.const_get(klass).new(:aleph_library => adm, :aleph_mnt_path => tab_path).to_h
|
42
|
-
File.open( File.join(yml_path, adm, "#{key}.yml"), 'w' ) { |out| YAML.dump( tab, out ) } unless tab.empty?
|
43
|
-
end
|
44
|
-
end
|
45
|
-
end
|
46
|
-
|
47
|
-
# Make the necessary directories
|
48
|
-
def self.mkdirs
|
49
|
-
FileUtils.mkdir_p File.join(yml_path, "alephe")
|
50
|
-
adms.each do |adm|
|
51
|
-
FileUtils.mkdir_p File.join(yml_path, adm)
|
52
|
-
end
|
53
|
-
end
|
54
|
-
|
55
|
-
# Private initialzize method for the singleton.
|
56
|
-
def initialize
|
57
|
-
raise ArgumentError.new("No tab path was specified.") if self.class.tab_path.nil?
|
58
|
-
raise ArgumentError.new("No yml path was specified.") if self.class.yml_path.nil?
|
59
|
-
raise ArgumentError.new("No refresh time was specified.") if self.class.refresh_time.nil?
|
60
|
-
self.class.refresh_yml
|
61
|
-
@@tabs.each { |tab|
|
62
|
-
# Default to empty hash
|
63
|
-
instance_variable_set("@#{tab}".to_sym, {})
|
64
|
-
# Define reader w/ refresh
|
65
|
-
self.class.send(:define_method, tab) {
|
66
|
-
refresh if refresh?
|
67
|
-
instance_variable_get("@#{tab}".to_sym)
|
68
|
-
}
|
69
|
-
}
|
70
|
-
refresh
|
71
|
-
end
|
72
|
-
|
73
|
-
# Returns the sub library display text for the given sub library code
|
74
|
-
def sub_library_text(code)
|
75
|
-
sub_library = @sub_libraries[code]
|
76
|
-
return sub_library[:text] unless sub_library.nil?
|
77
|
-
end
|
78
|
-
|
79
|
-
# Returns the ADM associated with the given sub library code
|
80
|
-
def sub_library_adm(code)
|
81
|
-
sub_library = @sub_libraries[code]
|
82
|
-
return sub_library[:library] unless sub_library.nil?
|
83
|
-
end
|
84
|
-
|
85
|
-
# Returns an array of pickup locations based on the given params.
|
86
|
-
# Available param keys are:
|
87
|
-
# :adm_library_code, :sub_library_code, :item_status_code,
|
88
|
-
# :item_process_status_code, :bor_status, :availability_status
|
89
|
-
def item_pickup_locations(params)
|
90
|
-
adm_locations = pickup_locations[params[:adm_library_code]]
|
91
|
-
sub_locations = adm_locations[params[:sub_library_code]] unless adm_locations.nil?
|
92
|
-
|
93
|
-
# First try the most specific
|
94
|
-
item_locations = sub_locations[params[:item_status_code]] unless sub_locations.nil?
|
95
|
-
item_procesing_locations = item_locations[params[:item_process_status_code]] unless item_locations.nil?
|
96
|
-
borrower_locations = item_procesing_locations[params[:bor_status]] unless item_procesing_locations.nil?
|
97
|
-
availability_locations = item_procesing_locations[params[:bor_status]] unless item_procesing_locations.nil?
|
98
|
-
locations = (borrower_locations.has_key?(params[:availability_status])) ?
|
99
|
-
borrower_locations[:availability_status] : borrower_locations["#"] unless borrower_locations.nil?
|
100
|
-
return locations[:pickup_locations] unless locations.nil?
|
101
|
-
|
102
|
-
# Wild card item status
|
103
|
-
item_locations, item_procesing_locations, borrower_locations = nil, nil, nil
|
104
|
-
item_locations = sub_locations["##"] unless sub_locations.nil?
|
105
|
-
item_procesing_locations = item_locations[params[:item_process_status_code]] unless item_locations.nil?
|
106
|
-
borrower_locations = item_procesing_locations[params[:bor_status]] unless item_procesing_locations.nil?
|
107
|
-
locations = (borrower_locations.has_key?(params[:availability_status])) ?
|
108
|
-
borrower_locations[:availability_status] : borrower_locations["#"] unless borrower_locations.nil?
|
109
|
-
return locations[:pickup_locations] unless locations.nil?
|
110
|
-
|
111
|
-
# Wild card item process status
|
112
|
-
item_locations, item_procesing_locations, borrower_locations = nil, nil, nil
|
113
|
-
item_locations = sub_locations[params[:item_status_code]] unless sub_locations.nil?
|
114
|
-
item_procesing_locations = item_locations["##"] unless item_locations.nil?
|
115
|
-
borrower_locations = item_procesing_locations[params[:bor_status]] unless item_procesing_locations.nil?
|
116
|
-
locations = (borrower_locations.has_key?(params[:availability_status])) ?
|
117
|
-
borrower_locations[:availability_status] : borrower_locations["#"] unless borrower_locations.nil?
|
118
|
-
return locations[:pickup_locations] unless locations.nil?
|
119
|
-
|
120
|
-
# Wild card item status and item process status
|
121
|
-
item_locations, item_procesing_locations, borrower_locations = nil, nil, nil
|
122
|
-
item_locations = sub_locations["##"] unless sub_locations.nil?
|
123
|
-
item_procesing_locations = item_locations["##"] unless item_locations.nil?
|
124
|
-
borrower_locations = item_procesing_locations[params[:bor_status]] unless item_procesing_locations.nil?
|
125
|
-
locations = (borrower_locations.has_key?(params[:availability_status])) ?
|
126
|
-
borrower_locations[:availability_status] : borrower_locations["#"] unless borrower_locations.nil?
|
127
|
-
return locations[:pickup_locations] unless locations.nil?
|
128
|
-
|
129
|
-
# Wild card patron status
|
130
|
-
item_locations, item_procesing_locations, borrower_locations = nil, nil, nil
|
131
|
-
item_locations = sub_locations[params[:item_status_code]] unless sub_locations.nil?
|
132
|
-
item_procesing_locations = item_locations[params[:item_process_status_code]] unless item_locations.nil?
|
133
|
-
borrower_locations = item_procesing_locations["##"] unless item_procesing_locations.nil?
|
134
|
-
locations = (borrower_locations.has_key?(params[:availability_status])) ?
|
135
|
-
borrower_locations[:availability_status] : borrower_locations["#"] unless borrower_locations.nil?
|
136
|
-
return locations[:pickup_locations] unless locations.nil?
|
137
|
-
|
138
|
-
# Wild card patron status and item status
|
139
|
-
item_locations, item_procesing_locations, borrower_locations = nil, nil, nil
|
140
|
-
item_locations = sub_locations["##"] unless sub_locations.nil?
|
141
|
-
item_procesing_locations = item_locations[params[:item_process_status_code]] unless item_locations.nil?
|
142
|
-
borrower_locations = item_procesing_locations["##"] unless item_procesing_locations.nil?
|
143
|
-
locations = (borrower_locations.has_key?(params[:availability_status])) ?
|
144
|
-
borrower_locations[:availability_status] : borrower_locations["#"] unless borrower_locations.nil?
|
145
|
-
return locations[:pickup_locations] unless locations.nil?
|
146
|
-
|
147
|
-
# Wild card patron status and item process status
|
148
|
-
item_locations, item_procesing_locations, borrower_locations = nil, nil, nil
|
149
|
-
item_locations = sub_locations[params[:item_status_code]] unless sub_locations.nil?
|
150
|
-
item_procesing_locations = item_locations["##"] unless item_locations.nil?
|
151
|
-
borrower_locations = item_procesing_locations["##"] unless item_procesing_locations.nil?
|
152
|
-
locations = (borrower_locations.has_key?(params[:availability_status])) ?
|
153
|
-
borrower_locations[:availability_status] : borrower_locations["#"] unless borrower_locations.nil?
|
154
|
-
return locations[:pickup_locations] unless locations.nil?
|
155
|
-
|
156
|
-
# Wild card everything
|
157
|
-
item_locations, item_procesing_locations, borrower_locations = nil, nil, nil
|
158
|
-
item_locations = sub_locations["##"] unless sub_locations.nil?
|
159
|
-
item_procesing_locations = item_locations["##"] unless item_locations.nil?
|
160
|
-
borrower_locations = item_procesing_locations["##"] unless item_procesing_locations.nil?
|
161
|
-
locations = (borrower_locations.has_key?(params[:availability_status])) ?
|
162
|
-
borrower_locations[:availability_status] : borrower_locations["#"] unless borrower_locations.nil?
|
163
|
-
return locations[:pickup_locations] unless locations.nil?
|
164
|
-
|
165
|
-
# Set the pickup location to default to the passed in sub library
|
166
|
-
logger.warn(
|
167
|
-
"Warning in #{self.class}. "+
|
168
|
-
"Pickup locations not found. "+
|
169
|
-
"Defaulting to Aleph item sub library, #{params[:sub_library_code]}.\n"+
|
170
|
-
"Additional parameters:\n"+
|
171
|
-
"\tADM library: #{params[:adm_library_code]}\n"+
|
172
|
-
"\tSub library: #{params[:sub_library_code]}\n"+
|
173
|
-
"\tItem status: #{params[:item_status_code]}\n"+
|
174
|
-
"\tItem process status: #{params[:item_process_status_code]}\n"+
|
175
|
-
"\tAvailability status: #{params[:availability_status]}\n"+
|
176
|
-
"\tBorrower status: #{params[:bor_status]}\n"
|
177
|
-
)
|
178
|
-
return [params[:sub_library_code]]
|
179
|
-
end
|
180
|
-
|
181
|
-
# Returns collection text for the given params.
|
182
|
-
# Available param keys are:
|
183
|
-
# :adm_library_code, :sub_library_code, :collection_code
|
184
|
-
def collection_text(params)
|
185
|
-
adm = collections[params[:adm_library_code]]
|
186
|
-
sub = adm[params[:sub_library_code]] unless adm.nil?
|
187
|
-
coll = sub[params[:collection_code]] unless sub.nil?
|
188
|
-
return coll[:text] unless coll.nil?
|
189
|
-
end
|
190
|
-
|
191
|
-
# Returns web display text for the given params.
|
192
|
-
# Available param keys are:
|
193
|
-
# :adm_library_code, :sub_library_code, :item_status_code, :item_process_status_code, :item_status, :item_process_status
|
194
|
-
def item_web_text(params)
|
195
|
-
adm = items[params[:adm_library_code]]
|
196
|
-
item = (adm[params[:item_process_status]].nil?) ? adm[params[:item_status]] : adm[params[:item_process_status]] unless (params[:item_status].nil? and params[:item_process_status].nil?) or adm.nil?
|
197
|
-
permissions = item_permissions(params) if item.nil?
|
198
|
-
item = adm[permissions[:text]] unless permissions.nil? or adm.nil?
|
199
|
-
return item[:web_text] unless item.nil?
|
200
|
-
return permissions[:text] unless permissions.nil?
|
201
|
-
end
|
202
|
-
|
203
|
-
# Returns item permissions for the given params.
|
204
|
-
# Available param keys are:
|
205
|
-
# :adm_library_code, :sub_library_code, :item_status_code, :item_process_status_code
|
206
|
-
def item_permissions(params)
|
207
|
-
item_permissions = {}
|
208
|
-
# Item process statuses take precedent in Aleph, same here.
|
209
|
-
if item_permissions.empty? and params[:item_process_status_code]
|
210
|
-
adm_permissions =
|
211
|
-
item_permissions_by_item_process_status[params[:adm_library_code]]
|
212
|
-
sublibrary_permissions =
|
213
|
-
adm_permissions[params[:sub_library_code]] unless adm_permissions.nil?
|
214
|
-
item_permissions =
|
215
|
-
sublibrary_permissions[params[:item_process_status_code]] unless sublibrary_permissions.nil?
|
216
|
-
end
|
217
|
-
# If we didn't find anything with the item process status, try the item status
|
218
|
-
if item_permissions.empty? and params[:item_status_code]
|
219
|
-
adm_permissions = item_permissions_by_item_status[params[:adm_library_code]]
|
220
|
-
sublibrary_permissions =
|
221
|
-
adm_permissions[params[:sub_library_code]] unless adm_permissions.nil?
|
222
|
-
item_permissions =
|
223
|
-
sublibrary_permissions[params[:item_status_code]] unless sublibrary_permissions.nil?
|
224
|
-
end
|
225
|
-
rescue => e
|
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)
|
234
|
-
logger.error("Error: \n\t#{e}")
|
235
|
-
ensure
|
236
|
-
return item_permissions
|
237
|
-
end
|
238
|
-
|
239
|
-
def refresh?
|
240
|
-
return (@updated_at.nil? or @updated_at < refresh_time.call)
|
241
|
-
end
|
242
|
-
private :refresh?
|
243
|
-
|
244
|
-
def refresh
|
245
|
-
@@alephe_tabs.each_key do |tab|
|
246
|
-
instance_variable_set("@#{tab}".to_sym, YAML.load_file(File.join(yml_path, "alephe", "#{tab}.yml")))
|
247
|
-
end
|
248
|
-
@@adm_tabs.each_key do |tab|
|
249
|
-
adms.each do |adm|
|
250
|
-
instance_variable_get("@#{tab}".to_sym)[adm] =
|
251
|
-
YAML.load_file(File.join(yml_path, adm, "#{tab}.yml"))
|
252
|
-
end
|
253
|
-
end
|
254
|
-
# Delete irrelevant sub libraries from @sub_library
|
255
|
-
@sub_libraries.delete_if {|key,value| irrelevant_sub_libraries.include? key }
|
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?
|
259
|
-
end
|
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
|
277
|
-
|
278
|
-
def adms
|
279
|
-
@adms ||= self.class.adms
|
280
|
-
end
|
281
|
-
|
282
|
-
def yml_path
|
283
|
-
@yml_path ||= self.class.yml_path
|
284
|
-
end
|
285
|
-
private :yml_path
|
286
|
-
|
287
|
-
def refresh_time
|
288
|
-
@refresh_time ||= self.class.refresh_time
|
289
|
-
end
|
290
|
-
private :refresh_time
|
291
|
-
|
292
|
-
def logger
|
293
|
-
@logger ||= self.class.logger
|
294
|
-
end
|
295
|
-
private :logger
|
296
|
-
|
297
|
-
def irrelevant_sub_libraries
|
298
|
-
@irrelevant_sub_libraries ||= self.class.irrelevant_sub_libraries
|
299
|
-
end
|
300
|
-
private :irrelevant_sub_libraries
|
301
|
-
end
|
302
|
-
end
|
303
|
-
end
|
@@ -1,49 +0,0 @@
|
|
1
|
-
module Exlibris
|
2
|
-
module Aleph
|
3
|
-
module TabParser
|
4
|
-
class Base
|
5
|
-
attr_accessor :library, :file_name, :pattern, :pattern_key
|
6
|
-
attr_accessor :local_path, :local_file
|
7
|
-
attr_accessor :config_array, :config_hash, :hash_key
|
8
|
-
|
9
|
-
def initialize(args)
|
10
|
-
@aleph_library = args[:aleph_library]
|
11
|
-
@aleph_library.downcase!
|
12
|
-
@aleph_file_name = args[:aleph_file_name]
|
13
|
-
@aleph_file_name.downcase!
|
14
|
-
@pattern = args[:pattern]
|
15
|
-
@pattern_key = args[:pattern_key]
|
16
|
-
@hash_key = args[:hash_key]
|
17
|
-
@aleph_file = "#{args[:aleph_mnt_path]}/#{@aleph_library}/tab/#{@aleph_file_name}"
|
18
|
-
end
|
19
|
-
|
20
|
-
def to_a
|
21
|
-
@config_array ||= parse_file.first
|
22
|
-
end
|
23
|
-
|
24
|
-
def to_h
|
25
|
-
@config_hash ||= parse_file.last
|
26
|
-
end
|
27
|
-
|
28
|
-
protected
|
29
|
-
def parse_file
|
30
|
-
config_array = []
|
31
|
-
config_hash = {}
|
32
|
-
File.open(@aleph_file).each do |line|
|
33
|
-
line.chomp!
|
34
|
-
config_match = line.match(@pattern)
|
35
|
-
if (config_match)
|
36
|
-
config_match_hash = {}
|
37
|
-
@pattern_key.each do |column, key|
|
38
|
-
config_match_hash[key] = config_match[column].strip
|
39
|
-
end
|
40
|
-
config_array.push(config_match_hash) unless config_match_hash.empty?
|
41
|
-
config_hash[config_match_hash[@hash_key]] = config_match_hash unless config_match_hash.empty?
|
42
|
-
end
|
43
|
-
end
|
44
|
-
return [config_array, config_hash]
|
45
|
-
end
|
46
|
-
end
|
47
|
-
end
|
48
|
-
end
|
49
|
-
end
|
@@ -1,20 +0,0 @@
|
|
1
|
-
module Exlibris
|
2
|
-
module Aleph
|
3
|
-
module TabParser
|
4
|
-
class PcTabExpFieldExtended < Exlibris::Aleph::TabParser::Base
|
5
|
-
|
6
|
-
def initialize(args)
|
7
|
-
args[:aleph_file_name] = "pc_tab_exp_field_extended.eng"
|
8
|
-
args[:pattern] = /^(BOR-STATUS\s{10})\s(.{5})\s(L)\s(.{50})\s([^\n]*)/
|
9
|
-
args[:pattern_key] = {
|
10
|
-
2 => :sublibrary,
|
11
|
-
4 => :text,
|
12
|
-
5 => :code
|
13
|
-
}
|
14
|
-
args[:hash_key] = :code
|
15
|
-
super(args)
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|