evergreen_holdings 0.1.3 → 0.1.4

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 +18 -6
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 169c2fdedb2ec153b7c53ae3127b40d204af2224
4
- data.tar.gz: 529a07c9eda3945dbedd495a40196c786d9e1860
3
+ metadata.gz: fef279aa15db0975f27e0dea9ec051c309ea26db
4
+ data.tar.gz: 1b5c63dad01749d7ae653531b56ca6e7525f903b
5
5
  SHA512:
6
- metadata.gz: b3be85651e00e4cc3775ce4e231ebb71877d9eea86e03a63962b0ce6ed418711de3e82cb896a3269cb77151f652c5b21233a3de9dc7864e2dac3ad958c7af28c
7
- data.tar.gz: 28d29236b89ce07dd4c864dc4d7d0beefe28f1b609998e1c53e5feef3808a595afe16c3cba1f56c74ba0262eeccec924e3de4bcafe7ffc3d19bc47b466cf6317
6
+ metadata.gz: b901c71d6fa8494cea763d92dca26e45da7d7a950226f59d627c07e7bf4e722b958ace7fac54e545a97b3b340702ae2e0add4cc221086f86a6c01edbeeb3d25a
7
+ data.tar.gz: 759f46ee10415bb6e48b43b18695e7b9a79e7c27b4f9d4be8acc0c863c4ca3a40059424bcb18cf12c540a43c43740f155289b499b1141c31aee1547af49c0193
@@ -30,15 +30,15 @@ module EvergreenHoldings
30
30
  end
31
31
  @gateway.query = params
32
32
 
33
- res = Net::HTTP.get_response(@gateway)
34
- return Status.new res.body, self if res.is_a?(Net::HTTPSuccess)
33
+ res = send_query
34
+ return Status.new res.body, self if res
35
35
  end
36
36
 
37
37
  def location_name id
38
38
  params = "format=json&input_format=json&service=open-ils.circ&method=open-ils.circ.copy_location.retrieve&param=#{id}"
39
39
  @gateway.query = params
40
- res = Net::HTTP.get_response(@gateway)
41
- if res.is_a? Net::HTTPSuccess
40
+ res = send_query
41
+ if res
42
42
  data = JSON.parse(res.body)['payload'][0]
43
43
  unless data.key? 'stacktrace'
44
44
  return data['__p'][4]
@@ -53,12 +53,22 @@ module EvergreenHoldings
53
53
 
54
54
  private
55
55
 
56
+ def send_query
57
+ begin
58
+ res = Net::HTTP.get_response(@gateway)
59
+ rescue Errno::ECONNREFUSED
60
+ return nil
61
+ end
62
+ return res if res.is_a?(Net::HTTPSuccess)
63
+ return nil
64
+ end
65
+
56
66
  def fetch_statuses
57
67
  @possible_item_statuses = []
58
68
  params = 'format=json&input_format=json&service=open-ils.search&method=open-ils.search.config.copy_status.retrieve.all'
59
69
  @gateway.query = params
60
- res = Net::HTTP.get_response(@gateway)
61
- if res.is_a?(Net::HTTPSuccess)
70
+ res = send_query
71
+ if res
62
72
  stats = JSON.parse(res.body)['payload'][0]
63
73
  stats.each do |stat|
64
74
  @possible_item_statuses[stat['__p'][1]] = stat['__p'][2]
@@ -70,6 +80,7 @@ module EvergreenHoldings
70
80
 
71
81
  end
72
82
 
83
+ # Status objects represent all the holdings attached to a specific tcn
73
84
  class Status
74
85
  attr_reader :copies
75
86
  def initialize json_data, connection = nil
@@ -125,6 +136,7 @@ module EvergreenHoldings
125
136
 
126
137
  end
127
138
 
139
+ # A physical copy of an item
128
140
  class Item
129
141
  attr_accessor :location, :status
130
142
  attr_reader :barcode, :call_number
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.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jane Sandberg
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-09-27 00:00:00.000000000 Z
11
+ date: 2016-10-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: minitest