ruby-lzws 1.1.3 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -13,13 +13,13 @@ module LZWS
13
13
  write object
14
14
  end
15
15
 
16
- def print(*objects)
16
+ def print(*objects, field_separator: $OUTPUT_FIELD_SEPARATOR, record_separator: $OUTPUT_RECORD_SEPARATOR)
17
17
  objects.each do |object|
18
18
  write object
19
- write $OUTPUT_FIELD_SEPARATOR unless $OUTPUT_FIELD_SEPARATOR.nil?
19
+ write field_separator unless field_separator.nil?
20
20
  end
21
21
 
22
- write $OUTPUT_RECORD_SEPARATOR unless $OUTPUT_RECORD_SEPARATOR.nil?
22
+ write record_separator unless record_separator.nil?
23
23
 
24
24
  nil
25
25
  end
@@ -31,9 +31,10 @@ module LZWS
31
31
  end
32
32
 
33
33
  def putc(object, encoding: ::Encoding::BINARY)
34
- if object.is_a? ::Numeric
34
+ case object
35
+ when ::Numeric
35
36
  write object.chr(encoding)
36
- elsif object.is_a? ::String
37
+ when ::String
37
38
  write object[0]
38
39
  else
39
40
  raise ValidateError, "invalid object: \"#{object}\" for putc"
@@ -5,12 +5,25 @@ require_relative "error"
5
5
 
6
6
  module LZWS
7
7
  module Validation
8
+ IO_METHODS = %i[
9
+ read
10
+ write
11
+ readpartial
12
+ read_nonblock
13
+ write_nonblock
14
+ eof?
15
+ flush
16
+ close
17
+ closed?
18
+ ]
19
+ .freeze
20
+
8
21
  def self.validate_bool(value)
9
22
  raise ValidateError, "invalid bool" unless value.is_a?(::TrueClass) || value.is_a?(::FalseClass)
10
23
  end
11
24
 
12
25
  def self.validate_positive_integer(value)
13
- raise ValidateError, "invalid positive integer" unless value.is_a?(::Integer) && value > 0
26
+ raise ValidateError, "invalid positive integer" unless value.is_a?(::Integer) && value.positive?
14
27
  end
15
28
 
16
29
  def self.validate_not_negative_integer(value)
@@ -22,7 +35,7 @@ module LZWS
22
35
  end
23
36
 
24
37
  def self.validate_io(value)
25
- raise ValidateError, "invalid io" unless value.is_a? ::IO
38
+ raise ValidateError, "invalid io" unless IO_METHODS.all? { |method| value.respond_to? method }
26
39
  end
27
40
 
28
41
  def self.validate_hash(value)
@@ -2,5 +2,5 @@
2
2
  # Copyright (c) 2019 AUTHORS, MIT License.
3
3
 
4
4
  module LZWS
5
- VERSION = "1.1.3".freeze
5
+ VERSION = "1.2.0".freeze
6
6
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby-lzws
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.3
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Aladjev
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-12-30 00:00:00.000000000 Z
11
+ date: 2020-10-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: codecov
@@ -44,14 +44,14 @@ dependencies:
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: '5.12'
47
+ version: '5.14'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: '5.12'
54
+ version: '5.14'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: ocg
57
57
  requirement: !ruby/object:Gem::Requirement
@@ -100,42 +100,28 @@ dependencies:
100
100
  requirements:
101
101
  - - "~>"
102
102
  - !ruby/object:Gem::Version
103
- version: '0.75'
103
+ version: '0.93'
104
104
  type: :development
105
105
  prerelease: false
106
106
  version_requirements: !ruby/object:Gem::Requirement
107
107
  requirements:
108
108
  - - "~>"
109
109
  - !ruby/object:Gem::Version
110
- version: '0.75'
110
+ version: '0.93'
111
111
  - !ruby/object:Gem::Dependency
112
112
  name: rubocop-performance
113
113
  requirement: !ruby/object:Gem::Requirement
114
114
  requirements:
115
115
  - - "~>"
116
116
  - !ruby/object:Gem::Version
117
- version: '1.5'
117
+ version: '1.8'
118
118
  type: :development
119
119
  prerelease: false
120
120
  version_requirements: !ruby/object:Gem::Requirement
121
121
  requirements:
122
122
  - - "~>"
123
123
  - !ruby/object:Gem::Version
124
- version: '1.5'
125
- - !ruby/object:Gem::Dependency
126
- name: rubocop-rails
127
- requirement: !ruby/object:Gem::Requirement
128
- requirements:
129
- - - "~>"
130
- - !ruby/object:Gem::Version
131
- version: '2.3'
132
- type: :development
133
- prerelease: false
134
- version_requirements: !ruby/object:Gem::Requirement
135
- requirements:
136
- - - "~>"
137
- - !ruby/object:Gem::Version
138
- version: '2.3'
124
+ version: '1.8'
139
125
  - !ruby/object:Gem::Dependency
140
126
  name: simplecov
141
127
  requirement: !ruby/object:Gem::Requirement
@@ -207,14 +193,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
207
193
  requirements:
208
194
  - - ">="
209
195
  - !ruby/object:Gem::Version
210
- version: '0'
196
+ version: '2.5'
211
197
  required_rubygems_version: !ruby/object:Gem::Requirement
212
198
  requirements:
213
199
  - - ">="
214
200
  - !ruby/object:Gem::Version
215
201
  version: '0'
216
202
  requirements: []
217
- rubygems_version: 3.0.6
203
+ rubygems_version: 3.1.4
218
204
  signing_key:
219
205
  specification_version: 4
220
206
  summary: Ruby bindings for lzws library.