evergreen_holdings 0.1.7 → 0.1.8

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/evergreen_holdings.rb +12 -9
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b06100edeee2a0a2ee6bc91b90295a015ef1a73a
4
- data.tar.gz: 3fe988a6af5545933d9e16989e4bdf3a35f8ec42
3
+ metadata.gz: 5bc48757194a624a320a66952894f1fb06feb2d3
4
+ data.tar.gz: bc39854e6d931c380a7996b8c998268917254bf7
5
5
  SHA512:
6
- metadata.gz: e14954516997254f54fe4c9c833ffca93003ea02691da279c88290a98cb0c4589faf7ac4c6aa3b377f90ef7106fe678b8e522c37e616bfdc5f54f54e71e47426
7
- data.tar.gz: c3d372ae1d76b776dc792a0a7d9b0da2553d2fa24235346bae3106c0ba3af7e789492d330dc073e9717f0f4b5cf0e98a1448d64889b80d1a861d9ec08e69646b
6
+ metadata.gz: cf9824129e3a2aaaa7c4f58a3e2534f014b9d33ddb9bf0f7ad8950324849b22522f29574b2e7e53056595ce1f3dbb130957eb1aa2d7248371bfc21919b66c9bf
7
+ data.tar.gz: d701f9dc7a595241544540e1cdb714a2b78be515adfa4bf476f257c27476b555a1cd614e208a507159f9052240693fbfdb4b47e9a993ca3f3843cfee4c0e8dfe
@@ -6,6 +6,7 @@ OSRF_PATH = '/osrf-gateway-v1'
6
6
 
7
7
  module EvergreenHoldings
8
8
  class Connection
9
+ attr_reader :org_units
9
10
  # Create a new object with the evergreen_domain
10
11
  # specified, e.g. http://libcat.linnbenton.edu
11
12
  #
@@ -130,11 +131,11 @@ module EvergreenHoldings
130
131
 
131
132
  # Status objects represent all the holdings attached to a specific tcn
132
133
  class Status
133
- attr_reader :copies
134
+ attr_reader :copies, :libraries
134
135
  def initialize json_data, connection = nil
135
136
  @connection = connection
136
137
  @raw_data = JSON.parse(json_data)['payload'][0]
137
- @copies = extract_copies
138
+ extract_copies
138
139
  substitute_values_for_ids unless @connection.nil?
139
140
  @available_copies = []
140
141
  @next_copy_available = 'a date'
@@ -150,30 +151,30 @@ module EvergreenHoldings
150
151
  end
151
152
 
152
153
  private
154
+
153
155
  # Look through @raw_data and find the copies
154
156
  def extract_copies
155
- copies = Array.new
157
+ @copies = Array.new
156
158
  @raw_data.each do |vol|
157
159
  if vol['__p'][0].size > 0
158
160
  vol['__p'][0].each do |item|
159
161
  unless item['__p'][35].nil?
160
- copies.push Item.new barcode: item['__p'][2], call_number: vol['__p'][7], location: item['__p'][24], status: item['__p'][28], owning_lib: item['__p'][5]
162
+ @copies.push Item.new barcode: item['__p'][2], call_number: vol['__p'][7], location: item['__p'][24], status: item['__p'][28], owning_lib: item['__p'][5]
161
163
  else
162
164
  begin
163
- copies.push Item.new barcode: item['__p'][2], call_number: vol['__p'][7], due_date: item['__p'][35][0]['__p'][6], location: item['__p'][24], status: item['__p'][28], owning_lib: item['__p'][5]
165
+ @copies.push Item.new barcode: item['__p'][2], call_number: vol['__p'][7], due_date: item['__p'][35][0]['__p'][6], location: item['__p'][24], status: item['__p'][28], owning_lib: item['__p'][5]
164
166
  rescue
165
- puts item['__p'][5]
166
- puts @org_units
167
- copies.push Item.new barcode: item['__p'][2], call_number: vol['__p'][7], location: item['__p'][24], status: item['__p'][28], owning_lib: item['__p'][5]
167
+ @copies.push Item.new barcode: item['__p'][2], call_number: vol['__p'][7], location: item['__p'][24], status: item['__p'][28], owning_lib: item['__p'][5]
168
168
  end
169
169
  end
170
170
  end
171
171
  end
172
172
  end
173
- return copies
174
173
  end
175
174
 
176
175
  def substitute_values_for_ids
176
+ @libraries = @connection.org_units.clone
177
+ @libraries.each { |key, lib| lib[:copies] = Array.new }
177
178
  @copies.each do |copy|
178
179
  if copy.location.is_a? Numeric
179
180
  copy.location = @connection.location_name copy.location
@@ -182,7 +183,9 @@ module EvergreenHoldings
182
183
  copy.status = @connection.status_name copy.status
183
184
  end
184
185
  if copy.owning_lib.is_a? Numeric
186
+ ou_id = copy.owning_lib
185
187
  copy.owning_lib = @connection.ou_name copy.owning_lib
188
+ @libraries[ou_id][:copies].push copy
186
189
  end
187
190
  end
188
191
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: evergreen_holdings
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.7
4
+ version: 0.1.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jane Sandberg
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-05-03 00:00:00.000000000 Z
11
+ date: 2017-07-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: minitest