sip2 0.0.6 → 0.0.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/sip2/patron_information.rb +55 -0
- data/lib/sip2/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 87f1a91704a2135d53d4f602917cf1c2908153ab
|
4
|
+
data.tar.gz: f53d05a8df248ebc929cb9cacf641121e65540a4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e3efffc4f034f23a158d5797caaa1e0672616677d8a39a69efa459c3bde49a24b802d72ce7b54245cf81a40afb34c5a87a2cbb99fd819f915d595d732255e420
|
7
|
+
data.tar.gz: ee5f62893b63b2a85aff8dc07f7d17d7ff544fd66a97a64a52d26423dec79dda3b01489bba87bae6bf67e7b76108a4f6ccd28ab309f9970b791bfc5c515b7c6b
|
@@ -9,6 +9,26 @@ module Sip2
|
|
9
9
|
@raw_response = patron_response
|
10
10
|
end
|
11
11
|
|
12
|
+
def patron_status
|
13
|
+
status = raw_response[/\A64(.{14})/, 1]
|
14
|
+
status.strip if status
|
15
|
+
end
|
16
|
+
|
17
|
+
def language_code
|
18
|
+
raw_response[/\A64.{14}(.{3})/, 1]
|
19
|
+
end
|
20
|
+
|
21
|
+
def transaction_date
|
22
|
+
match = raw_response.match(/\A64.{17}(\d{4})(\d{2})(\d{2})(.{4})(\d{2})(\d{2})(\d{2})/)
|
23
|
+
return unless match
|
24
|
+
_, year, month, day, zone, hour, minute, second = match.to_a
|
25
|
+
Time.new(
|
26
|
+
year.to_i, month.to_i, day.to_i,
|
27
|
+
hour.to_i, minute.to_i, second.to_i,
|
28
|
+
offset_from_zone(zone)
|
29
|
+
)
|
30
|
+
end
|
31
|
+
|
12
32
|
def patron_valid?
|
13
33
|
parse_boolean raw_response, 'BL'
|
14
34
|
end
|
@@ -46,5 +66,40 @@ module Sip2
|
|
46
66
|
def parse_text(response, message_id)
|
47
67
|
response[/\|#{message_id}(.*?)\|/, 1]
|
48
68
|
end
|
69
|
+
|
70
|
+
def offset_from_zone(zone)
|
71
|
+
zone.strip!
|
72
|
+
lookup = TIME_ZONE_LOOKUP_TABLE.find { |_, v| v.include? zone }
|
73
|
+
lookup ? lookup.first : '+00:00'
|
74
|
+
end
|
75
|
+
|
76
|
+
TIME_ZONE_LOOKUP_TABLE = {
|
77
|
+
'-12:00' => %w[Y],
|
78
|
+
'-11:00' => %w[X BST],
|
79
|
+
'-10:00' => %w[W HST BDT],
|
80
|
+
'-09:00' => %w[V YST HDT],
|
81
|
+
'-08:00' => %w[U PST YDT],
|
82
|
+
'-07:00' => %w[T MST PDT],
|
83
|
+
'-06:00' => %w[S CST MDT],
|
84
|
+
'-05:00' => %w[R EST CDT],
|
85
|
+
'-04:00' => %w[Q AST EDT],
|
86
|
+
'-03:00' => %w[P ADT],
|
87
|
+
'-02:00' => %w[O],
|
88
|
+
'-01:00' => %w[N],
|
89
|
+
'+00:00' => %w[Z GMT WET],
|
90
|
+
'+01:00' => %w[A CET BST],
|
91
|
+
'+02:00' => %w[B EET],
|
92
|
+
'+03:00' => %w[C],
|
93
|
+
'+04:00' => %w[D],
|
94
|
+
'+05:00' => %w[E],
|
95
|
+
'+06:00' => %w[F],
|
96
|
+
'+07:00' => %w[G],
|
97
|
+
'+08:00' => %w[H SST WST],
|
98
|
+
'+09:00' => %w[I JST],
|
99
|
+
'+10:00' => %w[K JDT],
|
100
|
+
'+11:00' => %w[L],
|
101
|
+
'+12:00' => %w[M NZST],
|
102
|
+
'+13:00' => %w[NZDT]
|
103
|
+
}.freeze
|
49
104
|
end
|
50
105
|
end
|
data/lib/sip2/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sip2
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- abrom
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-05-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -123,7 +123,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
123
123
|
version: '0'
|
124
124
|
requirements: []
|
125
125
|
rubyforge_project:
|
126
|
-
rubygems_version: 2.6.14
|
126
|
+
rubygems_version: 2.6.14.1
|
127
127
|
signing_key:
|
128
128
|
specification_version: 4
|
129
129
|
summary: 3M™ Standard Interchange Protocol v2 client implementation in Ruby
|