sip2 0.0.11 → 0.2.3

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.
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.0.11
4
+ version: 0.2.3
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-04 00:00:00.000000000 Z
11
+ date: 2021-02-07 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
@@ -56,30 +56,72 @@ dependencies:
56
56
  name: rubocop
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - ">="
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
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
+ - - "~>"
60
74
  - !ruby/object:Gem::Version
61
- version: '0'
75
+ version: '1.0'
62
76
  type: :development
63
77
  prerelease: false
64
78
  version_requirements: !ruby/object:Gem::Requirement
65
79
  requirements:
66
- - - ">="
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'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
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,22 +129,20 @@ 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
@@ -115,16 +155,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
115
155
  requirements:
116
156
  - - ">="
117
157
  - !ruby/object:Gem::Version
118
- version: 2.1.0
158
+ version: 2.4.0
119
159
  required_rubygems_version: !ruby/object:Gem::Requirement
120
160
  requirements:
121
161
  - - ">="
122
162
  - !ruby/object:Gem::Version
123
163
  version: '0'
124
164
  requirements: []
125
- rubyforge_project:
126
- rubygems_version: 2.6.14.1
165
+ rubygems_version: 3.0.6
127
166
  signing_key:
128
167
  specification_version: 4
129
- summary: 3M™ Standard Interchange Protocol v2 client implementation in Ruby
168
+ summary: SIP2 Ruby client
130
169
  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,17 +0,0 @@
1
- language: ruby
2
- rvm:
3
- - 2.1.0
4
- - 2.2.5
5
- - 2.3.0
6
- - 2.4.0
7
-
8
- before_install:
9
- - gem update bundler
10
-
11
- install:
12
- - bundle install --jobs=3 --retry=3
13
- - gem install rubocop
14
-
15
- script:
16
- - rubocop
17
- - 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
@@ -1,199 +0,0 @@
1
- module Sip2
2
- #
3
- # Sip2 Patron Information
4
- #
5
- class PatronInformation
6
- attr_reader :raw_response
7
-
8
- def initialize(patron_response)
9
- @raw_response = patron_response
10
- end
11
-
12
- def charge_privileges_denied?
13
- parse_patron_status 0
14
- end
15
-
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)]
70
- end
71
-
72
- def transaction_date
73
- match = raw_response.match(/\A64.{17}(\d{4})(\d{2})(\d{2})(.{4})(\d{2})(\d{2})(\d{2})/)
74
- return unless match
75
- _, year, month, day, zone, hour, minute, second = match.to_a
76
- Time.new(
77
- year.to_i, month.to_i, day.to_i,
78
- hour.to_i, minute.to_i, second.to_i,
79
- offset_from_zone(zone)
80
- )
81
- end
82
-
83
- def patron_valid?
84
- parse_boolean 'BL'
85
- end
86
-
87
- def authenticated?
88
- parse_boolean 'CQ'
89
- end
90
-
91
- def email
92
- parse_text 'BE'
93
- end
94
-
95
- def location
96
- parse_text 'AQ'
97
- end
98
-
99
- def screen_message
100
- parse_text 'AF'
101
- end
102
-
103
- def inspect
104
- format(
105
- '#<%<class_name>s:0x%<object_id>p @patron_valid="%<patron_valid>s"' \
106
- ' @email="%<email>s" @authenticated="%<authenticated>s">',
107
- class_name: self.class.name,
108
- object_id: object_id,
109
- patron_valid: patron_valid?,
110
- email: email,
111
- authenticated: authenticated?
112
- )
113
- end
114
-
115
- private
116
-
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]
123
- end
124
-
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]
131
- end
132
-
133
- def offset_from_zone(zone)
134
- zone.strip!
135
- lookup = TIME_ZONE_LOOKUP_TABLE.find { |_, v| v.include? zone }
136
- lookup ? lookup.first : '+00:00'
137
- end
138
-
139
- TIME_ZONE_LOOKUP_TABLE = {
140
- '-12:00' => %w[Y],
141
- '-11:00' => %w[X BST],
142
- '-10:00' => %w[W HST BDT],
143
- '-09:00' => %w[V YST HDT],
144
- '-08:00' => %w[U PST YDT],
145
- '-07:00' => %w[T MST PDT],
146
- '-06:00' => %w[S CST MDT],
147
- '-05:00' => %w[R EST CDT],
148
- '-04:00' => %w[Q AST EDT],
149
- '-03:00' => %w[P ADT],
150
- '-02:00' => %w[O],
151
- '-01:00' => %w[N],
152
- '+00:00' => %w[Z GMT WET],
153
- '+01:00' => %w[A CET BST],
154
- '+02:00' => %w[B EET],
155
- '+03:00' => %w[C],
156
- '+04:00' => %w[D],
157
- '+05:00' => %w[E],
158
- '+06:00' => %w[F],
159
- '+07:00' => %w[G],
160
- '+08:00' => %w[H SST WST],
161
- '+09:00' => %w[I JST],
162
- '+10:00' => %w[K JDT],
163
- '+11:00' => %w[L],
164
- '+12:00' => %w[M NZST],
165
- '+13:00' => %w[NZDT]
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
198
- end
199
- end
data/sip2.gemspec DELETED
@@ -1,27 +0,0 @@
1
- lib = File.expand_path('lib', __dir__)
2
- $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
-
4
- require 'sip2/version'
5
-
6
- Gem::Specification.new do |spec|
7
- spec.name = 'sip2'
8
- spec.version = Sip2::VERSION
9
- spec.authors = ['abrom']
10
- spec.email = ['a.bromwich@gmail.com']
11
-
12
- spec.summary = '3M™ Standard Interchange Protocol v2 client implementation in Ruby'
13
- spec.description = '3M™ Standard Interchange Protocol v2 client implementation in Ruby'
14
- spec.homepage = 'https://github.com/Studiosity/sip2-ruby'
15
- spec.license = 'MIT'
16
-
17
- spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(spec)/}) }
18
- spec.require_paths = ['lib']
19
-
20
- spec.required_ruby_version = '>= 2.1.0'
21
-
22
- spec.add_development_dependency 'bundler', '>= 1.11'
23
- spec.add_development_dependency 'rake', '>= 10.0'
24
- spec.add_development_dependency 'rspec', '~> 3.0'
25
- spec.add_development_dependency 'rubocop'
26
- spec.add_development_dependency 'timecop', '~> 0'
27
- end