sip2 0.0.12 → 0.1.1

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
- SHA1:
3
- metadata.gz: 426aa3286377738536f3308fe3031e27103f6fe6
4
- data.tar.gz: 03aa7d489c2ba5089bf5a961dc045c8c6682b8db
2
+ SHA256:
3
+ metadata.gz: e8f73fce390c230b1c0d95bba4221ebe77368b49a394635d84d8bd8314208ebb
4
+ data.tar.gz: c1b9beff001b1e3774a57853d2b031c5154fe51b793be2c301968744e61ca08d
5
5
  SHA512:
6
- metadata.gz: 6acd6b54ecf7e553ce2cbc05257ea2721bcc3b5203166b755316cd4165e02e13003f1ffed164e4896883d3a6900bc45106864cffa753b68c46eceec1837965f6
7
- data.tar.gz: 71f3609d27e6a0c6eda9541900b9982034359306cd967820db39cbd4f4411907dbfb465d842d81e712bab5a1301bf8638f6bea81a69cefb991c8428fc5ecfdbc
6
+ metadata.gz: 44d2323ee3939e99bdb192c5f61ce0be327321e99f5260592f62260ad3145d2681353ef759aff7a3193c09c7b5403e1f08f50fac661ecf22a063ec3ba475cfa8
7
+ data.tar.gz: 22e1645b0b13fcdff5de58757a9ba052191173c7fd374572fdadfaeba99a66b4b495d3dbb2b98dc717692f2f3c0442c975769c6917aaf7097d4c6f9a600ffeee
@@ -1,10 +1,12 @@
1
1
  language: ruby
2
+ sudo: required
3
+
2
4
  rvm:
3
- - 2.1.10
4
- - 2.2.10
5
- - 2.3.7
6
- - 2.4.4
7
- - 2.5.1
5
+ - 2.2
6
+ - 2.3
7
+ - 2.4
8
+ - 2.5
9
+ # - 2.6 waiting for https://github.com/rubocop-hq/rubocop/issues/6412 to land
8
10
 
9
11
  before_install:
10
12
  - gem update bundler
@@ -15,4 +17,6 @@ install:
15
17
 
16
18
  script:
17
19
  - rubocop
20
+ # Blackhole 127.0.0.2 for testing connection timeouts
21
+ - sudo iptables -I INPUT -s 127.0.0.2 -j DROP
18
22
  - bundle exec rake
@@ -3,14 +3,15 @@ module Sip2
3
3
  # Sip2 Client
4
4
  #
5
5
  class Client
6
- def initialize(host:, port:, ignore_error_detection: false)
6
+ def initialize(host:, port:, ignore_error_detection: false, timeout: nil)
7
7
  @host = host
8
8
  @port = port
9
9
  @ignore_error_detection = ignore_error_detection
10
+ @timeout = timeout || NonBlockingSocket::DEFAULT_TIMEOUT
10
11
  end
11
12
 
12
13
  def connect
13
- socket = NonBlockingSocket.connect @host, @port
14
+ socket = NonBlockingSocket.connect @host, @port, @timeout
14
15
  yield Connection.new(socket, @ignore_error_detection) if block_given?
15
16
  ensure
16
17
  socket.close if socket
@@ -41,6 +41,7 @@ module Sip2
41
41
  message = with_checksum with_error_detection message
42
42
  response = send_message message
43
43
  return if response.nil?
44
+
44
45
  send "handle_#{message_type}_response", response
45
46
  end
46
47
 
@@ -68,6 +69,7 @@ module Sip2
68
69
 
69
70
  def sequence_and_checksum_valid?(response)
70
71
  return true if @ignore_error_detection
72
+
71
73
  sequence_regex = /^(?<message>.*?AY(?<sequence>[0-9]+)AZ)(?<checksum>[A-F0-9]{4})$/
72
74
  match = response.strip.match sequence_regex
73
75
  match &&
@@ -23,6 +23,7 @@ module Sip2
23
23
 
24
24
  def handle_patron_information_response(response)
25
25
  return unless sequence_and_checksum_valid?(response)
26
+
26
27
  Sip2::PatronInformation.new response
27
28
  end
28
29
  end
@@ -72,6 +72,7 @@ module Sip2
72
72
  def transaction_date
73
73
  match = raw_response.match(/\A64.{17}(\d{4})(\d{2})(\d{2})(.{4})(\d{2})(\d{2})(\d{2})/)
74
74
  return unless match
75
+
75
76
  _, year, month, day, zone, hour, minute, second = match.to_a
76
77
  Time.new(
77
78
  year.to_i, month.to_i, day.to_i,
@@ -1,3 +1,3 @@
1
1
  module Sip2
2
- VERSION = '0.0.12'.freeze
2
+ VERSION = '0.1.1'.freeze
3
3
  end
@@ -17,11 +17,11 @@ Gem::Specification.new do |spec|
17
17
  spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(spec)/}) }
18
18
  spec.require_paths = ['lib']
19
19
 
20
- spec.required_ruby_version = '>= 2.1.0'
20
+ spec.required_ruby_version = '>= 2.2.0'
21
21
 
22
22
  spec.add_development_dependency 'bundler', '>= 1.11'
23
23
  spec.add_development_dependency 'rake', '>= 10.0'
24
24
  spec.add_development_dependency 'rspec', '~> 3.0'
25
- spec.add_development_dependency 'rubocop'
25
+ spec.add_development_dependency 'rubocop', '~> 0'
26
26
  spec.add_development_dependency 'timecop', '~> 0'
27
27
  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.12
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - abrom
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-06-05 00:00:00.000000000 Z
11
+ date: 2018-11-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -56,14 +56,14 @@ dependencies:
56
56
  name: rubocop
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - ">="
59
+ - - "~>"
60
60
  - !ruby/object:Gem::Version
61
61
  version: '0'
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - ">="
66
+ - - "~>"
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
69
  - !ruby/object:Gem::Dependency
@@ -115,7 +115,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
115
115
  requirements:
116
116
  - - ">="
117
117
  - !ruby/object:Gem::Version
118
- version: 2.1.0
118
+ version: 2.2.0
119
119
  required_rubygems_version: !ruby/object:Gem::Requirement
120
120
  requirements:
121
121
  - - ">="
@@ -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.1
126
+ rubygems_version: 2.7.6
127
127
  signing_key:
128
128
  specification_version: 4
129
129
  summary: 3M™ Standard Interchange Protocol v2 client implementation in Ruby