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.
- checksums.yaml +4 -4
- data/lib/evergreen_holdings.rb +18 -6
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fef279aa15db0975f27e0dea9ec051c309ea26db
|
4
|
+
data.tar.gz: 1b5c63dad01749d7ae653531b56ca6e7525f903b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b901c71d6fa8494cea763d92dca26e45da7d7a950226f59d627c07e7bf4e722b958ace7fac54e545a97b3b340702ae2e0add4cc221086f86a6c01edbeeb3d25a
|
7
|
+
data.tar.gz: 759f46ee10415bb6e48b43b18695e7b9a79e7c27b4f9d4be8acc0c863c4ca3a40059424bcb18cf12c540a43c43740f155289b499b1141c31aee1547af49c0193
|
data/lib/evergreen_holdings.rb
CHANGED
@@ -30,15 +30,15 @@ module EvergreenHoldings
|
|
30
30
|
end
|
31
31
|
@gateway.query = params
|
32
32
|
|
33
|
-
res =
|
34
|
-
return Status.new res.body, self if res
|
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¶m=#{id}"
|
39
39
|
@gateway.query = params
|
40
|
-
res =
|
41
|
-
if res
|
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 =
|
61
|
-
if res
|
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.
|
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-
|
11
|
+
date: 2016-10-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: minitest
|