ruby-lzws 1.0.0 → 1.1.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.
@@ -137,7 +137,7 @@ module LZWS
137
137
  # -- common --
138
138
 
139
139
  protected def transcode(data)
140
- data = data.encode @external_encoding, @transcode_options unless @external_encoding.nil?
140
+ data = data.encode @external_encoding, **@transcode_options unless @external_encoding.nil?
141
141
  data
142
142
  end
143
143
  end
@@ -1,6 +1,8 @@
1
1
  # Ruby bindings for lzws library.
2
2
  # Copyright (c) 2019 AUTHORS, MIT License.
3
3
 
4
+ require "English"
5
+
4
6
  require_relative "../error"
5
7
  require_relative "../validation"
6
8
 
@@ -11,18 +13,13 @@ module LZWS
11
13
  write object
12
14
  end
13
15
 
14
- def print(*objects)
15
- if objects.empty?
16
- write $LAST_READ_LINE unless $LAST_READ_LINE.nil?
17
- return nil
18
- end
19
-
16
+ def print(*objects, field_separator: $OUTPUT_FIELD_SEPARATOR, record_separator: $OUTPUT_RECORD_SEPARATOR)
20
17
  objects.each do |object|
21
18
  write object
22
- write $OUTPUT_FIELD_SEPARATOR unless $OUTPUT_FIELD_SEPARATOR.nil?
19
+ write field_separator unless field_separator.nil?
23
20
  end
24
21
 
25
- write $OUTPUT_RECORD_SEPARATOR unless $OUTPUT_RECORD_SEPARATOR.nil?
22
+ write record_separator unless record_separator.nil?
26
23
 
27
24
  nil
28
25
  end
@@ -73,8 +70,8 @@ module LZWS
73
70
  Validation.validate_string file_path
74
71
  Validation.validate_proc block
75
72
 
76
- ::File.open file_path, "wb" do |file|
77
- writer = new file, *args
73
+ ::File.open file_path, "wb" do |io|
74
+ writer = new io, *args
78
75
 
79
76
  begin
80
77
  yield writer
@@ -8,10 +8,12 @@ require_relative "validation"
8
8
 
9
9
  module LZWS
10
10
  module String
11
+ BUFFER_LENGTH_NAMES = %i[destination_buffer_length].freeze
12
+
11
13
  def self.compress(source, options = {})
12
14
  Validation.validate_string source
13
15
 
14
- options = Option.get_compressor_options options
16
+ options = Option.get_compressor_options options, BUFFER_LENGTH_NAMES
15
17
 
16
18
  LZWS._native_compress_string source, options
17
19
  end
@@ -19,7 +21,7 @@ module LZWS
19
21
  def self.decompress(source, options = {})
20
22
  Validation.validate_string source
21
23
 
22
- options = Option.get_decompressor_options options
24
+ options = Option.get_decompressor_options options, BUFFER_LENGTH_NAMES
23
25
 
24
26
  LZWS._native_decompress_string source, options
25
27
  end
@@ -5,6 +5,19 @@ 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
@@ -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.0.0".freeze
5
+ VERSION = "1.1.4".freeze
6
6
  end
metadata CHANGED
@@ -1,99 +1,155 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby-lzws
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.1.4
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-08-08 00:00:00.000000000 Z
11
+ date: 2020-06-27 00:00:00.000000000 Z
12
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: codecov
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
13
27
  - !ruby/object:Gem::Dependency
14
28
  name: minitar
15
29
  requirement: !ruby/object:Gem::Requirement
16
30
  requirements:
17
31
  - - "~>"
18
32
  - !ruby/object:Gem::Version
19
- version: '0.8'
33
+ version: '0.9'
20
34
  type: :development
21
35
  prerelease: false
22
36
  version_requirements: !ruby/object:Gem::Requirement
23
37
  requirements:
24
38
  - - "~>"
25
39
  - !ruby/object:Gem::Version
26
- version: '0.8'
40
+ version: '0.9'
27
41
  - !ruby/object:Gem::Dependency
28
42
  name: minitest
29
43
  requirement: !ruby/object:Gem::Requirement
30
44
  requirements:
31
45
  - - "~>"
32
46
  - !ruby/object:Gem::Version
33
- version: '5.11'
47
+ version: '5.12'
34
48
  type: :development
35
49
  prerelease: false
36
50
  version_requirements: !ruby/object:Gem::Requirement
37
51
  requirements:
38
52
  - - "~>"
39
53
  - !ruby/object:Gem::Version
40
- version: '5.11'
54
+ version: '5.12'
41
55
  - !ruby/object:Gem::Dependency
42
- name: rake-compiler
56
+ name: ocg
43
57
  requirement: !ruby/object:Gem::Requirement
44
58
  requirements:
45
59
  - - "~>"
46
60
  - !ruby/object:Gem::Version
47
- version: '1.0'
61
+ version: '1.1'
48
62
  type: :development
49
63
  prerelease: false
50
64
  version_requirements: !ruby/object:Gem::Requirement
51
65
  requirements:
52
66
  - - "~>"
53
67
  - !ruby/object:Gem::Version
54
- version: '1.0'
68
+ version: '1.1'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rake
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: rake-compiler
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
55
97
  - !ruby/object:Gem::Dependency
56
98
  name: rubocop
57
99
  requirement: !ruby/object:Gem::Requirement
58
100
  requirements:
59
101
  - - "~>"
60
102
  - !ruby/object:Gem::Version
61
- version: '0.74'
103
+ version: '0.75'
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.74'
110
+ version: '0.75'
69
111
  - !ruby/object:Gem::Dependency
70
112
  name: rubocop-performance
71
113
  requirement: !ruby/object:Gem::Requirement
72
114
  requirements:
73
115
  - - "~>"
74
116
  - !ruby/object:Gem::Version
75
- version: '1.4'
117
+ version: '1.5'
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: '1.4'
124
+ version: '1.5'
83
125
  - !ruby/object:Gem::Dependency
84
126
  name: rubocop-rails
85
127
  requirement: !ruby/object:Gem::Requirement
86
128
  requirements:
87
129
  - - "~>"
88
130
  - !ruby/object:Gem::Version
89
- version: '2.2'
131
+ version: '2.3'
90
132
  type: :development
91
133
  prerelease: false
92
134
  version_requirements: !ruby/object:Gem::Requirement
93
135
  requirements:
94
136
  - - "~>"
95
137
  - !ruby/object:Gem::Version
96
- version: '2.2'
138
+ version: '2.3'
139
+ - !ruby/object:Gem::Dependency
140
+ name: simplecov
141
+ requirement: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - ">="
144
+ - !ruby/object:Gem::Version
145
+ version: '0'
146
+ type: :development
147
+ prerelease: false
148
+ version_requirements: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - ">="
151
+ - !ruby/object:Gem::Version
152
+ version: '0'
97
153
  description:
98
154
  email: aladjev.andrew@gmail.com
99
155
  executables: []
@@ -105,6 +161,8 @@ files:
105
161
  - LICENSE
106
162
  - README.md
107
163
  - ext/extconf.rb
164
+ - ext/lzws_ext/buffer.c
165
+ - ext/lzws_ext/buffer.h
108
166
  - ext/lzws_ext/common.h
109
167
  - ext/lzws_ext/error.c
110
168
  - ext/lzws_ext/error.h
@@ -156,7 +214,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
156
214
  - !ruby/object:Gem::Version
157
215
  version: '0'
158
216
  requirements: []
159
- rubygems_version: 3.0.3
217
+ rubygems_version: 3.1.2
160
218
  signing_key:
161
219
  specification_version: 4
162
220
  summary: Ruby bindings for lzws library.