ruby-zstds 1.0.1 → 1.0.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +90 -159
- data/ext/extconf.rb +13 -0
- data/ext/zstds_ext/common.h +3 -0
- data/ext/zstds_ext/dictionary.c +1 -4
- data/ext/zstds_ext/error.c +0 -1
- data/ext/zstds_ext/io.c +37 -40
- data/ext/zstds_ext/main.c +0 -1
- data/ext/zstds_ext/option.c +0 -4
- data/ext/zstds_ext/option.h +3 -5
- data/ext/zstds_ext/stream/compressor.c +6 -9
- data/ext/zstds_ext/stream/compressor.h +6 -7
- data/ext/zstds_ext/stream/decompressor.c +6 -9
- data/ext/zstds_ext/stream/decompressor.h +6 -7
- data/ext/zstds_ext/string.c +2 -5
- data/lib/zstds/file.rb +4 -0
- data/lib/zstds/option.rb +2 -3
- data/lib/zstds/stream/abstract.rb +9 -12
- data/lib/zstds/stream/raw/abstract.rb +6 -2
- data/lib/zstds/stream/raw/compressor.rb +5 -7
- data/lib/zstds/stream/raw/decompressor.rb +1 -5
- data/lib/zstds/stream/reader.rb +71 -52
- data/lib/zstds/stream/reader_helpers.rb +2 -0
- data/lib/zstds/stream/writer.rb +10 -5
- data/lib/zstds/stream/writer_helpers.rb +8 -10
- data/lib/zstds/validation.rb +15 -2
- data/lib/zstds/version.rb +1 -1
- metadata +41 -13
data/lib/zstds/stream/writer.rb
CHANGED
@@ -64,7 +64,7 @@ module ZSTDS
|
|
64
64
|
end
|
65
65
|
|
66
66
|
protected def write_remaining_buffer
|
67
|
-
return nil if @buffer.bytesize
|
67
|
+
return nil if @buffer.bytesize.zero?
|
68
68
|
|
69
69
|
@io.write @buffer
|
70
70
|
|
@@ -77,6 +77,11 @@ module ZSTDS
|
|
77
77
|
|
78
78
|
# -- asynchronous --
|
79
79
|
|
80
|
+
# IO write nonblock can raise wait writable error.
|
81
|
+
# After resolving this error user may provide same content again.
|
82
|
+
# It is not possible to revert accepted content after error.
|
83
|
+
# So we have to accept content after processing IO write nonblock.
|
84
|
+
# It means that first write nonblock won't call IO write nonblock.
|
80
85
|
def write_nonblock(object, *options)
|
81
86
|
return 0 unless write_remaining_buffer_nonblock(*options)
|
82
87
|
|
@@ -120,14 +125,14 @@ module ZSTDS
|
|
120
125
|
end
|
121
126
|
|
122
127
|
protected def write_remaining_buffer_nonblock(*options)
|
123
|
-
return true if @buffer.bytesize
|
128
|
+
return true if @buffer.bytesize.zero?
|
124
129
|
|
125
130
|
bytes_written = @io.write_nonblock @buffer, *options
|
126
|
-
return false if bytes_written
|
131
|
+
return false if bytes_written.zero?
|
127
132
|
|
128
133
|
@buffer = @buffer.byteslice bytes_written, @buffer.bytesize - bytes_written
|
129
134
|
|
130
|
-
@buffer.bytesize
|
135
|
+
@buffer.bytesize.zero?
|
131
136
|
end
|
132
137
|
|
133
138
|
protected def raw_nonblock_wrapper(method_name, *args)
|
@@ -137,7 +142,7 @@ module ZSTDS
|
|
137
142
|
# -- common --
|
138
143
|
|
139
144
|
protected def transcode(data)
|
140
|
-
data = data.encode @external_encoding,
|
145
|
+
data = data.encode @external_encoding, **@transcode_options unless @external_encoding.nil?
|
141
146
|
data
|
142
147
|
end
|
143
148
|
end
|
@@ -1,6 +1,8 @@
|
|
1
1
|
# Ruby bindings for zstd 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 ZSTDS
|
|
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
|
19
|
+
write field_separator unless field_separator.nil?
|
23
20
|
end
|
24
21
|
|
25
|
-
write
|
22
|
+
write record_separator unless record_separator.nil?
|
26
23
|
|
27
24
|
nil
|
28
25
|
end
|
@@ -34,9 +31,10 @@ module ZSTDS
|
|
34
31
|
end
|
35
32
|
|
36
33
|
def putc(object, encoding: ::Encoding::BINARY)
|
37
|
-
|
34
|
+
case object
|
35
|
+
when ::Numeric
|
38
36
|
write object.chr(encoding)
|
39
|
-
|
37
|
+
when ::String
|
40
38
|
write object[0]
|
41
39
|
else
|
42
40
|
raise ValidateError, "invalid object: \"#{object}\" for putc"
|
data/lib/zstds/validation.rb
CHANGED
@@ -5,6 +5,19 @@ require_relative "error"
|
|
5
5
|
|
6
6
|
module ZSTDS
|
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
|
@@ -14,7 +27,7 @@ module ZSTDS
|
|
14
27
|
end
|
15
28
|
|
16
29
|
def self.validate_positive_integer(value)
|
17
|
-
raise ValidateError, "invalid positive integer" unless value.is_a?(::Integer) && value
|
30
|
+
raise ValidateError, "invalid positive integer" unless value.is_a?(::Integer) && value.positive?
|
18
31
|
end
|
19
32
|
|
20
33
|
def self.validate_not_negative_integer(value)
|
@@ -30,7 +43,7 @@ module ZSTDS
|
|
30
43
|
end
|
31
44
|
|
32
45
|
def self.validate_io(value)
|
33
|
-
raise ValidateError, "invalid io" unless value.
|
46
|
+
raise ValidateError, "invalid io" unless IO_METHODS.all? { |method| value.respond_to? method }
|
34
47
|
end
|
35
48
|
|
36
49
|
def self.validate_array(value)
|
data/lib/zstds/version.rb
CHANGED
metadata
CHANGED
@@ -1,15 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ruby-zstds
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrew Aladjev
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-10-09 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
|
@@ -52,20 +66,34 @@ dependencies:
|
|
52
66
|
- - "~>"
|
53
67
|
- !ruby/object:Gem::Version
|
54
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'
|
55
83
|
- !ruby/object:Gem::Dependency
|
56
84
|
name: rake-compiler
|
57
85
|
requirement: !ruby/object:Gem::Requirement
|
58
86
|
requirements:
|
59
|
-
- - "
|
87
|
+
- - ">="
|
60
88
|
- !ruby/object:Gem::Version
|
61
|
-
version: '
|
89
|
+
version: '0'
|
62
90
|
type: :development
|
63
91
|
prerelease: false
|
64
92
|
version_requirements: !ruby/object:Gem::Requirement
|
65
93
|
requirements:
|
66
|
-
- - "
|
94
|
+
- - ">="
|
67
95
|
- !ruby/object:Gem::Version
|
68
|
-
version: '
|
96
|
+
version: '0'
|
69
97
|
- !ruby/object:Gem::Dependency
|
70
98
|
name: rubocop
|
71
99
|
requirement: !ruby/object:Gem::Requirement
|
@@ -95,19 +123,19 @@ dependencies:
|
|
95
123
|
- !ruby/object:Gem::Version
|
96
124
|
version: '1.5'
|
97
125
|
- !ruby/object:Gem::Dependency
|
98
|
-
name:
|
126
|
+
name: simplecov
|
99
127
|
requirement: !ruby/object:Gem::Requirement
|
100
128
|
requirements:
|
101
|
-
- - "
|
129
|
+
- - ">="
|
102
130
|
- !ruby/object:Gem::Version
|
103
|
-
version: '
|
131
|
+
version: '0'
|
104
132
|
type: :development
|
105
133
|
prerelease: false
|
106
134
|
version_requirements: !ruby/object:Gem::Requirement
|
107
135
|
requirements:
|
108
|
-
- - "
|
136
|
+
- - ">="
|
109
137
|
- !ruby/object:Gem::Version
|
110
|
-
version: '
|
138
|
+
version: '0'
|
111
139
|
description:
|
112
140
|
email: aladjev.andrew@gmail.com
|
113
141
|
executables: []
|
@@ -168,14 +196,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
168
196
|
requirements:
|
169
197
|
- - ">="
|
170
198
|
- !ruby/object:Gem::Version
|
171
|
-
version: '
|
199
|
+
version: '2.5'
|
172
200
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
173
201
|
requirements:
|
174
202
|
- - ">="
|
175
203
|
- !ruby/object:Gem::Version
|
176
204
|
version: '0'
|
177
205
|
requirements: []
|
178
|
-
rubygems_version: 3.
|
206
|
+
rubygems_version: 3.1.4
|
179
207
|
signing_key:
|
180
208
|
specification_version: 4
|
181
209
|
summary: Ruby bindings for zstd library.
|