alma 0.2.8 → 0.3.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: e3079955feac35f5665cae0f49298159c6739f8e
4
- data.tar.gz: ada299082a4b7c0a15e8126b3417e4d8264d66f4
2
+ SHA256:
3
+ metadata.gz: ed295d076116c3da468f65bfb17ba476b171e60565adddec420a2328f9b88fa6
4
+ data.tar.gz: 146c04496209f27833a0d0881e5f21a2fe7d55c9aa2886e5c2833efd05a80fc1
5
5
  SHA512:
6
- metadata.gz: 267aa00bed5ba01ab29862986d549fc637ebe3ea26fefd7236728fe49c4a90c2f607608c8c44f52cbfcb8e4098403ee4d18f1094d51421ae289e81e41af46fb8
7
- data.tar.gz: 9babb4fda07c15927e659af938c3038f261082f70db8a7d102004dd323620f33565d3b5d5d19b9497987608d7acbd8651cefcac3ed6786da47952b02c7a531ce
6
+ metadata.gz: bd111915aa21143de049c78f1ccd51f91db677b228c304ffddbd8820349e10525aec2a7fd7b423ab6cab8154b8322ab899a7472c84b09c0518ea28cc1d6ad0c9
7
+ data.tar.gz: fdc24540723c168bfd8779a53dc233e353b564ab1a6f6eeaa7b053675a18aecfc28f1a324a905281dc0e8d9efe998d0167d3012164889ab9c9169d3fd5952d31
@@ -1 +1 @@
1
- ruby-2.4.1
1
+ ruby-2.6.5
@@ -1,5 +1,13 @@
1
1
  sudo: false
2
2
  language: ruby
3
3
  rvm:
4
- - 2.4.1
5
- before_install: gem install bundler -v 1.13.7
4
+ - 2.6.5
5
+ before_install: gem install bundler
6
+ deploy:
7
+ provider: rubygems
8
+ api_key:
9
+ secure: CX0/qWERXa4W5agrNZGQVsqIguRCKvaenqZvmW+fMJZdvMaK1ZzRN+IYUhCiBSBJ8mh3Dz1/L5D77HVsjz3ylDa+B9d/FFzq9ZsKTGbjbLXnconAH/tzVAtygN/5zyIPPgDLp83gVYBnJQr1AdXMhC0cpllixB2KiqbNahl750klYiOzjQDbJ6puuzT4plGOlQ56X0zVrNCBllIqTvFdcDslnes8I/BnU3HTqulIK9Ey9dUkYSqdn18UUn0R+kHs7VKkGQeIy2G7Gk9GV93y1sQi6Kdotz3B2wM4mPO+qovTLIZzr4mElpqm7RKHsXF8zmVzgQJi5JaeT/Y5GGjI3erc4CYqWcWX4/N3aogKYra+oVX9eQTg1H58cH0bjL655IY5mQ38eW4C3YuHBIdXcr9wsL7Mu6Pl4VetOs2N7dDSW7ZU868o7evBBebKQEI9Y0rDH5oGEqWYWxEiIb7anJ/kQYTADKWmpNdsTS8NpGdhtNU7qQq188Ektar7NIRrZTwIN9lSKQRCY9jYSkUv84xlaRFMvT2x4/cx00nLmVYJF+xN43JaEGOIgeZ2cyOxqVRDoDTu6UEU5KMXLSicACEijg4qWnJvbK06hfOc74ZB5zQ55Dk2xwP+aHexw3XxZbnhweu46ZvG6RdIAPNmrH1lQtE42qKEKBvfL6cTYZs=
10
+ gem: alma
11
+ on:
12
+ tags: true
13
+ repo: tulibraries/alma_rb
@@ -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,75 +26,81 @@ 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 te apikey
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 Api servers. You can override that here.
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
 
36
42
  Now you can access those configuration attributes with `Alma.configuration.apikey`
37
43
 
38
44
  ### Making Requests
39
-
45
+
40
46
  #### Get a Single user
41
47
  ```ruby
42
48
  user = Alma::User.find(123456789)
43
-
49
+
44
50
  user.first_name
45
51
  > Chad
46
-
52
+
47
53
  user.email
48
54
  > chad.nelson@fictional.edu
49
-
55
+
50
56
  user.keys
51
57
  >{first_name: "Chad",
52
58
  ...}
53
59
  ```
54
-
60
+
55
61
  #### Get details on a users fines
56
-
62
+
57
63
  ```ruby
58
64
  fines = user.fines
59
65
  fines.sum
60
66
  > "20.0"
61
-
67
+
62
68
  fines.total_record_count
63
69
  > "2"
64
-
70
+
65
71
  fines
66
72
  > [#<Alma::AlmaRecord:0x000000038b7b50
67
73
  ...>,
68
74
  #<Alma::AlmaRecord:0x000000038b7b28
69
75
  ...>]
70
-
76
+
71
77
  fines.first.title
72
78
  > "Practical Object Oriented Design with Ruby"
73
-
79
+
74
80
  ```
75
81
 
76
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)
77
83
 
78
84
  #### Get details on a users loans
79
-
85
+
80
86
  ```ruby
81
87
  loans = user.loans
82
88
 
83
89
  loans.total_record_count
84
90
  > "2"
85
-
91
+
86
92
  loans
87
93
  > [#<Alma::Loan:0x000000038c6b79
88
94
  ...>,
89
95
  #<Alma::Loan:0x000000038c6b34
90
96
  ...>]
91
-
97
+
92
98
  loans.first.title
93
99
  > "Javascript: The Good Parts"
94
-
100
+
95
101
  loans.first.due_date
96
- "2016-12-26z
97
-
102
+ "2016-12-26z"
103
+
98
104
  ```
99
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)
100
106
 
@@ -105,10 +111,10 @@ requests = user.requests
105
111
 
106
112
  requests.total_record_count
107
113
  > "1"
108
-
114
+
109
115
  requests.list
110
116
  > [#<Alma::AlmaRecord:0x000000038c6b79...>]
111
-
117
+
112
118
  requests.list.first.title
113
119
  > "Food in history / Reay Tannahill."
114
120
 
@@ -117,26 +123,131 @@ requests.list.first.pickup_location
117
123
 
118
124
  requests.list.first.request_status
119
125
  > "In Process"
120
-
126
+
121
127
  ```
122
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)
123
129
 
124
130
  Loans, fines and Requests can also be accessed statically
125
-
131
+
126
132
  ```ruby
127
133
  Alma::User.get_fines({:user_id => 123456789})
128
-
134
+
129
135
  Alma::User.get_loans({:user_id => 123456789})
130
136
 
131
137
  Alma::User.get_requests({:user_id => 123456789})
132
-
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
133
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
+
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
+
134
243
  ## Development
135
244
 
136
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.
137
246
 
138
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).
139
248
 
249
+ Use `bundle exec guard` to continuously run specs while developing.
250
+
140
251
  ## Contributing
141
252
 
142
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.
@@ -145,4 +256,3 @@ Bug reports and pull requests are welcome on GitHub at https://github.com/tulibr
145
256
  ## License
146
257
 
147
258
  The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
148
-
@@ -23,14 +23,19 @@ Gem::Specification.new do |spec|
23
23
 
24
24
  spec.add_dependency 'ezwadl'
25
25
  spec.add_dependency 'httparty'
26
- spec.add_dependency 'xml-simple'
26
+ spec.add_dependency 'xml-simple'
27
+ spec.add_dependency 'activesupport'
27
28
 
28
-
29
29
 
30
30
 
31
- spec.add_development_dependency "bundler", "~> 1.13"
32
- spec.add_development_dependency "rake", "~> 10.0"
31
+
32
+ spec.add_development_dependency "bundler", "~> 2.0"
33
+ spec.add_development_dependency "rake", "~> 13.0"
33
34
  spec.add_development_dependency "rspec", "~> 3.0"
34
35
  spec.add_development_dependency 'webmock'
35
36
  spec.add_development_dependency 'pry'
37
+ spec.add_development_dependency 'byebug'
38
+ spec.add_development_dependency "guard"
39
+ spec.add_development_dependency "guard-rspec"
40
+
36
41
  end
@@ -1,8 +1,9 @@
1
1
  require 'alma/version'
2
2
  require 'alma/config'
3
- require 'alma/api'
3
+ require 'alma/api_defaults'
4
4
  require 'alma/error'
5
5
  require 'alma/alma_record'
6
+ require 'alma/response'
6
7
  require 'alma/user'
7
8
  require 'alma/bib'
8
9
  require 'alma/loan'
@@ -10,6 +11,7 @@ require 'alma/result_set'
10
11
  require 'alma/loan_set'
11
12
  require 'alma/user_set'
12
13
  require 'alma/fine_set'
14
+ require 'alma/fine'
13
15
  require 'alma/user_set'
14
16
  require 'alma/bib_set'
15
17
  require 'alma/request_set'
@@ -17,11 +19,13 @@ require 'alma/renewal_response'
17
19
  require 'alma/availability_response'
18
20
  require 'alma/bib_item'
19
21
  require 'alma/request_options'
22
+ require 'alma/item_request_options'
23
+ require 'alma/request'
24
+ require 'alma/user_request'
25
+ require 'alma/electronic'
20
26
 
21
27
  module Alma
28
+ require 'httparty'
22
29
 
23
30
  ROOT = File.dirname __dir__
24
- WADL_DIR = File.join(Alma::ROOT, 'lib','alma','wadl')
25
-
26
-
27
31
  end
@@ -0,0 +1,30 @@
1
+ module Alma
2
+ module ApiDefaults
3
+
4
+ def apikey
5
+ Alma.configuration.apikey
6
+ end
7
+
8
+ def region
9
+ Alma.configuration.region
10
+ end
11
+
12
+ def headers
13
+ { "Authorization": "apikey #{self.apikey}",
14
+ "Accept": "application/json",
15
+ "Content-Type": "application/json" }
16
+ end
17
+
18
+ def bibs_base_path
19
+ "#{self.region}/almaws/v1/bibs"
20
+ end
21
+
22
+ def users_base_path
23
+ "#{self.region}/almaws/v1/users"
24
+ end
25
+
26
+ def timeout
27
+ Alma.configuration.timeout
28
+ end
29
+ end
30
+ end