alma 0.3.1 → 0.3.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.circleci/config.yml +54 -0
- data/.circleci/setup-rubygems.sh +3 -0
- data/.github/dependabot.yml +7 -0
- data/.gitignore +3 -0
- data/.rubocop.yml +134 -0
- data/.ruby-version +1 -1
- data/Gemfile +4 -3
- data/Rakefile +3 -1
- data/alma.gemspec +17 -17
- data/lib/alma.rb +34 -26
- data/lib/alma/alma_record.rb +3 -3
- data/lib/alma/api_defaults.rb +10 -1
- data/lib/alma/availability_response.rb +49 -52
- data/lib/alma/bib.rb +23 -21
- data/lib/alma/bib_holding.rb +25 -0
- data/lib/alma/bib_item.rb +22 -9
- data/lib/alma/bib_item_set.rb +19 -8
- data/lib/alma/config.rb +3 -1
- data/lib/alma/course.rb +47 -0
- data/lib/alma/course_set.rb +17 -0
- data/lib/alma/electronic.rb +1 -1
- data/lib/alma/electronic/batch_utils.rb +11 -11
- data/lib/alma/error.rb +4 -3
- data/lib/alma/fine.rb +3 -2
- data/lib/alma/fine_set.rb +1 -1
- data/lib/alma/item_request_options.rb +4 -3
- data/lib/alma/library.rb +29 -0
- data/lib/alma/library_set.rb +21 -0
- data/lib/alma/loan.rb +4 -2
- data/lib/alma/loan_set.rb +3 -3
- data/lib/alma/location.rb +29 -0
- data/lib/alma/location_set.rb +21 -0
- data/lib/alma/renewal_response.rb +8 -8
- data/lib/alma/request.rb +16 -14
- data/lib/alma/request_options.rb +9 -7
- data/lib/alma/request_set.rb +1 -1
- data/lib/alma/user.rb +61 -59
- data/lib/alma/user_request.rb +3 -1
- data/lib/alma/version.rb +3 -1
- metadata +46 -5
- data/.travis.yml +0 -13
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f162f9bb1a3b0eee2af44a379b1d094141b6cc9c06767d17acb39d909eb27ed1
|
4
|
+
data.tar.gz: 98eb300d6c0ab62ae07790fa64449c65839f89bd3903b3c0e010e911bf4d3ce0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bff5a50e3f546962f71c3ce2fbfe2ed553b63fc4698df62b1ce2828e53c86c62c018716a476005759ed8b94102d371911e9b3ef69f6b03752b96fe85bcbf7f97
|
7
|
+
data.tar.gz: 8159b943d247e6bd34f3efcd09325191806ca26471252d39d3f54be4182a5b45bc875b2eb7c5bc432b492b70e932cbac8c12054ba0b64883ac14e974933c215f
|
@@ -0,0 +1,54 @@
|
|
1
|
+
version: 2.1
|
2
|
+
orbs:
|
3
|
+
ruby: circleci/ruby@0.1.2
|
4
|
+
|
5
|
+
workflows:
|
6
|
+
version: 2
|
7
|
+
test-deploy:
|
8
|
+
jobs:
|
9
|
+
- build
|
10
|
+
- deploy:
|
11
|
+
filters:
|
12
|
+
tags:
|
13
|
+
only: /.*/
|
14
|
+
branches:
|
15
|
+
ignore: /.*/
|
16
|
+
|
17
|
+
jobs:
|
18
|
+
build:
|
19
|
+
docker:
|
20
|
+
- image: cimg/ruby:2.7.2-node
|
21
|
+
auth:
|
22
|
+
username: $DOCKERHUB_USER
|
23
|
+
password: $DOCKERHUB_PASSWORD
|
24
|
+
|
25
|
+
executor: ruby/default
|
26
|
+
steps:
|
27
|
+
- checkout
|
28
|
+
- run:
|
29
|
+
name: Which bundler?
|
30
|
+
command: bundle -v
|
31
|
+
- ruby/bundle-install
|
32
|
+
- run:
|
33
|
+
name: lint
|
34
|
+
command: bundle exec rubocop
|
35
|
+
- run:
|
36
|
+
name: test
|
37
|
+
command: bundle exec rake
|
38
|
+
deploy:
|
39
|
+
docker:
|
40
|
+
- image: circleci/ruby:2.7.2-node-browsers
|
41
|
+
|
42
|
+
working_directory: ~/repo
|
43
|
+
|
44
|
+
steps:
|
45
|
+
- checkout
|
46
|
+
- run:
|
47
|
+
name: Setup Rubygems
|
48
|
+
command: bash .circleci/setup-rubygems.sh
|
49
|
+
|
50
|
+
- run:
|
51
|
+
name: Publish to Rubygems
|
52
|
+
command: |
|
53
|
+
gem build alma.gemspec
|
54
|
+
gem push "$(ls alma-*.gem)"
|
data/.gitignore
CHANGED
data/.rubocop.yml
ADDED
@@ -0,0 +1,134 @@
|
|
1
|
+
require:
|
2
|
+
- rubocop-rails
|
3
|
+
|
4
|
+
AllCops:
|
5
|
+
TargetRubyVersion: 2.7
|
6
|
+
# RuboCop has a bunch of cops enabled by default. This setting tells RuboCop
|
7
|
+
# to ignore them, so only the ones explicitly set in this file are enabled.
|
8
|
+
DisabledByDefault: true
|
9
|
+
Exclude:
|
10
|
+
- 'node_modules/**/*'
|
11
|
+
- '**/templates/**/*'
|
12
|
+
- '**/vendor/**/*'
|
13
|
+
- 'actionpack/lib/action_dispatch/journey/parser.rb'
|
14
|
+
- 'bin/*'
|
15
|
+
- 'solr/**/*'
|
16
|
+
|
17
|
+
# Prefer &&/|| over and/or.
|
18
|
+
Style/AndOr:
|
19
|
+
Enabled: true
|
20
|
+
|
21
|
+
# Align `when` with `case`.
|
22
|
+
Layout/CaseIndentation:
|
23
|
+
Enabled: true
|
24
|
+
|
25
|
+
# Align comments with method definitions.
|
26
|
+
Layout/CommentIndentation:
|
27
|
+
Enabled: true
|
28
|
+
|
29
|
+
Layout/EmptyLineAfterMagicComment:
|
30
|
+
Enabled: true
|
31
|
+
|
32
|
+
# In a regular class definition, no empty lines around the body.
|
33
|
+
Layout/EmptyLinesAroundClassBody:
|
34
|
+
Enabled: true
|
35
|
+
|
36
|
+
# In a regular method definition, no empty lines around the body.
|
37
|
+
Layout/EmptyLinesAroundMethodBody:
|
38
|
+
Enabled: true
|
39
|
+
|
40
|
+
# In a regular module definition, no empty lines around the body.
|
41
|
+
Layout/EmptyLinesAroundModuleBody:
|
42
|
+
Enabled: true
|
43
|
+
|
44
|
+
Layout/FirstArgumentIndentation:
|
45
|
+
Enabled: true
|
46
|
+
|
47
|
+
# Use Ruby >= 1.9 syntax for hashes. Prefer { a: :b } over { :a => :b }.
|
48
|
+
Style/HashSyntax:
|
49
|
+
Enabled: true
|
50
|
+
|
51
|
+
# Method definitions after `private` or `protected` isolated calls need one
|
52
|
+
# extra level of indentation.
|
53
|
+
Layout/IndentationConsistency:
|
54
|
+
Enabled: true
|
55
|
+
EnforcedStyle: indented_internal_methods
|
56
|
+
|
57
|
+
# Two spaces, no tabs (for indentation).
|
58
|
+
Layout/IndentationWidth:
|
59
|
+
Enabled: true
|
60
|
+
|
61
|
+
Layout/SpaceAfterColon:
|
62
|
+
Enabled: true
|
63
|
+
|
64
|
+
Layout/SpaceAfterComma:
|
65
|
+
Enabled: true
|
66
|
+
|
67
|
+
Layout/SpaceAroundEqualsInParameterDefault:
|
68
|
+
Enabled: true
|
69
|
+
|
70
|
+
Layout/SpaceAroundKeyword:
|
71
|
+
Enabled: true
|
72
|
+
|
73
|
+
Layout/SpaceAroundOperators:
|
74
|
+
Enabled: true
|
75
|
+
|
76
|
+
Layout/SpaceBeforeFirstArg:
|
77
|
+
Enabled: true
|
78
|
+
|
79
|
+
# Defining a method with parameters needs parentheses.
|
80
|
+
Style/MethodDefParentheses:
|
81
|
+
Enabled: true
|
82
|
+
|
83
|
+
Style/FrozenStringLiteralComment:
|
84
|
+
Enabled: true
|
85
|
+
EnforcedStyle: always
|
86
|
+
Exclude:
|
87
|
+
- 'app/models/traject_indexer.rb'
|
88
|
+
- 'db/schema.rb'
|
89
|
+
|
90
|
+
# Use `foo {}` not `foo{}`.
|
91
|
+
Layout/SpaceBeforeBlockBraces:
|
92
|
+
Enabled: true
|
93
|
+
|
94
|
+
# Use `foo { bar }` not `foo {bar}`.
|
95
|
+
Layout/SpaceInsideBlockBraces:
|
96
|
+
Enabled: true
|
97
|
+
|
98
|
+
# Use `{ a: 1 }` not `{a:1}`.
|
99
|
+
Layout/SpaceInsideHashLiteralBraces:
|
100
|
+
Enabled: true
|
101
|
+
|
102
|
+
Layout/SpaceInsideParens:
|
103
|
+
Enabled: true
|
104
|
+
|
105
|
+
# Check quotes usage according to lint rule below.
|
106
|
+
Style/StringLiterals:
|
107
|
+
Enabled: true
|
108
|
+
EnforcedStyle: double_quotes
|
109
|
+
|
110
|
+
# Detect hard tabs, no hard tabs.
|
111
|
+
Layout/IndentationStyle:
|
112
|
+
Enabled: true
|
113
|
+
|
114
|
+
# Blank lines should not have any spaces.
|
115
|
+
Layout/TrailingEmptyLines:
|
116
|
+
Enabled: true
|
117
|
+
|
118
|
+
# No trailing whitespace.
|
119
|
+
Layout/TrailingWhitespace:
|
120
|
+
Enabled: true
|
121
|
+
|
122
|
+
# Use quotes for string literals when they are enough.
|
123
|
+
Style/RedundantPercentQ:
|
124
|
+
Enabled: true
|
125
|
+
|
126
|
+
# Align `end` with the matching keyword or starting expression except for
|
127
|
+
# assignments, where it should be aligned with the LHS.
|
128
|
+
Layout/EndAlignment:
|
129
|
+
Enabled: true
|
130
|
+
EnforcedStyleAlignWith: variable
|
131
|
+
|
132
|
+
# Use my_method(my_arg) not my_method( my_arg ) or my_method my_arg.
|
133
|
+
Lint/RequireParentheses:
|
134
|
+
Enabled: true
|
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
ruby-2.
|
1
|
+
ruby-2.7.2
|
data/Gemfile
CHANGED
data/Rakefile
CHANGED
data/alma.gemspec
CHANGED
@@ -1,16 +1,18 @@
|
|
1
1
|
# coding: utf-8
|
2
|
-
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
lib = File.expand_path("../lib", __FILE__)
|
3
5
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
-
require
|
6
|
+
require "alma/version"
|
5
7
|
|
6
8
|
Gem::Specification.new do |spec|
|
7
9
|
spec.name = "alma"
|
8
10
|
spec.version = Alma::VERSION
|
9
|
-
spec.authors = ["Chad Nelson"]
|
10
|
-
spec.email = ["chad.nelson@temple.edu"]
|
11
|
+
spec.authors = ["Jennifer Anton", "David Kinzer", "Chad Nelson"]
|
12
|
+
spec.email = ["jennifer.anton@temple.edu", "david.kinzer@temple.edu", "chad.nelson@temple.edu"]
|
11
13
|
|
12
|
-
spec.summary =
|
13
|
-
spec.description =
|
14
|
+
spec.summary = "Client for Ex Libris Alma Web Services"
|
15
|
+
spec.description = "Client for Ex Libris Alma Web Services"
|
14
16
|
spec.homepage = "https://github.com/tulibraries/alma_rb"
|
15
17
|
spec.license = "MIT"
|
16
18
|
|
@@ -21,21 +23,19 @@ Gem::Specification.new do |spec|
|
|
21
23
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
22
24
|
spec.require_paths = ["lib"]
|
23
25
|
|
24
|
-
spec.add_dependency
|
25
|
-
spec.add_dependency
|
26
|
-
spec.add_dependency
|
27
|
-
spec.add_dependency
|
28
|
-
|
29
|
-
|
30
|
-
|
26
|
+
spec.add_dependency "ezwadl"
|
27
|
+
spec.add_dependency "httparty"
|
28
|
+
spec.add_dependency "xml-simple"
|
29
|
+
spec.add_dependency "activesupport"
|
31
30
|
|
32
31
|
spec.add_development_dependency "bundler", "~> 2.0"
|
33
32
|
spec.add_development_dependency "rake", "~> 13.0"
|
34
33
|
spec.add_development_dependency "rspec", "~> 3.0"
|
35
|
-
spec.add_development_dependency
|
36
|
-
spec.add_development_dependency
|
37
|
-
spec.add_development_dependency
|
34
|
+
spec.add_development_dependency "webmock"
|
35
|
+
spec.add_development_dependency "pry"
|
36
|
+
spec.add_development_dependency "rubocop"
|
37
|
+
spec.add_development_dependency "rubocop-rails"
|
38
|
+
spec.add_development_dependency "byebug"
|
38
39
|
spec.add_development_dependency "guard"
|
39
40
|
spec.add_development_dependency "guard-rspec"
|
40
|
-
|
41
41
|
end
|
data/lib/alma.rb
CHANGED
@@ -1,31 +1,39 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
require
|
4
|
-
require
|
5
|
-
require
|
6
|
-
require
|
7
|
-
require
|
8
|
-
require
|
9
|
-
require
|
10
|
-
require
|
11
|
-
require
|
12
|
-
require
|
13
|
-
require
|
14
|
-
require
|
15
|
-
require
|
16
|
-
require
|
17
|
-
require
|
18
|
-
require
|
19
|
-
require
|
20
|
-
require
|
21
|
-
require
|
22
|
-
require
|
23
|
-
require
|
24
|
-
require
|
25
|
-
require
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "alma/version"
|
4
|
+
require "alma/config"
|
5
|
+
require "alma/api_defaults"
|
6
|
+
require "alma/error"
|
7
|
+
require "alma/alma_record"
|
8
|
+
require "alma/response"
|
9
|
+
require "alma/user"
|
10
|
+
require "alma/bib"
|
11
|
+
require "alma/loan"
|
12
|
+
require "alma/result_set"
|
13
|
+
require "alma/loan_set"
|
14
|
+
require "alma/user_set"
|
15
|
+
require "alma/fine_set"
|
16
|
+
require "alma/fine"
|
17
|
+
require "alma/bib_set"
|
18
|
+
require "alma/request_set"
|
19
|
+
require "alma/renewal_response"
|
20
|
+
require "alma/availability_response"
|
21
|
+
require "alma/bib_item"
|
22
|
+
require "alma/request_options"
|
23
|
+
require "alma/item_request_options"
|
24
|
+
require "alma/request"
|
25
|
+
require "alma/user_request"
|
26
|
+
require "alma/electronic"
|
27
|
+
require "alma/bib_holding"
|
28
|
+
require "alma/library"
|
29
|
+
require "alma/library_set"
|
30
|
+
require "alma/location"
|
31
|
+
require "alma/location_set"
|
32
|
+
require "alma/course_set"
|
33
|
+
require "alma/course"
|
26
34
|
|
27
35
|
module Alma
|
28
|
-
require
|
36
|
+
require "httparty"
|
29
37
|
|
30
38
|
ROOT = File.dirname __dir__
|
31
39
|
end
|
data/lib/alma/alma_record.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Alma
|
2
4
|
class AlmaRecord
|
3
|
-
|
4
5
|
def initialize(record)
|
5
6
|
@raw_record = record
|
6
7
|
post_initialize()
|
@@ -23,6 +24,5 @@ module Alma
|
|
23
24
|
# Subclasses can define this method to perform extra initialization
|
24
25
|
# after the super class init.
|
25
26
|
end
|
26
|
-
|
27
27
|
end
|
28
|
-
end
|
28
|
+
end
|
data/lib/alma/api_defaults.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Alma
|
2
4
|
module ApiDefaults
|
3
|
-
|
4
5
|
def apikey
|
5
6
|
Alma.configuration.apikey
|
6
7
|
end
|
@@ -23,6 +24,14 @@ module Alma
|
|
23
24
|
"#{self.region}/almaws/v1/users"
|
24
25
|
end
|
25
26
|
|
27
|
+
def items_base_path
|
28
|
+
"#{self.region}/almaws/v1/items"
|
29
|
+
end
|
30
|
+
|
31
|
+
def configuration_base_path
|
32
|
+
"#{self.region}/almaws/v1/conf"
|
33
|
+
end
|
34
|
+
|
26
35
|
def timeout
|
27
36
|
Alma.configuration.timeout
|
28
37
|
end
|
@@ -1,91 +1,88 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "xmlsimple"
|
2
4
|
|
3
5
|
module Alma
|
4
6
|
class AvailabilityResponse
|
5
|
-
|
6
|
-
|
7
7
|
attr_accessor :availability
|
8
8
|
|
9
9
|
def initialize(response)
|
10
10
|
@availability = parse_bibs_data(response.each)
|
11
11
|
end
|
12
12
|
|
13
|
-
# Data structure for holdings information of bib records.
|
13
|
+
# Data structure for holdings information of bib records.
|
14
14
|
# A hash with mms ids as keys, with values of an array of
|
15
15
|
# one or more hashes of holdings info
|
16
16
|
def parse_bibs_data(bibs)
|
17
17
|
bibs.reduce(Hash.new) { |acc, bib|
|
18
|
-
acc.merge({"#{bib.id}" => {holdings: build_holdings_for(bib)}})
|
18
|
+
acc.merge({ "#{bib.id}" => { holdings: build_holdings_for(bib) } })
|
19
19
|
}
|
20
20
|
end
|
21
21
|
|
22
22
|
def build_holdings_for(bib)
|
23
23
|
get_inventory_fields_for(bib).map do |inventory_field|
|
24
24
|
# Use the mapping for this inventory type
|
25
|
-
subfield_codes = Alma::INVENTORY_SUBFIELD_MAPPING[inventory_field[
|
26
|
-
|
25
|
+
subfield_codes = Alma::INVENTORY_SUBFIELD_MAPPING[inventory_field["tag"]]
|
26
|
+
|
27
27
|
inventory_field.
|
28
28
|
# Get all the subfields for this inventory field
|
29
|
-
fetch(
|
29
|
+
fetch("subfield", []).
|
30
30
|
# Limit to only subfields codes for which we have a mapping
|
31
|
-
select {|sf| subfield_codes.key? sf[
|
32
|
-
# Transform the array of subfields into a hash with mapped code as key
|
33
|
-
reduce(Hash.new) { |acc, subfield|
|
34
|
-
|
31
|
+
select { |sf| subfield_codes.key? sf["code"] }.
|
32
|
+
# Transform the array of subfields into a hash with mapped code as key
|
33
|
+
reduce(Hash.new) { |acc, subfield|
|
34
|
+
acc.merge({ "#{subfield_codes[subfield['code']]}" => subfield["content"] })
|
35
35
|
}.
|
36
36
|
# Include the inventory type
|
37
|
-
merge({
|
37
|
+
merge({ "inventory_type" => subfield_codes["INVENTORY_TYPE"] })
|
38
38
|
end
|
39
39
|
end
|
40
40
|
|
41
41
|
def get_inventory_fields_for(bib)
|
42
|
-
# Return only the datafields with tags AVA, AVD, or AVE
|
42
|
+
# Return only the datafields with tags AVA, AVD, or AVE
|
43
43
|
bib.record
|
44
|
-
.fetch(
|
45
|
-
.select { |df| Alma::INVENTORY_SUBFIELD_MAPPING.key?(df[
|
44
|
+
.fetch("datafield", [])
|
45
|
+
.select { |df| Alma::INVENTORY_SUBFIELD_MAPPING.key?(df["tag"]) }
|
46
46
|
end
|
47
47
|
end
|
48
48
|
|
49
49
|
INVENTORY_SUBFIELD_MAPPING =
|
50
50
|
{
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
51
|
+
"AVA" => {
|
52
|
+
"INVENTORY_TYPE" => "physical",
|
53
|
+
"a" => "institution",
|
54
|
+
"b" => "library_code",
|
55
|
+
"c" => "location",
|
56
|
+
"d" => "call_number",
|
57
|
+
"e" => "availability",
|
58
|
+
"f" => "total_items",
|
59
|
+
"g" => "non_available_items",
|
60
|
+
"j" => "location_code",
|
61
|
+
"k" => "call_number_type",
|
62
|
+
"p" => "priority",
|
63
|
+
"q" => "library",
|
64
|
+
"t" => "holding_info",
|
65
|
+
"8" => "holding_id",
|
66
66
|
},
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
67
|
+
"AVD" => {
|
68
|
+
"INVENTORY_TYPE" => "digital",
|
69
|
+
"a" => "institution",
|
70
|
+
"b" => "representations_id",
|
71
|
+
"c" => "representation",
|
72
|
+
"d" => "repository_name",
|
73
|
+
"e" => "label",
|
74
74
|
},
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
75
|
+
"AVE" => {
|
76
|
+
"INVENTORY_TYPE" => "electronic",
|
77
|
+
"c" => "collection_id",
|
78
|
+
"e" => "activation_status",
|
79
|
+
"l" => "library_code",
|
80
|
+
"m" => "collection",
|
81
|
+
"n" => "public_note",
|
82
|
+
"s" => "coverage_statement",
|
83
|
+
"t" => "interface_name",
|
84
|
+
"u" => "link_to_service_page",
|
85
|
+
"8" => "portfolio_pid",
|
86
86
|
}
|
87
87
|
}
|
88
|
-
|
89
|
-
|
90
|
-
|
91
88
|
end
|