berkeley_library-alma 0.0.4 → 0.0.5
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 +4 -4
- data/.idea/alma.iml +7 -6
- data/CHANGES.md +5 -0
- data/README.md +43 -5
- data/lib/berkeley_library/alma/module_info.rb +1 -1
- data/lib/berkeley_library/alma/record_id.rb +9 -26
- data/lib/berkeley_library/alma/sru.rb +79 -0
- data/spec/data/availability-sru.xml +109 -0
- data/spec/lib/berkeley_library/alma/record_id_spec.rb +20 -0
- data/spec/lib/berkeley_library/alma/sru_spec.rb +29 -0
- metadata +7 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: '0805d8fb305dd644ede89efb0c71845c479df3cc8b69334bbfc4e747312c229d'
|
|
4
|
+
data.tar.gz: 80b1576c6dc7d5bbfd5bd5a0a53985167c4c3929668d505dae92ffcac196988e
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 879cb4ef386caa8543bf883ac3b62888c4ca810ef431562618ad456c9d560ee81f6dada5b9ae850ca15523cd6f58d5487919c3e782c817313deaff346912c257
|
|
7
|
+
data.tar.gz: b10240d0571733f28f90ab099da879647cdd670da05c5af5aa396f0fcd8c9ae026d2ec9b4c1246764a6b919bc594c665ff0096140b400cb2626af893bdcd3b21
|
data/.idea/alma.iml
CHANGED
|
@@ -12,9 +12,9 @@
|
|
|
12
12
|
</content>
|
|
13
13
|
<orderEntry type="jdk" jdkName="RVM: ruby-2.7.5" jdkType="RUBY_SDK" />
|
|
14
14
|
<orderEntry type="sourceFolder" forTests="false" />
|
|
15
|
-
<orderEntry type="library" scope="PROVIDED" name="actionpack (v6.1.4.
|
|
16
|
-
<orderEntry type="library" scope="PROVIDED" name="actionview (v6.1.4.
|
|
17
|
-
<orderEntry type="library" scope="PROVIDED" name="activesupport (v6.1.4.
|
|
15
|
+
<orderEntry type="library" scope="PROVIDED" name="actionpack (v6.1.4.6, RVM: ruby-2.7.5) [gem]" level="application" />
|
|
16
|
+
<orderEntry type="library" scope="PROVIDED" name="actionview (v6.1.4.6, RVM: ruby-2.7.5) [gem]" level="application" />
|
|
17
|
+
<orderEntry type="library" scope="PROVIDED" name="activesupport (v6.1.4.6, RVM: ruby-2.7.5) [gem]" level="application" />
|
|
18
18
|
<orderEntry type="library" scope="PROVIDED" name="addressable (v2.8.0, RVM: ruby-2.7.5) [gem]" level="application" />
|
|
19
19
|
<orderEntry type="library" scope="PROVIDED" name="amazing_print (v1.4.0, RVM: ruby-2.7.5) [gem]" level="application" />
|
|
20
20
|
<orderEntry type="library" scope="PROVIDED" name="ast (v2.4.2, RVM: ruby-2.7.5) [gem]" level="application" />
|
|
@@ -38,13 +38,14 @@
|
|
|
38
38
|
<orderEntry type="library" scope="PROVIDED" name="hashdiff (v1.0.1, RVM: ruby-2.7.5) [gem]" level="application" />
|
|
39
39
|
<orderEntry type="library" scope="PROVIDED" name="http-accept (v1.7.0, RVM: ruby-2.7.5) [gem]" level="application" />
|
|
40
40
|
<orderEntry type="library" scope="PROVIDED" name="http-cookie (v1.0.4, RVM: ruby-2.7.5) [gem]" level="application" />
|
|
41
|
-
<orderEntry type="library" scope="PROVIDED" name="i18n (v1.
|
|
41
|
+
<orderEntry type="library" scope="PROVIDED" name="i18n (v1.10.0, RVM: ruby-2.7.5) [gem]" level="application" />
|
|
42
42
|
<orderEntry type="library" scope="PROVIDED" name="lograge (v0.11.2, RVM: ruby-2.7.5) [gem]" level="application" />
|
|
43
|
-
<orderEntry type="library" scope="PROVIDED" name="loofah (v2.
|
|
43
|
+
<orderEntry type="library" scope="PROVIDED" name="loofah (v2.14.0, RVM: ruby-2.7.5) [gem]" level="application" />
|
|
44
44
|
<orderEntry type="library" scope="PROVIDED" name="marc (v1.1.1, RVM: ruby-2.7.5) [gem]" level="application" />
|
|
45
45
|
<orderEntry type="library" scope="PROVIDED" name="method_source (v1.0.0, RVM: ruby-2.7.5) [gem]" level="application" />
|
|
46
46
|
<orderEntry type="library" scope="PROVIDED" name="mime-types (v3.4.1, RVM: ruby-2.7.5) [gem]" level="application" />
|
|
47
47
|
<orderEntry type="library" scope="PROVIDED" name="mime-types-data (v3.2022.0105, RVM: ruby-2.7.5) [gem]" level="application" />
|
|
48
|
+
<orderEntry type="library" scope="PROVIDED" name="mini_portile2 (v2.7.1, RVM: ruby-2.7.5) [gem]" level="application" />
|
|
48
49
|
<orderEntry type="library" scope="PROVIDED" name="minitest (v5.15.0, RVM: ruby-2.7.5) [gem]" level="application" />
|
|
49
50
|
<orderEntry type="library" scope="PROVIDED" name="netrc (v0.11.0, RVM: ruby-2.7.5) [gem]" level="application" />
|
|
50
51
|
<orderEntry type="library" scope="PROVIDED" name="nokogiri (v1.13.1, RVM: ruby-2.7.5) [gem]" level="application" />
|
|
@@ -59,7 +60,7 @@
|
|
|
59
60
|
<orderEntry type="library" scope="PROVIDED" name="rack-test (v1.1.0, RVM: ruby-2.7.5) [gem]" level="application" />
|
|
60
61
|
<orderEntry type="library" scope="PROVIDED" name="rails-dom-testing (v2.0.3, RVM: ruby-2.7.5) [gem]" level="application" />
|
|
61
62
|
<orderEntry type="library" scope="PROVIDED" name="rails-html-sanitizer (v1.4.2, RVM: ruby-2.7.5) [gem]" level="application" />
|
|
62
|
-
<orderEntry type="library" scope="PROVIDED" name="railties (v6.1.4.
|
|
63
|
+
<orderEntry type="library" scope="PROVIDED" name="railties (v6.1.4.6, RVM: ruby-2.7.5) [gem]" level="application" />
|
|
63
64
|
<orderEntry type="library" scope="PROVIDED" name="rainbow (v3.1.1, RVM: ruby-2.7.5) [gem]" level="application" />
|
|
64
65
|
<orderEntry type="library" scope="PROVIDED" name="rake (v13.0.6, RVM: ruby-2.7.5) [gem]" level="application" />
|
|
65
66
|
<orderEntry type="library" scope="PROVIDED" name="regexp_parser (v2.2.0, RVM: ruby-2.7.5) [gem]" level="application" />
|
data/CHANGES.md
CHANGED
|
@@ -1,3 +1,8 @@
|
|
|
1
|
+
# 0.0.5 (4 May 2022)
|
|
2
|
+
|
|
3
|
+
- extracts `SRU` module for performing SRU queries.
|
|
4
|
+
- MARCXML parsing now uses `MARC::NokogiriReader` rather than the `REXML` default.
|
|
5
|
+
|
|
1
6
|
# 0.0.4 (15 February 2022)
|
|
2
7
|
|
|
3
8
|
- adds `BarCode` subclass of `RecordId`, to look up bibliographic records by
|
data/README.md
CHANGED
|
@@ -41,10 +41,34 @@ options to either:
|
|
|
41
41
|
|
|
42
42
|
## Retrieving Alma records
|
|
43
43
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
[SRU](
|
|
47
|
-
|
|
44
|
+
### Via `SRU`
|
|
45
|
+
|
|
46
|
+
The [`SRU`](lib/berkeley_library/alma/sru.rb) module encapsulates Alma
|
|
47
|
+
[SRU](https://developers.exlibrisgroup.com/alma/integrations/sru/) queries.
|
|
48
|
+
|
|
49
|
+
Retrieving MARC records:
|
|
50
|
+
|
|
51
|
+
```ruby
|
|
52
|
+
reader = BerkeleyLibrary::Alma::SRU.get_marc_records('991005668209706532', '991005668359706532')
|
|
53
|
+
# => #<MARC::XMLReader:0x0000000135b940e8 @freeze=false, @handle=#<StringIO:0x0000000135b94160>...
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
Making arbitrary SRU queries:
|
|
57
|
+
|
|
58
|
+
```ruby
|
|
59
|
+
BerkeleyLibrary::Alma::SRU.make_sru_query('alma.other_system_number=UCB-b123230470-01ucs_ber')
|
|
60
|
+
# => "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?><searchRetrieveResponse xmlns=...
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
### Via `RecordId`
|
|
64
|
+
|
|
65
|
+
In addition, individual records can be retrieved from an instance of the
|
|
66
|
+
[`RecordId`](lib/berkeley_library/alma/record_id.rb) class, which encapsulates
|
|
67
|
+
an Alma MMS ID, Millennium bib number, or item barcode.
|
|
68
|
+
|
|
69
|
+
#### Initializing `RecordID` objects
|
|
70
|
+
|
|
71
|
+
Alma MMS ID:
|
|
48
72
|
|
|
49
73
|
```ruby
|
|
50
74
|
mms_id_str = '991054360089706532'
|
|
@@ -52,7 +76,7 @@ record_id = BerkeleyLibrary::Alma::RecordId.parse(mms_id_str)
|
|
|
52
76
|
# => #<BerkeleyLibrary::Alma::MMSID:0x0000000138949830 @institution="6532", @mms_id="991054360089706532", @type_prefix="99", @unique_part="105436008970">
|
|
53
77
|
```
|
|
54
78
|
|
|
55
|
-
|
|
79
|
+
Millennium bib number:
|
|
56
80
|
|
|
57
81
|
```ruby
|
|
58
82
|
bib_number_str = 'b11082434'
|
|
@@ -60,6 +84,20 @@ record_id = BerkeleyLibrary::Alma::RecordId.parse(bib_number_str)
|
|
|
60
84
|
# => #<BerkeleyLibrary::Alma::BibNumber:0x0000000118815038 @check_str="9", @digit_str="11082434">
|
|
61
85
|
```
|
|
62
86
|
|
|
87
|
+
Item barcode:
|
|
88
|
+
|
|
89
|
+
```ruby
|
|
90
|
+
barcode_str = 'C084093187'
|
|
91
|
+
barcode = BerkeleyLibrary::Alma::BarCode.new(barcode_str)
|
|
92
|
+
# => #<BerkeleyLibrary::Alma::BarCode:0x000000013fac4c08 @barcode="C084093187">
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
⚠️ Note that because of the free-form nature of barcodes, they cannot be auto-detected,
|
|
96
|
+
and hence are **not** supported by the `RecordId#parse` method; they must be instantiated
|
|
97
|
+
directly.
|
|
98
|
+
|
|
99
|
+
#### Using `RecordId` objects to make SRU queries
|
|
100
|
+
|
|
63
101
|
Given a `RecordId` object, you can get the SRU query URI for the corresponding MARC record:
|
|
64
102
|
|
|
65
103
|
```ruby
|
|
@@ -7,7 +7,7 @@ module BerkeleyLibrary
|
|
|
7
7
|
SUMMARY = 'Alma/Primo utilities for the UC Berkeley Library'.freeze
|
|
8
8
|
DESCRIPTION = 'A gem providing Alma/Primo-related utility code for the UC Berkeley Library'.freeze
|
|
9
9
|
LICENSE = 'MIT'.freeze
|
|
10
|
-
VERSION = '0.0.
|
|
10
|
+
VERSION = '0.0.5'.freeze
|
|
11
11
|
HOMEPAGE = 'https://github.com/BerkeleyLibrary/alma'.freeze
|
|
12
12
|
end
|
|
13
13
|
end
|
|
@@ -2,6 +2,7 @@ require 'berkeley_library/logging'
|
|
|
2
2
|
require 'berkeley_library/marc'
|
|
3
3
|
require 'berkeley_library/util/uris'
|
|
4
4
|
require 'berkeley_library/alma/constants'
|
|
5
|
+
require 'berkeley_library/alma/sru'
|
|
5
6
|
|
|
6
7
|
module BerkeleyLibrary
|
|
7
8
|
module Alma
|
|
@@ -47,13 +48,7 @@ module BerkeleyLibrary
|
|
|
47
48
|
#
|
|
48
49
|
# @return [URI] the MARC URI
|
|
49
50
|
def marc_uri
|
|
50
|
-
|
|
51
|
-
'version' => '1.2',
|
|
52
|
-
'operation' => 'searchRetrieve',
|
|
53
|
-
'query' => sru_query_value
|
|
54
|
-
)
|
|
55
|
-
|
|
56
|
-
URIs.append(Config.alma_sru_base_uri, '?', query_string)
|
|
51
|
+
SRU.sru_query_uri(sru_query_value)
|
|
57
52
|
end
|
|
58
53
|
|
|
59
54
|
# Makes an SRU query for this record and returns a MARC record, or nil if the
|
|
@@ -65,8 +60,12 @@ module BerkeleyLibrary
|
|
|
65
60
|
# @return [MARC::Record, nil] the MARC record
|
|
66
61
|
# rubocop:disable Naming/AccessorMethodName
|
|
67
62
|
def get_marc_record
|
|
68
|
-
|
|
69
|
-
|
|
63
|
+
unless (marc_reader = SRU.marc_records_for(sru_query_value))
|
|
64
|
+
logger.warn("GET #{marc_uri} did not return a MARC record")
|
|
65
|
+
return nil
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
logger.warn("GET #{marc_uri} did not return a MARC record") unless (marc_record = marc_reader.first)
|
|
70
69
|
marc_record
|
|
71
70
|
end
|
|
72
71
|
# rubocop:enable Naming/AccessorMethodName
|
|
@@ -77,10 +76,7 @@ module BerkeleyLibrary
|
|
|
77
76
|
# @return [String, nil] the SRU query response body, or nil in the event of an error.
|
|
78
77
|
# rubocop:disable Naming/AccessorMethodName
|
|
79
78
|
def get_marc_xml
|
|
80
|
-
|
|
81
|
-
rescue RestClient::Exception => e
|
|
82
|
-
logger.warn("GET #{marc_uri} failed", e)
|
|
83
|
-
nil
|
|
79
|
+
SRU.make_sru_query(sru_query_value)
|
|
84
80
|
end
|
|
85
81
|
# rubocop:enable Naming/AccessorMethodName
|
|
86
82
|
|
|
@@ -98,19 +94,6 @@ module BerkeleyLibrary
|
|
|
98
94
|
|
|
99
95
|
to_s <=> other.to_s
|
|
100
96
|
end
|
|
101
|
-
|
|
102
|
-
# ------------------------------------------------------------
|
|
103
|
-
# Private methods
|
|
104
|
-
|
|
105
|
-
private
|
|
106
|
-
|
|
107
|
-
def parse_marc_xml(xml)
|
|
108
|
-
return unless xml
|
|
109
|
-
|
|
110
|
-
input = StringIO.new(xml.scrub)
|
|
111
|
-
reader = MARC::XMLReader.new(input)
|
|
112
|
-
reader.first
|
|
113
|
-
end
|
|
114
97
|
end
|
|
115
98
|
end
|
|
116
99
|
end
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
require 'uri'
|
|
2
|
+
require 'berkeley_library/alma/config'
|
|
3
|
+
require 'berkeley_library/alma/constants'
|
|
4
|
+
require 'berkeley_library/alma/record_id'
|
|
5
|
+
require 'berkeley_library/util/uris'
|
|
6
|
+
|
|
7
|
+
module BerkeleyLibrary
|
|
8
|
+
module Alma
|
|
9
|
+
module SRU
|
|
10
|
+
include BerkeleyLibrary::Logging
|
|
11
|
+
include Constants
|
|
12
|
+
|
|
13
|
+
class << self
|
|
14
|
+
include SRU
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
# Given a list of record IDs, returns the MARC records for each ID (if found).
|
|
18
|
+
#
|
|
19
|
+
# @param record_ids [Array<String, RecordId>] the record IDs to look up
|
|
20
|
+
# @return [MARC::XMLReader, nil] a reader for the MARC records, or nil if
|
|
21
|
+
# the records could not be read
|
|
22
|
+
def get_marc_records(*record_ids)
|
|
23
|
+
# noinspection RubyMismatchedReturnType
|
|
24
|
+
parsed_ids = record_ids.filter_map { |id| RecordId.parse(id) }
|
|
25
|
+
raise ArgumentError, "Argument #{record_ids.inspect} contain no valid record IDs" if parsed_ids.empty?
|
|
26
|
+
|
|
27
|
+
sru_query_value = parsed_ids.map(&:sru_query_value).join(' or ')
|
|
28
|
+
SRU.marc_records_for(sru_query_value)
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
# Returns a URI for retrieving records for the specified query
|
|
32
|
+
# via SRU. Requires {Config#alma_sru_base_uri} to be set.
|
|
33
|
+
#
|
|
34
|
+
# @return [URI] the MARC URI
|
|
35
|
+
def sru_query_uri(sru_query_value)
|
|
36
|
+
query_string = URI.encode_www_form(
|
|
37
|
+
'version' => '1.2',
|
|
38
|
+
'operation' => 'searchRetrieve',
|
|
39
|
+
'query' => sru_query_value
|
|
40
|
+
)
|
|
41
|
+
|
|
42
|
+
Util::URIs.append(Config.alma_sru_base_uri, '?', query_string)
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
# Makes an SRU query for the specified query value and returns the query response
|
|
46
|
+
# as a string.
|
|
47
|
+
#
|
|
48
|
+
# @param query_value [String] the value of the SRU query parameter
|
|
49
|
+
# @return [String, nil] the SRU query response body, or nil in the event of an error.
|
|
50
|
+
def make_sru_query(query_value)
|
|
51
|
+
uri = sru_query_uri(query_value)
|
|
52
|
+
do_get(uri)
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
# Makes an SRU query for the specified query value and returns the query response
|
|
56
|
+
# as MARC records.
|
|
57
|
+
#
|
|
58
|
+
# @param query_value [String] the value of the SRU query parameter
|
|
59
|
+
# @return [MARC::XMLReader, nil] a reader for the MARC records, or nil if
|
|
60
|
+
# the records could not be read
|
|
61
|
+
def marc_records_for(query_value)
|
|
62
|
+
return unless (xml = make_sru_query(query_value))
|
|
63
|
+
|
|
64
|
+
input = StringIO.new(xml.scrub)
|
|
65
|
+
MARC::XMLReader.new(input, parser: 'nokogiri')
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
private
|
|
69
|
+
|
|
70
|
+
def do_get(uri)
|
|
71
|
+
# TODO: can we get the XML as an IO rather than as a string?
|
|
72
|
+
Util::URIs.get(uri, headers: { user_agent: DEFAULT_USER_AGENT })
|
|
73
|
+
rescue RestClient::Exception => e
|
|
74
|
+
logger.warn("GET #{uri} failed", e)
|
|
75
|
+
nil
|
|
76
|
+
end
|
|
77
|
+
end
|
|
78
|
+
end
|
|
79
|
+
end
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8" standalone="no"?><searchRetrieveResponse xmlns="http://www.loc.gov/zing/srw/">
|
|
2
|
+
<version>1.2</version>
|
|
3
|
+
<numberOfRecords>2</numberOfRecords>
|
|
4
|
+
<records>
|
|
5
|
+
<record>
|
|
6
|
+
<recordSchema>marcxml</recordSchema>
|
|
7
|
+
<recordPacking>xml</recordPacking>
|
|
8
|
+
<recordData>
|
|
9
|
+
<record xmlns="http://www.loc.gov/MARC21/slim">
|
|
10
|
+
<leader>00307nam a2200085 a 4500</leader>
|
|
11
|
+
<controlfield tag="001">991005668359706532</controlfield>
|
|
12
|
+
<controlfield tag="008">^^</controlfield>
|
|
13
|
+
<datafield ind1=" " ind2=" " tag="035">
|
|
14
|
+
<subfield code="a">(CUY)UCB-b207766733-01ucs_ber</subfield>
|
|
15
|
+
</datafield>
|
|
16
|
+
<datafield ind1="1" ind2=" " tag="100">
|
|
17
|
+
<subfield code="a">Fukazawa, Yukio,</subfield>
|
|
18
|
+
<subfield code="d">1924-2017.</subfield>
|
|
19
|
+
</datafield>
|
|
20
|
+
<datafield ind1="1" ind2="0" tag="245">
|
|
21
|
+
<subfield code="a">Blue Doors</subfield>
|
|
22
|
+
<subfield code="h">[graphic]</subfield>
|
|
23
|
+
</datafield>
|
|
24
|
+
<datafield ind1=" " ind2=" " tag="300">
|
|
25
|
+
<subfield code="a">1 relief etching and aquatint :</subfield>
|
|
26
|
+
<subfield code="b">col.</subfield>
|
|
27
|
+
</datafield>
|
|
28
|
+
<datafield ind1=" " ind2=" " tag="996">
|
|
29
|
+
<subfield code="a">b207766733</subfield>
|
|
30
|
+
<subfield code="b">Updated: 01-09-19</subfield>
|
|
31
|
+
<subfield code="c">Created: 11-01-13</subfield>
|
|
32
|
+
<subfield code="d">CatDate: - -</subfield>
|
|
33
|
+
<subfield code="9">LOCAL</subfield>
|
|
34
|
+
</datafield>
|
|
35
|
+
<datafield ind1=" " ind2=" " tag="AVA">
|
|
36
|
+
<subfield code="0">991005668359706532</subfield>
|
|
37
|
+
<subfield code="8">22928381510006532</subfield>
|
|
38
|
+
<subfield code="a">01UCS_BER</subfield>
|
|
39
|
+
<subfield code="b">MORR</subfield>
|
|
40
|
+
<subfield code="c">Morrison</subfield>
|
|
41
|
+
<subfield code="e">unavailable</subfield>
|
|
42
|
+
<subfield code="f">1</subfield>
|
|
43
|
+
<subfield code="g">1</subfield>
|
|
44
|
+
<subfield code="i">UCB_Campus</subfield>
|
|
45
|
+
<subfield code="j">mo</subfield>
|
|
46
|
+
<subfield code="k">#</subfield>
|
|
47
|
+
<subfield code="p">1</subfield>
|
|
48
|
+
<subfield code="q">Morrison Library</subfield>
|
|
49
|
+
</datafield>
|
|
50
|
+
</record>
|
|
51
|
+
</recordData>
|
|
52
|
+
<recordIdentifier>991005668359706532</recordIdentifier>
|
|
53
|
+
<recordPosition>1</recordPosition>
|
|
54
|
+
</record>
|
|
55
|
+
<record>
|
|
56
|
+
<recordSchema>marcxml</recordSchema>
|
|
57
|
+
<recordPacking>xml</recordPacking>
|
|
58
|
+
<recordData>
|
|
59
|
+
<record xmlns="http://www.loc.gov/MARC21/slim">
|
|
60
|
+
<leader>00273nam a2200085 a 4500</leader>
|
|
61
|
+
<controlfield tag="001">991005668209706532</controlfield>
|
|
62
|
+
<controlfield tag="008">^^</controlfield>
|
|
63
|
+
<datafield ind1=" " ind2=" " tag="035">
|
|
64
|
+
<subfield code="a">(CUY)UCB-b207766708-01ucs_ber</subfield>
|
|
65
|
+
</datafield>
|
|
66
|
+
<datafield ind1="1" ind2=" " tag="100">
|
|
67
|
+
<subfield code="a">Beutlich, Tadek.</subfield>
|
|
68
|
+
</datafield>
|
|
69
|
+
<datafield ind1="1" ind2="0" tag="245">
|
|
70
|
+
<subfield code="a">River</subfield>
|
|
71
|
+
<subfield code="h">[graphic]</subfield>
|
|
72
|
+
</datafield>
|
|
73
|
+
<datafield ind1=" " ind2=" " tag="300">
|
|
74
|
+
<subfield code="a">1 lithograph :</subfield>
|
|
75
|
+
<subfield code="b">col.</subfield>
|
|
76
|
+
</datafield>
|
|
77
|
+
<datafield ind1=" " ind2=" " tag="996">
|
|
78
|
+
<subfield code="a">b207766708</subfield>
|
|
79
|
+
<subfield code="b">Updated: 11-01-13</subfield>
|
|
80
|
+
<subfield code="c">Created: 11-01-13</subfield>
|
|
81
|
+
<subfield code="d">CatDate: - -</subfield>
|
|
82
|
+
<subfield code="9">LOCAL</subfield>
|
|
83
|
+
</datafield>
|
|
84
|
+
<datafield ind1=" " ind2=" " tag="AVA">
|
|
85
|
+
<subfield code="0">991005668209706532</subfield>
|
|
86
|
+
<subfield code="8">22928389410006532</subfield>
|
|
87
|
+
<subfield code="a">01UCS_BER</subfield>
|
|
88
|
+
<subfield code="b">MORR</subfield>
|
|
89
|
+
<subfield code="c">Morrison</subfield>
|
|
90
|
+
<subfield code="e">available</subfield>
|
|
91
|
+
<subfield code="f">1</subfield>
|
|
92
|
+
<subfield code="g">0</subfield>
|
|
93
|
+
<subfield code="i">UCB_Campus</subfield>
|
|
94
|
+
<subfield code="j">mo</subfield>
|
|
95
|
+
<subfield code="k">#</subfield>
|
|
96
|
+
<subfield code="p">1</subfield>
|
|
97
|
+
<subfield code="q">Morrison Library</subfield>
|
|
98
|
+
</datafield>
|
|
99
|
+
</record>
|
|
100
|
+
</recordData>
|
|
101
|
+
<recordIdentifier>991005668209706532</recordIdentifier>
|
|
102
|
+
<recordPosition>2</recordPosition>
|
|
103
|
+
</record>
|
|
104
|
+
</records>
|
|
105
|
+
<extraResponseData xmlns:xb="http://www.exlibris.com/repository/search/xmlbeans/">
|
|
106
|
+
<xb:exact>true</xb:exact>
|
|
107
|
+
<xb:responseDate>2022-05-04T14:31:01-0700</xb:responseDate>
|
|
108
|
+
</extraResponseData>
|
|
109
|
+
</searchRetrieveResponse>
|
|
@@ -36,6 +36,26 @@ module BerkeleyLibrary
|
|
|
36
36
|
end
|
|
37
37
|
end
|
|
38
38
|
end
|
|
39
|
+
|
|
40
|
+
describe 'SRU methods' do
|
|
41
|
+
before { Config.default! }
|
|
42
|
+
after { Config.send(:clear!) }
|
|
43
|
+
|
|
44
|
+
describe :get_marc_xml do
|
|
45
|
+
let(:record_id) { RecordId.parse('991054360089706532') }
|
|
46
|
+
let(:expected_body) { File.read('spec/data/991054360089706532-sru.xml') }
|
|
47
|
+
|
|
48
|
+
before do
|
|
49
|
+
sru_query_uri = record_id.marc_uri
|
|
50
|
+
stub_request(:get, sru_query_uri).to_return(body: expected_body)
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
it 'returns the MARC XML' do
|
|
54
|
+
marc_xml = record_id.get_marc_xml
|
|
55
|
+
expect(marc_xml).to eq(expected_body)
|
|
56
|
+
end
|
|
57
|
+
end
|
|
58
|
+
end
|
|
39
59
|
end
|
|
40
60
|
end
|
|
41
61
|
end
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
module BerkeleyLibrary
|
|
4
|
+
module Alma
|
|
5
|
+
describe SRU do
|
|
6
|
+
before { Config.default! }
|
|
7
|
+
after { Config.send(:clear!) }
|
|
8
|
+
|
|
9
|
+
describe :get_marc_records do
|
|
10
|
+
let(:mms_ids) { %w[991005668209706532 991005668359706532] }
|
|
11
|
+
|
|
12
|
+
before do
|
|
13
|
+
sru_query_value = mms_ids.map { |id| RecordId.parse(id) }.map(&:sru_query_value).join(' or ')
|
|
14
|
+
sru_query_uri = SRU.sru_query_uri(sru_query_value)
|
|
15
|
+
stub_request(:get, sru_query_uri).to_return(body: File.read('spec/data/availability-sru.xml'))
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
it 'returns the MARC records' do
|
|
19
|
+
reader = SRU.get_marc_records(*mms_ids)
|
|
20
|
+
expect(reader).to be_a(MARC::XMLReader)
|
|
21
|
+
|
|
22
|
+
marc_records = reader.to_a
|
|
23
|
+
expect(marc_records.size).to eq(mms_ids.size)
|
|
24
|
+
expect(marc_records.map(&:record_id)).to contain_exactly(*mms_ids)
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
end
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: berkeley_library-alma
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.0.
|
|
4
|
+
version: 0.0.5
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- David Moles
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2022-
|
|
11
|
+
date: 2022-05-04 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: berkeley_library-logging
|
|
@@ -276,6 +276,7 @@ files:
|
|
|
276
276
|
- lib/berkeley_library/alma/mms_id.rb
|
|
277
277
|
- lib/berkeley_library/alma/module_info.rb
|
|
278
278
|
- lib/berkeley_library/alma/record_id.rb
|
|
279
|
+
- lib/berkeley_library/alma/sru.rb
|
|
279
280
|
- rakelib/bundle.rake
|
|
280
281
|
- rakelib/coverage.rake
|
|
281
282
|
- rakelib/gem.rake
|
|
@@ -284,6 +285,7 @@ files:
|
|
|
284
285
|
- spec/.rubocop.yml
|
|
285
286
|
- spec/data/991054360089706532-sru.xml
|
|
286
287
|
- spec/data/C084093187-sru.xml
|
|
288
|
+
- spec/data/availability-sru.xml
|
|
287
289
|
- spec/data/b110824349-sru.xml
|
|
288
290
|
- spec/data/bibs_with_check_digits.txt
|
|
289
291
|
- spec/lib/berkeley_library/alma/barcode_spec.rb
|
|
@@ -291,6 +293,7 @@ files:
|
|
|
291
293
|
- spec/lib/berkeley_library/alma/config_spec.rb
|
|
292
294
|
- spec/lib/berkeley_library/alma/mms_id_spec.rb
|
|
293
295
|
- spec/lib/berkeley_library/alma/record_id_spec.rb
|
|
296
|
+
- spec/lib/berkeley_library/alma/sru_spec.rb
|
|
294
297
|
- spec/spec_helper.rb
|
|
295
298
|
homepage: https://github.com/BerkeleyLibrary/alma
|
|
296
299
|
licenses:
|
|
@@ -319,6 +322,7 @@ test_files:
|
|
|
319
322
|
- spec/.rubocop.yml
|
|
320
323
|
- spec/data/991054360089706532-sru.xml
|
|
321
324
|
- spec/data/C084093187-sru.xml
|
|
325
|
+
- spec/data/availability-sru.xml
|
|
322
326
|
- spec/data/b110824349-sru.xml
|
|
323
327
|
- spec/data/bibs_with_check_digits.txt
|
|
324
328
|
- spec/lib/berkeley_library/alma/barcode_spec.rb
|
|
@@ -326,4 +330,5 @@ test_files:
|
|
|
326
330
|
- spec/lib/berkeley_library/alma/config_spec.rb
|
|
327
331
|
- spec/lib/berkeley_library/alma/mms_id_spec.rb
|
|
328
332
|
- spec/lib/berkeley_library/alma/record_id_spec.rb
|
|
333
|
+
- spec/lib/berkeley_library/alma/sru_spec.rb
|
|
329
334
|
- spec/spec_helper.rb
|