sip2 0.0.8 → 0.0.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 87f1a91704a2135d53d4f602917cf1c2908153ab
4
- data.tar.gz: f53d05a8df248ebc929cb9cacf641121e65540a4
3
+ metadata.gz: 66c5b3c4ac6909954ad5e3c0b11577cb97d17e91
4
+ data.tar.gz: 47985f7e545caec1d2d71e7fdeda15dbf099af7a
5
5
  SHA512:
6
- metadata.gz: e3efffc4f034f23a158d5797caaa1e0672616677d8a39a69efa459c3bde49a24b802d72ce7b54245cf81a40afb34c5a87a2cbb99fd819f915d595d732255e420
7
- data.tar.gz: ee5f62893b63b2a85aff8dc07f7d17d7ff544fd66a97a64a52d26423dec79dda3b01489bba87bae6bf67e7b76108a4f6ccd28ab309f9970b791bfc5c515b7c6b
6
+ metadata.gz: c59b28ec3bfb1c1e4604e0dc8e5196c91b994c0015c11a5badfc54e6cce2a4f45a4e4bbcae42fea24e0ee28a73f609353c609eaeb53a7109ed54d91f7b567c0c
7
+ data.tar.gz: 6cab90f0952d40cc71664db95b746014ad4f996049523789be36d663539f44ddcae6f36420f496befc0c8f297bebbdccc483b1f6b98b9b4936fd025458282de2
@@ -4,3 +4,6 @@ Metrics/BlockLength:
4
4
 
5
5
  Metrics/LineLength:
6
6
  Max: 100
7
+
8
+ Metrics/ClassLength:
9
+ Enabled: false
@@ -9,13 +9,64 @@ 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
12
+ def charge_privileges_denied?
13
+ parse_patron_status 0
15
14
  end
16
15
 
17
- def language_code
18
- raw_response[/\A64.{14}(.{3})/, 1]
16
+ def renewal_privileges_denied?
17
+ parse_patron_status 1
18
+ end
19
+
20
+ def recall_privileges_denied?
21
+ parse_patron_status 2
22
+ end
23
+
24
+ def hold_privileges_denied?
25
+ parse_patron_status 3
26
+ end
27
+
28
+ def card_reported_lost?
29
+ parse_patron_status 4
30
+ end
31
+
32
+ def too_many_items_charged?
33
+ parse_patron_status 5
34
+ end
35
+
36
+ def too_many_items_overdue?
37
+ parse_patron_status 6
38
+ end
39
+
40
+ def too_many_renewals?
41
+ parse_patron_status 7
42
+ end
43
+
44
+ def too_many_claims_of_items_returned?
45
+ parse_patron_status 8
46
+ end
47
+
48
+ def too_many_items_lost?
49
+ parse_patron_status 9
50
+ end
51
+
52
+ def excessive_outstanding_fines?
53
+ parse_patron_status 10
54
+ end
55
+
56
+ def excessive_outstanding_fees?
57
+ parse_patron_status 11
58
+ end
59
+
60
+ def recall_overdue?
61
+ parse_patron_status 12
62
+ end
63
+
64
+ def too_many_items_billed?
65
+ parse_patron_status 13
66
+ end
67
+
68
+ def language
69
+ LANGUAGE_LOOKUP_TABLE[parse_fixed_response(14, 3)]
19
70
  end
20
71
 
21
72
  def transaction_date
@@ -30,19 +81,23 @@ module Sip2
30
81
  end
31
82
 
32
83
  def patron_valid?
33
- parse_boolean raw_response, 'BL'
84
+ parse_boolean 'BL'
34
85
  end
35
86
 
36
87
  def authenticated?
37
- parse_boolean raw_response, 'CQ'
88
+ parse_boolean 'CQ'
38
89
  end
39
90
 
40
91
  def email
41
- parse_text raw_response, 'BE'
92
+ parse_text 'BE'
42
93
  end
43
94
 
44
95
  def location
45
- parse_text raw_response, 'AQ'
96
+ parse_text 'AQ'
97
+ end
98
+
99
+ def screen_message
100
+ parse_text 'AF'
46
101
  end
47
102
 
48
103
  def inspect
@@ -59,12 +114,20 @@ module Sip2
59
114
 
60
115
  private
61
116
 
62
- def parse_boolean(response, message_id)
63
- response[/\|#{message_id}([YN])\|/, 1] == 'Y'
117
+ def parse_boolean(message_id)
118
+ raw_response[/\|#{message_id}([YN])\|/, 1] == 'Y'
119
+ end
120
+
121
+ def parse_text(message_id)
122
+ raw_response[/\|#{message_id}(.*?)\|/, 1]
64
123
  end
65
124
 
66
- def parse_text(response, message_id)
67
- response[/\|#{message_id}(.*?)\|/, 1]
125
+ def parse_patron_status(position)
126
+ parse_fixed_response(position) == 'Y'
127
+ end
128
+
129
+ def parse_fixed_response(position, count = 1)
130
+ raw_response[/\A64.{#{position}}(.{#{count}})/, 1]
68
131
  end
69
132
 
70
133
  def offset_from_zone(zone)
@@ -101,5 +164,36 @@ module Sip2
101
164
  '+12:00' => %w[M NZST],
102
165
  '+13:00' => %w[NZDT]
103
166
  }.freeze
167
+
168
+ LANGUAGE_LOOKUP_TABLE = {
169
+ '000' => 'Unknown',
170
+ '001' => 'English',
171
+ '002' => 'French',
172
+ '003' => 'German',
173
+ '004' => 'Italian',
174
+ '005' => 'Dutch',
175
+ '006' => 'Swedish',
176
+ '007' => 'Finnish',
177
+ '008' => 'Spanish',
178
+ '009' => 'Danish',
179
+ '010' => 'Portuguese',
180
+ '011' => 'Canadian-French',
181
+ '012' => 'Norwegian',
182
+ '013' => 'Hebrew',
183
+ '014' => 'Japanese',
184
+ '015' => 'Russian',
185
+ '016' => 'Arabic',
186
+ '017' => 'Polish',
187
+ '018' => 'Greek',
188
+ '019' => 'Chinese',
189
+ '020' => 'Korean',
190
+ '021' => 'North American Spanish',
191
+ '022' => 'Tamil',
192
+ '023' => 'Malay',
193
+ '024' => 'United Kingdom',
194
+ '025' => 'Icelandic',
195
+ '026' => 'Belgian',
196
+ '027' => 'Taiwanese'
197
+ }.freeze
104
198
  end
105
199
  end
@@ -1,3 +1,3 @@
1
1
  module Sip2
2
- VERSION = '0.0.8'.freeze
2
+ VERSION = '0.0.9'.freeze
3
3
  end
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.8
4
+ version: 0.0.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - abrom
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-05-08 00:00:00.000000000 Z
11
+ date: 2018-05-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler