libis-services 0.1.2 → 0.1.3
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/lib/libis/services/alma/sru_service.rb +39 -0
- data/lib/libis/services/alma/web_service.rb +0 -6
- data/lib/libis/services/version.rb +1 -1
- data/spec/alma_service_spec.rb +116 -90
- data/spec/rosetta_collection_spec.rb +15 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 16c6005df56e91ea7b9806570aefb5a024bc01a4
|
4
|
+
data.tar.gz: 4ab1b7d063c4f2aaf10143aca268051c176e56da
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d1d1080408037cc6725bcd78a3001269f733f8d8b06e7b8b32ad926c68425662f0050460da1233575787eb512eca4798ac371cf697fad1e60fcbe8c926a7b87e
|
7
|
+
data.tar.gz: d41b1ef29ba1a94f66ab93c135d3383be513c6fde2180ab85998e096dc6174bfc5fef93014ce8c96be71b5c568f8670c398a2c251954c7dfd377f1f8c16ba041
|
@@ -0,0 +1,39 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
require 'libis-tools'
|
3
|
+
require 'libis/services/service_error'
|
4
|
+
require 'libis/services/rest_client'
|
5
|
+
|
6
|
+
module Libis
|
7
|
+
module Services
|
8
|
+
module Alma
|
9
|
+
|
10
|
+
class SruService
|
11
|
+
include ::Libis::Services::RestClient
|
12
|
+
|
13
|
+
def initialize(url = 'https://eu.alma.exlibrisgroup.com/view/sru')
|
14
|
+
configure(url)
|
15
|
+
end
|
16
|
+
|
17
|
+
def search(field, value, library = '32KUL_LIBIS_NETWORK')
|
18
|
+
result = get library, version: '1.2', operation: 'searchRetrieve', recordSchema: 'marcxml',
|
19
|
+
query: "#{field}=#{value}"
|
20
|
+
|
21
|
+
unless result['//diag:diagnostic'].blank?
|
22
|
+
raise Libis::Services::ServiceError, "#{result['/searchRetrieveResponse/diag:diagnostic/diag:message']}"
|
23
|
+
end
|
24
|
+
|
25
|
+
result.xpath('//record').map do |record|
|
26
|
+
Libis::Tools::XmlDocument.parse(record.to_s)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
protected
|
31
|
+
|
32
|
+
def result_parser(response)
|
33
|
+
Libis::Tools::XmlDocument.parse(response)
|
34
|
+
end
|
35
|
+
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
@@ -15,12 +15,6 @@ module Libis
|
|
15
15
|
end
|
16
16
|
|
17
17
|
def get_marc(alma_id, apikey = nil)
|
18
|
-
apikey ||= case alma_id
|
19
|
-
when /1480$/
|
20
|
-
'l7xx8879c82a7d7b453a887a6e6dca8300fd'
|
21
|
-
else
|
22
|
-
raise Libis::Services::ServiceError, "No Alma API key available for '#{alma_id}'"
|
23
|
-
end
|
24
18
|
get alma_id, apikey: apikey
|
25
19
|
end
|
26
20
|
|
data/spec/alma_service_spec.rb
CHANGED
@@ -2,103 +2,129 @@ require_relative 'spec_helper'
|
|
2
2
|
require 'awesome_print'
|
3
3
|
|
4
4
|
require 'libis/services/alma/web_service'
|
5
|
+
require 'libis/services/alma/sru_service'
|
5
6
|
|
6
|
-
describe 'Alma
|
7
|
-
let(:subject) { Libis::Services::Alma::WebService.new }
|
7
|
+
describe 'Alma' do
|
8
8
|
|
9
|
-
|
9
|
+
let(:record) {
|
10
|
+
{
|
11
|
+
leader: '01206nas 2200337u 4500',
|
12
|
+
controlfield: ['9930800070101471', '20151015113543.0', '881205c19679999be r|p|| 0|||a|dut c'],
|
13
|
+
datafield: [
|
14
|
+
{
|
15
|
+
subfield: '(BeLVLBS)003080007LBS01-Aleph',
|
16
|
+
:@tag => '035', :@ind1 => ' ', :@ind2 => ' '
|
17
|
+
}, {
|
18
|
+
subfield: 'Kerk en leven. Bisdom Antwerpen (0991).',
|
19
|
+
:@tag => '245', :@ind1 => '0', :@ind2 => '0'
|
20
|
+
}, {
|
21
|
+
subfield: 'K & L',
|
22
|
+
:@tag => '246', :@ind1 => '3', :@ind2 => '3'
|
23
|
+
}, {
|
24
|
+
subfield: ['Antwerpen', 'Kerk en leven,', '1967-.'],
|
25
|
+
:@tag => '260', :@ind1 => ' ', :@ind2 => ' '
|
26
|
+
}, {
|
27
|
+
subfield: 'Weekly',
|
28
|
+
:@tag => '310', :@ind1 => ' ', :@ind2 => ' '
|
29
|
+
}, {
|
30
|
+
subfield: %w(text rdacontent),
|
31
|
+
:@tag => '336', :@ind1 => ' ', :@ind2 => ' '
|
32
|
+
}, {
|
33
|
+
subfield: %w(computer rdamedia),
|
34
|
+
:@tag => '337', :@ind1 => ' ', :@ind2 => ' '
|
35
|
+
}, {
|
36
|
+
subfield: ['online resource', 'rdacarrier'],
|
37
|
+
:@tag => '338', :@ind1 => ' ', :@ind2 => ' '
|
38
|
+
}, {
|
39
|
+
subfield: 'Online',
|
40
|
+
:@tag => '340', :@ind1 => ' ', :@ind2 => ' '
|
41
|
+
}, {
|
42
|
+
subfield: 'Digitale kopie van de gedrukte uitgave',
|
43
|
+
:@tag => '500', :@ind1 => ' ', :@ind2 => ' '
|
44
|
+
}, {
|
45
|
+
subfield: 'E-journals',
|
46
|
+
:@tag => '653', :@ind1 => ' ', :@ind2 => '6'
|
47
|
+
}, {
|
48
|
+
subfield: 'Collectie Kerk en Leven',
|
49
|
+
:@tag => '699', :@ind1 => ' ', :@ind2 => ' '
|
50
|
+
}, {
|
51
|
+
subfield: ['KADOC', 'C1', 'Kerken en religie', '(ODIS-HT)'],
|
52
|
+
:@tag => '650', :@ind1 => ' ', :@ind2 => '7'
|
53
|
+
}, {
|
54
|
+
subfield: ['KADOC', 'Antwerpen [deelgemeente in gemeente Antwerpen - BE]', '(ODIS-GEO)10560000006504'],
|
55
|
+
:@tag => '650', :@ind1 => ' ', :@ind2 => '7'
|
56
|
+
}, {
|
57
|
+
subfield: ['KADOC', 'Bisdom Antwerpen (1961-heden)', '(ODIS-ORG)9284'],
|
58
|
+
:@tag => '650', :@ind1 => ' ', :@ind2 => '7'
|
59
|
+
}, {
|
60
|
+
subfield: ['KADOC', 'Studiecentrum voor Zielzorg en Predicatie', '(ODIS-ORG)24894'],
|
61
|
+
:@tag => '650', :@ind1 => ' ', :@ind2 => '7'
|
62
|
+
}, {
|
63
|
+
subfield: 'KYE000486',
|
64
|
+
:@tag => '983', :@ind1 => ' ', :@ind2 => ' '
|
65
|
+
}, {
|
66
|
+
subfield: ['EKAD', '(2007)39-42, 44, 46-49, 51-52'],
|
67
|
+
:@tag => '993', :@ind1 => ' ', :@ind2 => ' '
|
68
|
+
}, {
|
69
|
+
subfield: ['EKAD', '(2008)1-28, 32-53'],
|
70
|
+
:@tag => '993', :@ind1 => ' ', :@ind2 => ' '
|
71
|
+
}, {
|
72
|
+
subfield: ['EKAD', '(2009)1-34, 36-38'],
|
73
|
+
:@tag => '993', :@ind1 => ' ', :@ind2 => ' '
|
74
|
+
}, {
|
75
|
+
subfield: ['EKAD', '(2011)1-13, 15-36, 45-52'],
|
76
|
+
:@tag => '993', :@ind1 => ' ', :@ind2 => ' '
|
77
|
+
}, {
|
78
|
+
subfield: ['EKAD', 'KADOC elektronische tijdschriften'],
|
79
|
+
:@tag => '995', :@ind1 => ' ', :@ind2 => ' '
|
80
|
+
}, {
|
81
|
+
subfield: ['EKAD', 'KADOC lopende periodiek'],
|
82
|
+
:@tag => '995', :@ind1 => ' ', :@ind2 => ' '
|
83
|
+
}
|
84
|
+
],
|
85
|
+
}
|
86
|
+
}
|
87
|
+
|
88
|
+
context 'API service' do
|
89
|
+
let(:subject) { Libis::Services::Alma::WebService.new }
|
90
|
+
|
91
|
+
context 'marc' do
|
10
92
|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
:@tag => '035', :@ind1 => ' ', :@ind2 => ' '
|
22
|
-
}, {
|
23
|
-
subfield: 'Kerk en leven. Bisdom Antwerpen (0991).',
|
24
|
-
:@tag => '245', :@ind1 => '0', :@ind2 => '0'
|
25
|
-
}, {
|
26
|
-
subfield: 'K & L',
|
27
|
-
:@tag => '246', :@ind1 => '3', :@ind2 => '3'
|
28
|
-
}, {
|
29
|
-
subfield: ['Antwerpen', 'Kerk en leven,', '1967-.'],
|
30
|
-
:@tag => '260', :@ind1 => ' ', :@ind2 => ' '
|
31
|
-
}, {
|
32
|
-
subfield: 'Weekly',
|
33
|
-
:@tag => '310', :@ind1 => ' ', :@ind2 => ' '
|
34
|
-
}, {
|
35
|
-
subfield: %w(text rdacontent),
|
36
|
-
:@tag => '336', :@ind1 => ' ', :@ind2 => ' '
|
37
|
-
}, {
|
38
|
-
subfield: %w(computer rdamedia),
|
39
|
-
:@tag => '337', :@ind1 => ' ', :@ind2 => ' '
|
40
|
-
}, {
|
41
|
-
subfield: ['online resource', 'rdacarrier'],
|
42
|
-
:@tag => '338', :@ind1 => ' ', :@ind2 => ' '
|
43
|
-
}, {
|
44
|
-
subfield: 'Online',
|
45
|
-
:@tag => '340', :@ind1 => ' ', :@ind2 => ' '
|
46
|
-
}, {
|
47
|
-
subfield: 'Digitale kopie van de gedrukte uitgave',
|
48
|
-
:@tag => '500', :@ind1 => ' ', :@ind2 => ' '
|
49
|
-
}, {
|
50
|
-
subfield: 'E-journals',
|
51
|
-
:@tag => '653', :@ind1 => ' ', :@ind2 => '6'
|
52
|
-
}, {
|
53
|
-
subfield: 'Collectie Kerk en Leven',
|
54
|
-
:@tag => '699', :@ind1 => ' ', :@ind2 => ' '
|
55
|
-
}, {
|
56
|
-
subfield: ['KADOC', 'C1', 'Kerken en religie', '(ODIS-HT)'],
|
57
|
-
:@tag => '650', :@ind1 => ' ', :@ind2 => '7'
|
58
|
-
}, {
|
59
|
-
subfield: ['KADOC', 'Antwerpen [deelgemeente in gemeente Antwerpen - BE]', '(ODIS-GEO)10560000006504'],
|
60
|
-
:@tag => '650', :@ind1 => ' ', :@ind2 => '7'
|
61
|
-
}, {
|
62
|
-
subfield: ['KADOC', 'Bisdom Antwerpen (1961-heden)', '(ODIS-ORG)9284'],
|
63
|
-
:@tag => '650', :@ind1 => ' ', :@ind2 => '7'
|
64
|
-
}, {
|
65
|
-
subfield: ['KADOC', 'Studiecentrum voor Zielzorg en Predicatie', '(ODIS-ORG)24894'],
|
66
|
-
:@tag => '650', :@ind1 => ' ', :@ind2 => '7'
|
67
|
-
}, {
|
68
|
-
subfield: 'KYE000486',
|
69
|
-
:@tag => '983', :@ind1 => ' ', :@ind2 => ' '
|
70
|
-
}, {
|
71
|
-
subfield: ['EKAD', '(2007)39-42, 44, 46-49, 51-52'],
|
72
|
-
:@tag => '993', :@ind1 => ' ', :@ind2 => ' '
|
73
|
-
}, {
|
74
|
-
subfield: ['EKAD', '(2008)1-28, 32-53'],
|
75
|
-
:@tag => '993', :@ind1 => ' ', :@ind2 => ' '
|
76
|
-
}, {
|
77
|
-
subfield: ['EKAD', '(2009)1-34, 36-38'],
|
78
|
-
:@tag => '993', :@ind1 => ' ', :@ind2 => ' '
|
79
|
-
}, {
|
80
|
-
subfield: ['EKAD', '(2011)1-13, 15-36, 45-52'],
|
81
|
-
:@tag => '993', :@ind1 => ' ', :@ind2 => ' '
|
82
|
-
}, {
|
83
|
-
subfield: ['EKAD', 'KADOC elektronische tijdschriften'],
|
84
|
-
:@tag => '995', :@ind1 => ' ', :@ind2 => ' '
|
85
|
-
}, {
|
86
|
-
subfield: ['EKAD', 'KADOC lopende periodiek'],
|
87
|
-
:@tag => '995', :@ind1 => ' ', :@ind2 => ' '
|
88
|
-
}, {
|
89
|
-
subfield: ['KADOC', 'online', '201510', 'W', 'Collectie Kerk en Leven', 'local'],
|
90
|
-
:@tag => '996', :@ind1 => ' ', :@ind2 => ' '
|
91
|
-
}
|
92
|
-
],
|
93
|
+
before {
|
94
|
+
record[:controlfield][0] = '9930800070101480'
|
95
|
+
record[:datafield].insert(1, {
|
96
|
+
subfield: '(EXLNZ-32KUL_LIBIS_NETWORK)9930800070101471',
|
97
|
+
:@tag => '035', :@ind1 => ' ', :@ind2 => ' '
|
98
|
+
})
|
99
|
+
record[:datafield] << {
|
100
|
+
subfield: ['KADOC', 'online', '201510', 'W', 'Collectie Kerk en Leven', 'local'],
|
101
|
+
:@tag => '996', :@ind1 => ' ', :@ind2 => ' '
|
102
|
+
}
|
93
103
|
}
|
94
|
-
}
|
95
104
|
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
105
|
+
it 'get record' do
|
106
|
+
result = subject.get_marc('9930800070101480', 'l7xx8879c82a7d7b453a887a6e6dca8300fd').
|
107
|
+
to_hash(:convert_tags_to => lambda { |tag| tag.snakecase.to_sym })
|
108
|
+
check_container(record, result[:bib][:record])
|
109
|
+
end
|
110
|
+
|
100
111
|
end
|
101
112
|
|
102
113
|
end
|
103
114
|
|
115
|
+
context 'SRU service' do
|
116
|
+
let(:subject) { Libis::Services::Alma::SruService.new }
|
117
|
+
|
118
|
+
context 'marc' do
|
119
|
+
|
120
|
+
|
121
|
+
it 'search' do
|
122
|
+
result = subject.search('alma.local_field_983', 'KYE000486')
|
123
|
+
expect(result.size).to be 1
|
124
|
+
result = result.first.to_hash(:convert_tags_to => lambda { |tag| tag.snakecase.to_sym })
|
125
|
+
check_container(record, result[:record])
|
126
|
+
end
|
127
|
+
end
|
128
|
+
end
|
129
|
+
|
104
130
|
end
|
@@ -140,13 +140,27 @@ describe 'Rosetta Collection Service' do
|
|
140
140
|
}
|
141
141
|
|
142
142
|
let(:updated_name) { 'Stupid text' }
|
143
|
+
let(:updated_metadata) {
|
144
|
+
<<-STR.unindent.strip
|
145
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
146
|
+
<dc:record xmlns:dc="http://purl.org/dc/elements/1.1/"
|
147
|
+
xmlns:dcterms="http://purl.org/dc/terms/"
|
148
|
+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
149
|
+
<dc:title>Updated DC title</dc:title>
|
150
|
+
<dc:author>Autotest</dc:author>
|
151
|
+
<dcterms:created>2015-06-25 10:00</dcterms:created>
|
152
|
+
</dc:record>
|
153
|
+
STR
|
154
|
+
}
|
143
155
|
|
144
156
|
let(:updated_collection) { collection_service.find(parent_name + '/' + updated_name) }
|
145
157
|
|
146
158
|
let(:updated_collection_data) {
|
147
159
|
updated_collection_data = new_collection_data.dup
|
148
160
|
updated_collection_data[:name] = updated_name
|
149
|
-
updated_collection_data
|
161
|
+
# updated_collection_data[:md_dc].delete :mid
|
162
|
+
updated_collection_data[:md_dc][:content] = updated_metadata
|
163
|
+
updated_collection_data.cleanup
|
150
164
|
}
|
151
165
|
|
152
166
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: libis-services
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kris Dekeyser
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-02-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -221,6 +221,7 @@ files:
|
|
221
221
|
- lib/libis-services.rb
|
222
222
|
- lib/libis/services.rb
|
223
223
|
- lib/libis/services/aleph/search.rb
|
224
|
+
- lib/libis/services/alma/sru_service.rb
|
224
225
|
- lib/libis/services/alma/web_service.rb
|
225
226
|
- lib/libis/services/collective_access.rb
|
226
227
|
- lib/libis/services/collective_access/cataloguing.rb
|