lz4-ruby 0.3.1-java → 0.3.2-java
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.rdoc +9 -5
- data/Rakefile +2 -0
- data/VERSION +1 -1
- data/lib/lz4-ruby.rb +23 -20
- data/lib/lz4ruby.jar +0 -0
- data/spec/lz4_compressHC_spec.rb +26 -15
- data/spec/lz4_compress_spec.rb +23 -12
- data/spec/lz4_raw_compress_spec.rb +1 -1
- data/spec/lz4_raw_decompress_spec.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 46342a69f114dbe815b41b9c16e576ccba9d3e54
|
4
|
+
data.tar.gz: b5d4f6518cb521d7a20686518cca2056d62d866e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f15c4c7f11535570d7d3cb2d07d4fca537e7e6f123985648a43e9be26fca26fb5385192a5df2a3e25702f4e14466e6415cc57eafff145c84413d38339c4a0083
|
7
|
+
data.tar.gz: 4649de937928772cf82a390643af99dff4a48c91a691addc03e09784e05d2b843551c6b1dba46918c83c07c363a6bb9f54b5f19abb1de06066c026d5049dcc22
|
data/CHANGELOG.rdoc
CHANGED
@@ -1,9 +1,13 @@
|
|
1
1
|
= ChangeLog
|
2
2
|
|
3
|
+
== 0.3.1
|
4
|
+
|
5
|
+
* Support raw data handling methods in JRuby
|
6
|
+
|
3
7
|
== 0.3.0
|
4
8
|
|
5
|
-
* Support raw data
|
6
|
-
*
|
7
|
-
*
|
8
|
-
*
|
9
|
-
* Rename
|
9
|
+
* Support raw data handling methods (but not worked in JRuby).
|
10
|
+
* LZ4.Raw.compress()
|
11
|
+
* LZ4.Raw.compressHC()
|
12
|
+
* LZ4.Raw.decompress()
|
13
|
+
* Rename LZ4.uncompress() to LZ4.decompress().
|
data/Rakefile
CHANGED
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.3.
|
1
|
+
0.3.2
|
data/lib/lz4-ruby.rb
CHANGED
@@ -17,15 +17,18 @@ class LZ4
|
|
17
17
|
return _compress(input, in_size, true)
|
18
18
|
end
|
19
19
|
|
20
|
-
def self.decompress(input, in_size = nil)
|
21
|
-
in_size = input.
|
20
|
+
def self.decompress(input, in_size = nil, encoding = nil)
|
21
|
+
in_size = input.bytesize if in_size == nil
|
22
22
|
out_size, varbyte_len = decode_varbyte(input)
|
23
23
|
|
24
24
|
if out_size < 0 || varbyte_len < 0
|
25
25
|
raise "Compressed data is maybe corrupted"
|
26
26
|
end
|
27
27
|
|
28
|
-
|
28
|
+
result = LZ4Internal::uncompress(input, in_size, varbyte_len, out_size)
|
29
|
+
result.force_encoding(encoding) if encoding != nil
|
30
|
+
|
31
|
+
return result
|
29
32
|
end
|
30
33
|
|
31
34
|
# @deprecated Use {#decompress} and will be removed.
|
@@ -35,7 +38,7 @@ class LZ4
|
|
35
38
|
|
36
39
|
private
|
37
40
|
def self._compress(input, in_size, high_compression)
|
38
|
-
in_size = input.
|
41
|
+
in_size = input.bytesize if in_size == nil
|
39
42
|
header = encode_varbyte(in_size)
|
40
43
|
|
41
44
|
if high_compression
|
@@ -66,7 +69,7 @@ class LZ4
|
|
66
69
|
|
67
70
|
private
|
68
71
|
def self.decode_varbyte(text)
|
69
|
-
len = [text.
|
72
|
+
len = [text.bytesize, 5].min
|
70
73
|
bytes = text[0, len].unpack("C*")
|
71
74
|
|
72
75
|
varbyte_len = 0
|
@@ -86,7 +89,7 @@ class LZ4
|
|
86
89
|
#
|
87
90
|
# @param [String] source string to be compressed
|
88
91
|
# @param [Hash] options
|
89
|
-
# @option options [Fixnum] :input_size
|
92
|
+
# @option options [Fixnum] :input_size byte size of source to compress (must be less than or equal to `source.bytesize`)
|
90
93
|
# @option options [String] :dest output buffer which will receive compressed string
|
91
94
|
# @option options [Fixnum] :max_output_size acceptable maximum output size
|
92
95
|
# @return [String, Fixnum] compressed string and its length.
|
@@ -98,7 +101,7 @@ class LZ4
|
|
98
101
|
#
|
99
102
|
# @param [String] source string to be compressed
|
100
103
|
# @param [Hash] options
|
101
|
-
# @option options [Fixnum] :input_size
|
104
|
+
# @option options [Fixnum] :input_size byte size of source to compress (must be less than or equal to `source.bytesize`)
|
102
105
|
# @option options [String] :dest output buffer which will receive compressed string
|
103
106
|
# @option options [Fixnum] :max_output_size acceptable maximum output size
|
104
107
|
# @return [String, Fixnum] compressed string and its length.
|
@@ -106,15 +109,15 @@ class LZ4
|
|
106
109
|
return _compress(source, true, options)
|
107
110
|
end
|
108
111
|
|
109
|
-
private
|
112
|
+
private
|
110
113
|
def self._compress(source, high_compression, options = {})
|
111
114
|
input_size = options[:input_size]
|
112
115
|
if input_size == nil
|
113
|
-
input_size = source.
|
116
|
+
input_size = source.bytesize
|
114
117
|
|
115
118
|
else
|
116
|
-
if source.
|
117
|
-
raise ArgumentError, "`:input_size` (#{input_size}) must be less than or equal `source.
|
119
|
+
if source.bytesize < input_size
|
120
|
+
raise ArgumentError, "`:input_size` (#{input_size}) must be less than or equal `source.bytesize` (#{source.bytesize})"
|
118
121
|
end
|
119
122
|
end
|
120
123
|
|
@@ -123,14 +126,14 @@ class LZ4
|
|
123
126
|
max_output_size = options[:max_output_size]
|
124
127
|
if max_output_size == nil
|
125
128
|
if dest != nil
|
126
|
-
max_output_size = dest.
|
129
|
+
max_output_size = dest.bytesize
|
127
130
|
else
|
128
131
|
max_output_size = input_size + (input_size / 255) + 16 if dest == nil
|
129
132
|
end
|
130
133
|
|
131
134
|
else
|
132
|
-
if dest != nil && dest.
|
133
|
-
raise ArgumentError, "`:dest` buffer size (#{dest.
|
135
|
+
if dest != nil && dest.bytesize < max_output_size
|
136
|
+
raise ArgumentError, "`:dest` buffer size (#{dest.bytesize}) must be greater than or equal `:max_output_size` (#{max_output_size})"
|
134
137
|
end
|
135
138
|
end
|
136
139
|
|
@@ -153,24 +156,24 @@ class LZ4
|
|
153
156
|
# @param [String] source
|
154
157
|
# @param [Fixnum] max_output_size
|
155
158
|
# @param [Hash] options
|
156
|
-
# @option options [Fixnum] :input_size
|
159
|
+
# @option options [Fixnum] :input_size byte size of source to decompress (must be less than or equal to `source.bytesize`)
|
157
160
|
# @option options [String] :dest output buffer which will receive decompressed string
|
158
161
|
# @return [String, Fixnum] decompressed string and its length.
|
159
162
|
def self.decompress(source, max_output_size, options = {})
|
160
163
|
input_size = options[:input_size]
|
161
164
|
if input_size == nil
|
162
|
-
input_size = source.
|
165
|
+
input_size = source.bytesize
|
163
166
|
|
164
167
|
else
|
165
|
-
if source.
|
166
|
-
raise ArgumentError, "`:input_size` (#{input_size}) must be less than or equal `source.
|
168
|
+
if source.bytesize < input_size
|
169
|
+
raise ArgumentError, "`:input_size` (#{input_size}) must be less than or equal `source.bytesize` (#{source.bytesize})"
|
167
170
|
end
|
168
171
|
end
|
169
172
|
|
170
173
|
dest = options[:dest]
|
171
174
|
|
172
|
-
if dest != nil && dest.
|
173
|
-
raise ArgumentError, "`:dest` buffer size (#{dest.
|
175
|
+
if dest != nil && dest.bytesize < max_output_size
|
176
|
+
raise ArgumentError, "`:dest` buffer size (#{dest.bytesize}) must be greater than or equal `max_output_size` (#{max_output_size})"
|
174
177
|
end
|
175
178
|
|
176
179
|
result = LZ4Internal.decompress_raw(source, input_size, dest, max_output_size)
|
data/lib/lz4ruby.jar
CHANGED
Binary file
|
data/spec/lz4_compressHC_spec.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
|
1
3
|
require './spec/helper'
|
2
4
|
|
3
5
|
describe "LZ4::compress" do
|
@@ -5,24 +7,24 @@ describe "LZ4::compress" do
|
|
5
7
|
|
6
8
|
context "give empty text" do
|
7
9
|
compressed = LZ4.compressHC("")
|
8
|
-
|
10
|
+
decompressed = LZ4.decompress(compressed)
|
9
11
|
|
10
|
-
it "should be able to
|
11
|
-
expect(
|
12
|
+
it "should be able to decompress" do
|
13
|
+
expect(decompressed).to eql("")
|
12
14
|
end
|
13
15
|
end
|
14
16
|
|
15
17
|
context "give long text" do
|
16
18
|
text = "a" * 131073
|
17
19
|
compressed = LZ4.compressHC(text)
|
18
|
-
|
20
|
+
decompressed = LZ4.decompress(compressed)
|
19
21
|
|
20
22
|
it "should be compressed length less than original text" do
|
21
|
-
expect(compressed.
|
23
|
+
expect(compressed.bytesize).to be < text.bytesize
|
22
24
|
end
|
23
25
|
|
24
|
-
it "should be able to
|
25
|
-
expect(
|
26
|
+
it "should be able to decompress" do
|
27
|
+
expect(decompressed).to eql(text)
|
26
28
|
end
|
27
29
|
end
|
28
30
|
|
@@ -32,12 +34,12 @@ describe "LZ4::compress" do
|
|
32
34
|
|
33
35
|
context "give text of #{len} \"a\"'s" do
|
34
36
|
compressed = LZ4.compressHC(text)
|
35
|
-
|
36
|
-
it "should be able to
|
37
|
-
expect(
|
37
|
+
decompressed = LZ4.decompress(compressed)
|
38
|
+
it "should be able to decompress" do
|
39
|
+
expect(decompressed).to eql(text)
|
38
40
|
end
|
39
41
|
end
|
40
|
-
end
|
42
|
+
end
|
41
43
|
|
42
44
|
LOOP_COUNT.times do |t|
|
43
45
|
len = t + 1
|
@@ -45,10 +47,19 @@ describe "LZ4::compress" do
|
|
45
47
|
|
46
48
|
context "give text of #{len} bytes" do
|
47
49
|
compressed = LZ4.compressHC(text)
|
48
|
-
|
49
|
-
it "should be able to
|
50
|
-
expect(
|
50
|
+
decompressed = LZ4.decompress(compressed)
|
51
|
+
it "should be able to decompress" do
|
52
|
+
expect(decompressed).to eql(text)
|
51
53
|
end
|
52
54
|
end
|
53
|
-
end
|
55
|
+
end
|
56
|
+
|
57
|
+
context "give UTF-8 text" do
|
58
|
+
text = "いろはにほへと"
|
59
|
+
compressed = LZ4.compressHC(text)
|
60
|
+
decompressed = LZ4.decompress(compressed, compressed.bytesize, "UTF-8")
|
61
|
+
it "should be able to decompress" do
|
62
|
+
expect(decompressed).to eql(text)
|
63
|
+
end
|
64
|
+
end
|
54
65
|
end
|
data/spec/lz4_compress_spec.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
|
1
3
|
require './spec/helper'
|
2
4
|
|
3
5
|
describe "LZ4::compress" do
|
@@ -5,24 +7,24 @@ describe "LZ4::compress" do
|
|
5
7
|
|
6
8
|
context "give empty text" do
|
7
9
|
compressed = LZ4.compress("")
|
8
|
-
|
10
|
+
decompressed = LZ4.decompress(compressed)
|
9
11
|
|
10
|
-
it "should be able to
|
11
|
-
expect(
|
12
|
+
it "should be able to decompress" do
|
13
|
+
expect(decompressed).to eql("")
|
12
14
|
end
|
13
15
|
end
|
14
16
|
|
15
17
|
context "give long text" do
|
16
18
|
text = "a" * 131073
|
17
19
|
compressed = LZ4.compress(text)
|
18
|
-
|
20
|
+
decompressed = LZ4.decompress(compressed)
|
19
21
|
|
20
22
|
it "should be compressed length less than original text" do
|
21
23
|
expect(compressed.size).to be < text.length
|
22
24
|
end
|
23
25
|
|
24
|
-
it "should be able to
|
25
|
-
expect(
|
26
|
+
it "should be able to decompress" do
|
27
|
+
expect(decompressed).to eql(text)
|
26
28
|
end
|
27
29
|
end
|
28
30
|
|
@@ -32,9 +34,9 @@ describe "LZ4::compress" do
|
|
32
34
|
|
33
35
|
context "give text of #{len} \"a\"'s" do
|
34
36
|
compressed = LZ4.compress(text)
|
35
|
-
|
36
|
-
it "should be able to
|
37
|
-
expect(
|
37
|
+
decompressed = LZ4.decompress(compressed)
|
38
|
+
it "should be able to decompress" do
|
39
|
+
expect(decompressed).to eql(text)
|
38
40
|
end
|
39
41
|
end
|
40
42
|
end
|
@@ -45,10 +47,19 @@ describe "LZ4::compress" do
|
|
45
47
|
|
46
48
|
context "give text of #{len} bytes" do
|
47
49
|
compressed = LZ4.compress(text)
|
48
|
-
|
49
|
-
it "should be able to
|
50
|
-
expect(
|
50
|
+
decompressed = LZ4.decompress(compressed)
|
51
|
+
it "should be able to decompress" do
|
52
|
+
expect(decompressed).to eql(text)
|
51
53
|
end
|
52
54
|
end
|
53
55
|
end
|
56
|
+
|
57
|
+
context "give UTF-8 text" do
|
58
|
+
text = "いろはにほへと"
|
59
|
+
compressed = LZ4.compress(text)
|
60
|
+
decompressed = LZ4.decompress(compressed, compressed.bytesize, "UTF-8")
|
61
|
+
it "should be able to decompress" do
|
62
|
+
expect(decompressed).to eql(text)
|
63
|
+
end
|
64
|
+
end
|
54
65
|
end
|
@@ -54,7 +54,7 @@ describe "LZ4::Raw::compress" do
|
|
54
54
|
it "should be thrown ArgumentError" do
|
55
55
|
expect {
|
56
56
|
compressed, size = LZ4::Raw.compress(text, :input_size => input_size)
|
57
|
-
}.to raise_error(ArgumentError, "`:input_size` (30) must be less than or equal `source.
|
57
|
+
}.to raise_error(ArgumentError, "`:input_size` (30) must be less than or equal `source.bytesize` (20)")
|
58
58
|
end
|
59
59
|
end
|
60
60
|
end
|
@@ -55,7 +55,7 @@ describe "LZ4::Raw.decompress" do
|
|
55
55
|
it "should be thrown ArgumentError" do
|
56
56
|
expect {
|
57
57
|
decompressed, size = LZ4::Raw.decompress(compressed.pack("C*"), 30, :input_size => input_size)
|
58
|
-
}.to raise_error ArgumentError, "`:input_size` (20) must be less than or equal `source.
|
58
|
+
}.to raise_error ArgumentError, "`:input_size` (20) must be less than or equal `source.bytesize` (#{compressed.length})"
|
59
59
|
end
|
60
60
|
end
|
61
61
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lz4-ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.2
|
5
5
|
platform: java
|
6
6
|
authors:
|
7
7
|
- KOMIYA Atsushi
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-05-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|
@@ -131,7 +131,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
131
131
|
requirements:
|
132
132
|
- - '>='
|
133
133
|
- !ruby/object:Gem::Version
|
134
|
-
version: '
|
134
|
+
version: '1.9'
|
135
135
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
136
136
|
requirements:
|
137
137
|
- - '>='
|