sip2 0.1.1 → 0.2.4

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.
@@ -0,0 +1,144 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Sip2
4
+ module Responses
5
+ #
6
+ # Sip2 Patron Information
7
+ #
8
+ # https://developers.exlibrisgroup.com/wp-content/uploads/2020/01/3M-Standard-Interchange-Protocol-Version-2.00.pdf
9
+ #
10
+ # Response message 64
11
+ # * patron status - 14 char, fixed-length required field
12
+ # * language - 3 char, fixed-length required field
13
+ # * transaction date - 18 char, fixed-length required field: YYYYMMDDZZZZHHMMSS
14
+ # * hold items count - 4 char, fixed-length required field
15
+ # * overdue items count - 4 char, fixed-length required field
16
+ # * charged items count - 4 char, fixed-length required field
17
+ # * fine items count - 4 char, fixed-length required field
18
+ # * recall items count - 4 char, fixed-length required field
19
+ # * unavailable holds count - 4 char, fixed-length required field
20
+ # * institution id - AO - variable-length required field
21
+ # * patron identifier - AA - variable-length required field
22
+ # * personal name - AE - variable-length required field
23
+ # * hold items limit - BZ - 4 char, fixed-length optional field
24
+ # * overdue items limit - CA - 4 char, fixed-length optional field
25
+ # * charged items limit - CB - 4 char, fixed-length optional field
26
+ # * valid patron - BL - 1 char, optional field: Y or N
27
+ # * valid patron password - CQ - 1 char, optional field: Y or N
28
+ # * currency type - BH - 3 char, fixed-length optional field
29
+ # * fee amount - BV - variable-length optional field
30
+ # * fee limit - CC - variable-length optional field
31
+ # * hold items - AS - variable-length optional field
32
+ # * overdue items - AT - variable-length optional field
33
+ # * charged items - AU - variable-length optional field
34
+ # * fine items - AV - variable-length optional field
35
+ # * recall items - BU - variable-length optional field
36
+ # * unavailable hold items - CD - variable-length optional field
37
+ # * home address - BD - variable-length optional field
38
+ # * email address - BE - variable-length optional field
39
+ # * home phone number - BF - variable-length optional field
40
+ # * screen message - AF - variable-length optional field
41
+ # * print line - AG - variable-length optional field
42
+ #
43
+ class PatronInformation < Base
44
+ RESPONSE_ID = 64
45
+ FIXED_LENGTH_CHARS = 61 # 59 chars + 2 for the header
46
+
47
+ def charge_privileges_denied?
48
+ parse_fixed_boolean 0
49
+ end
50
+
51
+ def renewal_privileges_denied?
52
+ parse_fixed_boolean 1
53
+ end
54
+
55
+ def recall_privileges_denied?
56
+ parse_fixed_boolean 2
57
+ end
58
+
59
+ def hold_privileges_denied?
60
+ parse_fixed_boolean 3
61
+ end
62
+
63
+ def card_reported_lost?
64
+ parse_fixed_boolean 4
65
+ end
66
+
67
+ def too_many_items_charged?
68
+ parse_fixed_boolean 5
69
+ end
70
+
71
+ def too_many_items_overdue?
72
+ parse_fixed_boolean 6
73
+ end
74
+
75
+ def too_many_renewals?
76
+ parse_fixed_boolean 7
77
+ end
78
+
79
+ def too_many_claims_of_items_returned?
80
+ parse_fixed_boolean 8
81
+ end
82
+
83
+ def too_many_items_lost?
84
+ parse_fixed_boolean 9
85
+ end
86
+
87
+ def excessive_outstanding_fines?
88
+ parse_fixed_boolean 10
89
+ end
90
+
91
+ def excessive_outstanding_fees?
92
+ parse_fixed_boolean 11
93
+ end
94
+
95
+ def recall_overdue?
96
+ parse_fixed_boolean 12
97
+ end
98
+
99
+ def too_many_items_billed?
100
+ parse_fixed_boolean 13
101
+ end
102
+
103
+ def language
104
+ LANGUAGE_LOOKUP_TABLE[parse_fixed_response(14, 3)]
105
+ end
106
+
107
+ def transaction_date
108
+ parse_datetime 17
109
+ end
110
+
111
+ def patron_valid?
112
+ parse_optional_boolean 'BL'
113
+ end
114
+
115
+ def authenticated?
116
+ parse_optional_boolean 'CQ'
117
+ end
118
+
119
+ def email
120
+ parse_text 'BE'
121
+ end
122
+
123
+ def location
124
+ parse_text 'AQ'
125
+ end
126
+
127
+ def screen_message
128
+ parse_text 'AF'
129
+ end
130
+
131
+ def inspect
132
+ format(
133
+ '#<%<class_name>s:0x%<object_id>p @patron_valid="%<patron_valid>s"' \
134
+ ' @email="%<email>s" @authenticated="%<authenticated>s">',
135
+ class_name: self.class.name,
136
+ object_id: object_id,
137
+ patron_valid: patron_valid?,
138
+ email: email,
139
+ authenticated: authenticated?
140
+ )
141
+ end
142
+ end
143
+ end
144
+ end
@@ -0,0 +1,133 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Sip2
4
+ module Responses
5
+ #
6
+ # Sip2 Patron Information
7
+ #
8
+ # https://developers.exlibrisgroup.com/wp-content/uploads/2020/01/3M-Standard-Interchange-Protocol-Version-2.00.pdf
9
+ #
10
+ # Response message 98
11
+ # * on-line status - 1 char, fixed-length required field: Y or N
12
+ # * checkin ok - 1 char, fixed-length required field: Y or N
13
+ # * checkout ok - 1 char, fixed-length required field: Y or N
14
+ # * ACS renewal policy - 1 char, fixed-length required field: Y or N
15
+ # * status update ok - 1 char, fixed-length required field: Y or N
16
+ # * off-line ok - 1 char, fixed-length required field: Y or N
17
+ # * timeout period - 3 char, fixed-length required field
18
+ # * retries allowed - 3 char, fixed-length required field
19
+ # * date / time sync - 18 char, fixed-length required field: YYYYMMDDZZZZHHMMSS
20
+ # * protocol version - 4 char, fixed-length required field: x.xx
21
+ # * institution ID - AO - variable-length required field
22
+ # * library name - AM - variable-length optional field
23
+ # * supported messages - BX - variable-length required field
24
+ # * terminal location - AN - variable-length optional field
25
+ # * screen message - AF - variable-length optional field
26
+ # * print line - AG - variable-length optional field
27
+ #
28
+ class Status < Base
29
+ RESPONSE_ID = 98
30
+ FIXED_LENGTH_CHARS = 36 # 34 chars + 2 for the header
31
+ SUPPORTED_MESSAGES = {
32
+ patron_status_request: 0,
33
+ checkout: 1,
34
+ checkin: 2,
35
+ block_patron: 3,
36
+ status: 4,
37
+ request_resend: 5,
38
+ login: 6,
39
+ patron_information: 7,
40
+ end_patron_session: 8,
41
+ fee_paid: 9,
42
+ item_information: 10,
43
+ item_status_update: 11,
44
+ patron_enable: 12,
45
+ hold: 13,
46
+ renew: 14,
47
+ renew_all: 15
48
+ }.freeze
49
+
50
+ def online?
51
+ parse_fixed_boolean 0
52
+ end
53
+
54
+ def checkin_ok?
55
+ parse_fixed_boolean 1
56
+ end
57
+
58
+ def checkout_ok?
59
+ parse_fixed_boolean 2
60
+ end
61
+
62
+ def acs_renewal_policy?
63
+ parse_fixed_boolean 3
64
+ end
65
+
66
+ def status_update_ok?
67
+ parse_fixed_boolean 4
68
+ end
69
+
70
+ def offline_ok?
71
+ parse_fixed_boolean 5
72
+ end
73
+
74
+ def timeout_period
75
+ timeout = parse_fixed_response 6, 3
76
+ timeout.to_i if timeout.match?(/\A\d+\z/)
77
+ end
78
+
79
+ def retries_allowed
80
+ retries = parse_fixed_response 9, 3
81
+ retries.to_i if retries.match?(/\A\d+\z/)
82
+ end
83
+
84
+ def date_sync
85
+ parse_datetime 12
86
+ end
87
+
88
+ def protocol_version
89
+ version = parse_fixed_response 30, 4
90
+ version.to_f if version.match?(/\A\d\.\d\d\z/)
91
+ end
92
+
93
+ def institution_id
94
+ parse_text 'AO'
95
+ end
96
+
97
+ def library_name
98
+ parse_text 'AM'
99
+ end
100
+
101
+ def supported_messages
102
+ message = parse_text('BX').to_s
103
+
104
+ SUPPORTED_MESSAGES.each_with_object([]) do |(supported_message, index), acc|
105
+ acc << supported_message if message[index] == 'Y'
106
+ end
107
+ end
108
+
109
+ def terminal_location
110
+ parse_text 'AN'
111
+ end
112
+
113
+ def screen_message
114
+ parse_text 'AF'
115
+ end
116
+
117
+ def print_line
118
+ parse_text 'AG'
119
+ end
120
+
121
+ def inspect
122
+ format(
123
+ '#<%<class_name>s:0x%<object_id>p @online="%<online>s"' \
124
+ ' @protocol_version="%<protocol_version>s"',
125
+ class_name: self.class.name,
126
+ object_id: object_id,
127
+ online: online?,
128
+ protocol_version: protocol_version
129
+ )
130
+ end
131
+ end
132
+ end
133
+ end
data/lib/sip2/version.rb CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Sip2
2
- VERSION = '0.1.1'.freeze
4
+ VERSION = '0.2.4'
3
5
  end
data/lib/sip2.rb CHANGED
@@ -1,14 +1,25 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'sip2/version'
2
4
 
3
- require 'sip2/patron_information'
5
+ require 'openssl'
6
+
7
+ require 'sip2/responses/base'
8
+ require 'sip2/responses/patron_information'
9
+ require 'sip2/responses/status'
4
10
 
11
+ require 'sip2/messages/base'
5
12
  require 'sip2/messages/login'
6
13
  require 'sip2/messages/patron_information'
14
+ require 'sip2/messages/status'
7
15
 
8
16
  module Sip2
9
17
  class TimeoutError < StandardError; end
18
+
10
19
  class ConnectionTimeout < TimeoutError; end
20
+
11
21
  class WriteTimeout < TimeoutError; end
22
+
12
23
  class ReadTimeout < TimeoutError; end
13
24
  end
14
25
 
metadata CHANGED
@@ -1,43 +1,43 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sip2
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.2.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - abrom
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-11-01 00:00:00.000000000 Z
11
+ date: 2022-01-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ">="
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '1.11'
19
+ version: '2'
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ">="
24
+ - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '1.11'
26
+ version: '2'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rake
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ">="
31
+ - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '10.0'
33
+ version: '13.0'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - ">="
38
+ - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: '10.0'
40
+ version: '13.0'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rspec
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -58,28 +58,70 @@ dependencies:
58
58
  requirements:
59
59
  - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: '0'
61
+ version: '1.0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '1.0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rubocop-performance
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '1.0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '1.0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: rubocop-rake
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '0.5'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '0.5'
97
+ - !ruby/object:Gem::Dependency
98
+ name: rubocop-rspec
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: '2.0'
62
104
  type: :development
63
105
  prerelease: false
64
106
  version_requirements: !ruby/object:Gem::Requirement
65
107
  requirements:
66
108
  - - "~>"
67
109
  - !ruby/object:Gem::Version
68
- version: '0'
110
+ version: '2.0'
69
111
  - !ruby/object:Gem::Dependency
70
112
  name: timecop
71
113
  requirement: !ruby/object:Gem::Requirement
72
114
  requirements:
73
115
  - - "~>"
74
116
  - !ruby/object:Gem::Version
75
- version: '0'
117
+ version: '0.9'
76
118
  type: :development
77
119
  prerelease: false
78
120
  version_requirements: !ruby/object:Gem::Requirement
79
121
  requirements:
80
122
  - - "~>"
81
123
  - !ruby/object:Gem::Version
82
- version: '0'
124
+ version: '0.9'
83
125
  description: 3M™ Standard Interchange Protocol v2 client implementation in Ruby
84
126
  email:
85
127
  - a.bromwich@gmail.com
@@ -87,27 +129,26 @@ executables: []
87
129
  extensions: []
88
130
  extra_rdoc_files: []
89
131
  files:
90
- - ".gitignore"
91
- - ".rubocop.yml"
92
- - ".travis.yml"
93
- - Gemfile
94
132
  - LICENSE
95
133
  - README.md
96
- - Rakefile
97
134
  - lib/sip2.rb
98
135
  - lib/sip2/client.rb
99
136
  - lib/sip2/connection.rb
137
+ - lib/sip2/messages/base.rb
100
138
  - lib/sip2/messages/login.rb
101
139
  - lib/sip2/messages/patron_information.rb
140
+ - lib/sip2/messages/status.rb
102
141
  - lib/sip2/non_blocking_socket.rb
103
- - lib/sip2/patron_information.rb
142
+ - lib/sip2/responses/base.rb
143
+ - lib/sip2/responses/patron_information.rb
144
+ - lib/sip2/responses/status.rb
104
145
  - lib/sip2/version.rb
105
- - sip2.gemspec
106
146
  homepage: https://github.com/Studiosity/sip2-ruby
107
147
  licenses:
108
148
  - MIT
109
- metadata: {}
110
- post_install_message:
149
+ metadata:
150
+ rubygems_mfa_required: 'true'
151
+ post_install_message:
111
152
  rdoc_options: []
112
153
  require_paths:
113
154
  - lib
@@ -115,16 +156,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
115
156
  requirements:
116
157
  - - ">="
117
158
  - !ruby/object:Gem::Version
118
- version: 2.2.0
159
+ version: 2.5.0
119
160
  required_rubygems_version: !ruby/object:Gem::Requirement
120
161
  requirements:
121
162
  - - ">="
122
163
  - !ruby/object:Gem::Version
123
164
  version: '0'
124
165
  requirements: []
125
- rubyforge_project:
126
- rubygems_version: 2.7.6
127
- signing_key:
166
+ rubygems_version: 3.2.32
167
+ signing_key:
128
168
  specification_version: 4
129
- summary: 3M™ Standard Interchange Protocol v2 client implementation in Ruby
169
+ summary: SIP2 Ruby client
130
170
  test_files: []
data/.gitignore DELETED
@@ -1,2 +0,0 @@
1
- *.gem
2
- Gemfile.lock
data/.rubocop.yml DELETED
@@ -1,9 +0,0 @@
1
- Metrics/BlockLength:
2
- Exclude:
3
- - "**/*_spec.rb"
4
-
5
- Metrics/LineLength:
6
- Max: 100
7
-
8
- Metrics/ClassLength:
9
- Enabled: false
data/.travis.yml DELETED
@@ -1,22 +0,0 @@
1
- language: ruby
2
- sudo: required
3
-
4
- rvm:
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
10
-
11
- before_install:
12
- - gem update bundler
13
-
14
- install:
15
- - bundle install --jobs=3 --retry=3
16
- - gem install rubocop
17
-
18
- script:
19
- - rubocop
20
- # Blackhole 127.0.0.2 for testing connection timeouts
21
- - sudo iptables -I INPUT -s 127.0.0.2 -j DROP
22
- - bundle exec rake
data/Gemfile DELETED
@@ -1,4 +0,0 @@
1
- source 'https://rubygems.org'
2
-
3
- # Specify your gem's dependencies in sip2.gemspec
4
- gemspec
data/Rakefile DELETED
@@ -1,8 +0,0 @@
1
- #!/usr/bin/env rake
2
-
3
- require 'bundler/gem_tasks'
4
- require 'rspec/core/rake_task'
5
-
6
- RSpec::Core::RakeTask.new(:spec)
7
-
8
- task default: :spec