alma 0.2.4 → 0.3.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- 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 +5 -1
- data/Guardfile +75 -0
- data/README.md +146 -57
- data/Rakefile +3 -1
- data/alma.gemspec +21 -12
- data/lib/alma.rb +34 -54
- data/lib/alma/alma_record.rb +3 -3
- data/lib/alma/api_defaults.rb +39 -0
- data/lib/alma/availability_response.rb +69 -31
- data/lib/alma/bib.rb +54 -29
- data/lib/alma/bib_holding.rb +25 -0
- data/lib/alma/bib_item.rb +164 -0
- data/lib/alma/bib_item_set.rb +93 -0
- data/lib/alma/bib_set.rb +5 -10
- data/lib/alma/config.rb +10 -4
- data/lib/alma/course.rb +47 -0
- data/lib/alma/course_set.rb +17 -0
- data/lib/alma/electronic.rb +167 -0
- data/lib/alma/electronic/README.md +20 -0
- data/lib/alma/electronic/batch_utils.rb +224 -0
- data/lib/alma/electronic/business.rb +29 -0
- data/lib/alma/error.rb +16 -4
- data/lib/alma/fine.rb +16 -0
- data/lib/alma/fine_set.rb +41 -8
- data/lib/alma/item_request_options.rb +23 -0
- data/lib/alma/library.rb +29 -0
- data/lib/alma/library_set.rb +21 -0
- data/lib/alma/loan.rb +31 -2
- data/lib/alma/loan_set.rb +62 -4
- data/lib/alma/location.rb +29 -0
- data/lib/alma/location_set.rb +21 -0
- data/lib/alma/renewal_response.rb +25 -14
- data/lib/alma/request.rb +167 -0
- data/lib/alma/request_options.rb +66 -0
- data/lib/alma/request_set.rb +69 -5
- data/lib/alma/response.rb +45 -0
- data/lib/alma/result_set.rb +27 -35
- data/lib/alma/user.rb +142 -86
- data/lib/alma/user_request.rb +19 -0
- data/lib/alma/user_set.rb +5 -6
- data/lib/alma/version.rb +3 -1
- data/log/.gitignore +4 -0
- metadata +149 -10
- data/.travis.yml +0 -5
- data/lib/alma/api.rb +0 -33
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
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/Guardfile
ADDED
@@ -0,0 +1,75 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# A sample Guardfile
|
4
|
+
# More info at https://github.com/guard/guard#readme
|
5
|
+
|
6
|
+
## Uncomment and set this to only include directories you want to watch
|
7
|
+
# directories %w(app lib config test spec features) \
|
8
|
+
# .select{|d| Dir.exists?(d) ? d : UI.warning("Directory #{d} does not exist")}
|
9
|
+
|
10
|
+
## Note: if you are using the `directories` clause above and you are not
|
11
|
+
## watching the project directory ('.'), then you will want to move
|
12
|
+
## the Guardfile to a watched dir and symlink it back, e.g.
|
13
|
+
#
|
14
|
+
# $ mkdir config
|
15
|
+
# $ mv Guardfile config/
|
16
|
+
# $ ln -s config/Guardfile .
|
17
|
+
#
|
18
|
+
# and, you'll have to watch "config/Guardfile" instead of "Guardfile"
|
19
|
+
|
20
|
+
# Note: The cmd option is now required due to the increasing number of ways
|
21
|
+
# rspec may be run, below are examples of the most common uses.
|
22
|
+
# * bundler: 'bundle exec rspec'
|
23
|
+
# * bundler binstubs: 'bin/rspec'
|
24
|
+
# * spring: 'bin/rspec' (This will use spring if running and you have
|
25
|
+
# installed the spring binstubs per the docs)
|
26
|
+
# * zeus: 'zeus rspec' (requires the server to be started separately)
|
27
|
+
# * 'just' rspec: 'rspec'
|
28
|
+
|
29
|
+
guard :rspec, cmd: "bundle exec rspec" do
|
30
|
+
require "guard/rspec/dsl"
|
31
|
+
dsl = Guard::RSpec::Dsl.new(self)
|
32
|
+
|
33
|
+
# Feel free to open issues for suggestions and improvements
|
34
|
+
|
35
|
+
# RSpec files
|
36
|
+
rspec = dsl.rspec
|
37
|
+
watch(rspec.spec_helper) { rspec.spec_dir }
|
38
|
+
watch(rspec.spec_support) { rspec.spec_dir }
|
39
|
+
watch(rspec.spec_files)
|
40
|
+
|
41
|
+
# Ruby files
|
42
|
+
ruby = dsl.ruby
|
43
|
+
dsl.watch_spec_files_for(ruby.lib_files)
|
44
|
+
|
45
|
+
# Rails files
|
46
|
+
rails = dsl.rails(view_extensions: %w(erb haml slim))
|
47
|
+
dsl.watch_spec_files_for(rails.app_files)
|
48
|
+
dsl.watch_spec_files_for(rails.views)
|
49
|
+
|
50
|
+
watch(rails.controllers) do |m|
|
51
|
+
[
|
52
|
+
rspec.spec.call("routing/#{m[1]}_routing"),
|
53
|
+
rspec.spec.call("controllers/#{m[1]}_controller"),
|
54
|
+
rspec.spec.call("acceptance/#{m[1]}")
|
55
|
+
]
|
56
|
+
end
|
57
|
+
|
58
|
+
# Rails config changes
|
59
|
+
watch(rails.spec_helper) { rspec.spec_dir }
|
60
|
+
watch(rails.routes) { "#{rspec.spec_dir}/routing" }
|
61
|
+
watch(rails.app_controller) { "#{rspec.spec_dir}/controllers" }
|
62
|
+
|
63
|
+
# Capybara features specs
|
64
|
+
watch(rails.view_dirs) { |m| rspec.spec.call("features/#{m[1]}") }
|
65
|
+
watch(rails.layouts) { |m| rspec.spec.call("features/#{m[1]}") }
|
66
|
+
|
67
|
+
# Turnip features and steps
|
68
|
+
watch(%r{^spec/acceptance/(.+)\.feature$})
|
69
|
+
watch(%r{^spec/acceptance/steps/(.+)_steps\.rb$}) do |m|
|
70
|
+
Dir[File.join("**/#{m[1]}.feature")][0] || "spec/acceptance"
|
71
|
+
end
|
72
|
+
|
73
|
+
# Specific files when defaults don't work (for some reason):
|
74
|
+
watch("lib/alma.rb") { "spec/alma_spec.rb" }
|
75
|
+
end
|
data/README.md
CHANGED
@@ -26,10 +26,16 @@ You'll need to configure the Alma gem to ensure you query the appropriate data.
|
|
26
26
|
|
27
27
|
```ruby
|
28
28
|
Alma.configure do |config|
|
29
|
-
# You have to set
|
29
|
+
# You have to set the apikey
|
30
30
|
config.apikey = 'EXAMPLE_EL_DEV_NETWORK_APPLICATION_KEY'
|
31
|
-
# Alma gem defaults to querying Ex Libris's North American
|
32
|
-
config.region = "https://api-eu.hosted.exlibrisgroup.com
|
31
|
+
# Alma gem defaults to querying Ex Libris's North American API servers. You can override that here.
|
32
|
+
config.region = "https://api-eu.hosted.exlibrisgroup.com"
|
33
|
+
|
34
|
+
# By default enable_loggable is set to false
|
35
|
+
config.enable_loggable = false
|
36
|
+
|
37
|
+
# By default timeout is set to 5 seconds; can only provide integers
|
38
|
+
config.timeout = 10
|
33
39
|
end
|
34
40
|
```
|
35
41
|
|
@@ -37,99 +43,78 @@ Now you can access those configuration attributes with `Alma.configuration.apike
|
|
37
43
|
|
38
44
|
### Making Requests
|
39
45
|
|
40
|
-
#### Get a list of Users
|
41
|
-
```ruby
|
42
|
-
users = Alma::User.find
|
43
|
-
|
44
|
-
users.total count
|
45
|
-
> 402
|
46
|
-
|
47
|
-
users.list.first.id
|
48
|
-
> 123456789
|
49
|
-
```
|
50
|
-
|
51
46
|
#### Get a Single user
|
52
47
|
```ruby
|
53
|
-
user = Alma::User.find(
|
54
|
-
|
48
|
+
user = Alma::User.find(123456789)
|
49
|
+
|
55
50
|
user.first_name
|
56
51
|
> Chad
|
57
|
-
|
52
|
+
|
58
53
|
user.email
|
59
54
|
> chad.nelson@fictional.edu
|
55
|
+
|
56
|
+
user.keys
|
57
|
+
>{first_name: "Chad",
|
58
|
+
...}
|
60
59
|
```
|
61
|
-
|
60
|
+
|
62
61
|
#### Get details on a users fines
|
63
|
-
|
62
|
+
|
64
63
|
```ruby
|
65
64
|
fines = user.fines
|
66
65
|
fines.sum
|
67
66
|
> "20.0"
|
68
|
-
|
67
|
+
|
69
68
|
fines.total_record_count
|
70
69
|
> "2"
|
71
|
-
|
72
|
-
fines
|
70
|
+
|
71
|
+
fines
|
73
72
|
> [#<Alma::AlmaRecord:0x000000038b7b50
|
74
73
|
...>,
|
75
74
|
#<Alma::AlmaRecord:0x000000038b7b28
|
76
75
|
...>]
|
77
|
-
|
78
|
-
fines.
|
76
|
+
|
77
|
+
fines.first.title
|
79
78
|
> "Practical Object Oriented Design with Ruby"
|
80
|
-
|
79
|
+
|
81
80
|
```
|
82
81
|
|
83
|
-
Each fine object reflects the available fields in the returned
|
82
|
+
Each fine object reflects the available fields in the returned JSON,[as documented on the Ex Libris Api docs](https://developers.exlibrisgroup.com/alma/apis/xsd/rest_fees.xsd?tags=GET)
|
84
83
|
|
85
84
|
#### Get details on a users loans
|
86
|
-
|
85
|
+
|
87
86
|
```ruby
|
88
87
|
loans = user.loans
|
89
88
|
|
90
89
|
loans.total_record_count
|
91
90
|
> "2"
|
92
|
-
|
93
|
-
loans
|
91
|
+
|
92
|
+
loans
|
94
93
|
> [#<Alma::Loan:0x000000038c6b79
|
95
94
|
...>,
|
96
95
|
#<Alma::Loan:0x000000038c6b34
|
97
96
|
...>]
|
98
|
-
|
99
|
-
loans.list.first.title
|
100
|
-
> "Javascript: The Good Parts"
|
101
|
-
|
102
|
-
loans.list.first.due_date
|
103
|
-
"2016-12-26z
|
104
|
-
|
105
|
-
```
|
106
|
-
Each loan object reflects the available fields in the returned XML,[as documented on the Ex Libris Api docs](https://developers.exlibrisgroup.com/alma/apis/xsd/rest_item_loans.xsd?tags=GET)
|
107
97
|
|
108
|
-
|
109
|
-
|
110
|
-
```ruby
|
111
|
-
renewal = loans.list.first.renew
|
112
|
-
|
113
|
-
renewal.renewed?
|
114
|
-
> True
|
98
|
+
loans.first.title
|
99
|
+
> "Javascript: The Good Parts"
|
115
100
|
|
116
|
-
|
117
|
-
|
101
|
+
loans.first.due_date
|
102
|
+
"2016-12-26z"
|
118
103
|
|
119
104
|
```
|
105
|
+
Each loan object reflects the available fields in the returned XML,[as documented on the Ex Libris Api docs](https://developers.exlibrisgroup.com/alma/apis/xsd/rest_item_loans.xsd?tags=GET)
|
120
106
|
|
121
107
|
|
122
|
-
|
123
|
-
#### Get details on a users requests
|
108
|
+
#### Get details on a users requests - WIP
|
124
109
|
```ruby
|
125
110
|
requests = user.requests
|
126
111
|
|
127
112
|
requests.total_record_count
|
128
113
|
> "1"
|
129
|
-
|
114
|
+
|
130
115
|
requests.list
|
131
116
|
> [#<Alma::AlmaRecord:0x000000038c6b79...>]
|
132
|
-
|
117
|
+
|
133
118
|
requests.list.first.title
|
134
119
|
> "Food in history / Reay Tannahill."
|
135
120
|
|
@@ -138,32 +123,136 @@ requests.list.first.pickup_location
|
|
138
123
|
|
139
124
|
requests.list.first.request_status
|
140
125
|
> "In Process"
|
141
|
-
|
126
|
+
|
142
127
|
```
|
143
128
|
Each request object reflects the available fields in the returned XML,[as documented on the Ex Libris Api docs](https://developers.exlibrisgroup.com/alma/apis/xsd/rest_user_requests.xsd?tags=GET)
|
144
129
|
|
145
130
|
Loans, fines and Requests can also be accessed statically
|
146
|
-
|
131
|
+
|
147
132
|
```ruby
|
148
133
|
Alma::User.get_fines({:user_id => 123456789})
|
149
|
-
|
134
|
+
|
150
135
|
Alma::User.get_loans({:user_id => 123456789})
|
151
136
|
|
152
137
|
Alma::User.get_requests({:user_id => 123456789})
|
153
|
-
|
138
|
+
|
139
|
+
```
|
140
|
+
|
141
|
+
### Bib Records
|
142
|
+
Wrappings for some of the API endpoints described by the [Bibliographic Records and Inventory
|
143
|
+
](https://developers.exlibrisgroup.com/alma/apis/bibs) section of the Ex Libris Developers Network
|
144
|
+
|
145
|
+
### All the items for a Bib Records
|
146
|
+
Corresponds to the [Retrieve Items list](https://developers.exlibrisgroup.com/alma/apis/bibs/GET/gwPcGly021om4RTvtjbPleCklCGxeYAfEqJOcQOaLEvNcHQT0/ozqu3DGTurs/XxIP4LrexQUdc=/af2fb69d-64f4-42bc-bb05-d8a0ae56936e) api endpoint
|
147
|
+
|
148
|
+
To get the list of items for all holdings of a bib record.
|
149
|
+
`items = Alma::BibItem.find("EXAMPLE_MMS_ID")`
|
150
|
+
|
151
|
+
You can also pass a holding ID as an option, if you only want that holdings items.
|
152
|
+
`items = Alma::BibItem.find("EXAMPLE_MMS_ID", holding_id: EXAMPLE_HOLDING_ID)`
|
153
|
+
|
154
|
+
|
155
|
+
The response is a BibItemSet which can be iterated over to access items:
|
156
|
+
|
157
|
+
```ruby
|
158
|
+
items.each { ... }
|
159
|
+
|
160
|
+
items.total_record_count
|
161
|
+
> 4
|
162
|
+
```
|
163
|
+
|
164
|
+
You can remove items that are missing or lost from the result set
|
165
|
+
` avail_items = items.filter_missing_and_lost
|
166
|
+
`
|
167
|
+
|
168
|
+
Items can be grouped by the library they are held at, which returns a hash with library codes as the keys and an array of items as the values.
|
169
|
+
|
170
|
+
```ruby
|
171
|
+
items.grouped_by_library
|
172
|
+
{ "MAIN" =>
|
173
|
+
[#<Alma::BibItem:0x000000038c6b79...>],
|
174
|
+
"NOT_MAIN" =>
|
175
|
+
[#<Alma::BibItem:0x000000038c6b88...>, #<Alma::BibItem:0x000000038c6b94...>,],
|
176
|
+
}
|
177
|
+
```
|
178
|
+
|
179
|
+
The data for each item can be accessed via hash representation of the [item structure](https://developers.exlibrisgroup.com/alma/apis/xsd/rest_item.xsd), e.g.:
|
180
|
+
|
181
|
+
```ruby
|
182
|
+
item = items.first
|
183
|
+
|
184
|
+
item["holding_data"]["call_number"]
|
185
|
+
"T385 .F79 2008"
|
186
|
+
|
187
|
+
item["item_data"]["location"]["value"]
|
188
|
+
"STACKS"
|
189
|
+
|
190
|
+
```
|
191
|
+
|
192
|
+
There are also numerous convenience methods
|
193
|
+
|
194
|
+
```ruby
|
195
|
+
# Boolean checks
|
196
|
+
item.in_temp_location?
|
197
|
+
item.in_place? # Basically, On Shelf or Not
|
198
|
+
item.non_circulating?
|
199
|
+
item.missing_or_lost?
|
200
|
+
item.has_temp_call_number?
|
201
|
+
item.has_alt_call_number?
|
202
|
+
item.has_process_type?
|
203
|
+
|
204
|
+
|
205
|
+
# Opinionated Accessors - return the value, or an empty string
|
206
|
+
|
207
|
+
# Returns temp library/location if appropriate, else normal library/location
|
208
|
+
item.library
|
209
|
+
item.library_name
|
210
|
+
item.location
|
211
|
+
item.location_name
|
212
|
+
|
213
|
+
# which use these methods under the hood
|
214
|
+
item.holding_library
|
215
|
+
item.holding_location
|
216
|
+
|
217
|
+
item.temp_library
|
218
|
+
item.temp_location
|
219
|
+
|
220
|
+
|
221
|
+
# Looks for Temp call number, then alternate call number, then normal call number
|
222
|
+
item.call_number
|
223
|
+
|
224
|
+
# and which use
|
225
|
+
item.temp_call_number
|
226
|
+
item.alt_call_number
|
227
|
+
|
228
|
+
|
229
|
+
# standard accessors
|
230
|
+
item.process_type
|
231
|
+
item.base_status
|
232
|
+
item.circulation_policy
|
233
|
+
item.description
|
234
|
+
item.public_note
|
235
|
+
|
154
236
|
```
|
237
|
+
|
238
|
+
### Logging
|
239
|
+
This gem exposes a loggable interface to responses. Thus a response will respond to `loggable` and return a hash with state values that may be of use to log.
|
240
|
+
|
241
|
+
As a bonus, when we enable this feature using the `enable_loggable` configuration, error messages will contain the loggable values and be formatted as JSON.
|
242
|
+
|
155
243
|
## Development
|
156
244
|
|
157
245
|
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
158
246
|
|
159
247
|
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
160
248
|
|
249
|
+
Use `bundle exec guard` to continuously run specs while developing.
|
250
|
+
|
161
251
|
## Contributing
|
162
252
|
|
163
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/
|
253
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/tulibraries/alma_rb. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
164
254
|
|
165
255
|
|
166
256
|
## License
|
167
257
|
|
168
258
|
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
169
|
-
|