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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1aec0c0b09594004dbe8cd002b6e42cf7f3ff42a
4
- data.tar.gz: cf5bb8f8dca71964796f19ba752c721185859f52
3
+ metadata.gz: 87f1a91704a2135d53d4f602917cf1c2908153ab
4
+ data.tar.gz: f53d05a8df248ebc929cb9cacf641121e65540a4
5
5
  SHA512:
6
- metadata.gz: fb560f6189c6e1a25a941bf6a8dab2b8a18cc836a39816333f23fa14c4510d4f70bb9cd56d1754cecc7f2388eb88d18d61c10001b3dcf7517eb138d4eb5908dd
7
- data.tar.gz: eebef1706a4ef7d8070d84004541b11d7a6f1a8026b0d5c7b663232819a6b63c4e614455a6705014ce63226f0a2cb8acf215f61654fc8f1bff916ba70c3ffbbb
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
@@ -1,3 +1,3 @@
1
1
  module Sip2
2
- VERSION = '0.0.6'.freeze
2
+ VERSION = '0.0.8'.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.6
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-03-13 00:00:00.000000000 Z
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