lz4-ruby 0.3.1-x86-mingw32 → 0.3.2-x86-mingw32

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA512:
3
- metadata.gz: b7c8c4031ace9a7f264e898dc540b46b5edbbd4cc8a9a9b5a94fa9c6315f66ab9a2f9e0a36625926f3cce0cf1a30cc930584a6ec38977f3f5b4e254db3a7360b
4
- data.tar.gz: 29b2866d4403c1063aac1df854a61df93017d8d401df4172b6658e4c1d4e6ba1a77c328c9f6b9e85e2f5bbd7af6a042bd5ad1afc8d8b156a1a592c552b527bb8
5
2
  SHA1:
6
- metadata.gz: 66d782a5410a36a003d0dcecd58cde8a266aa839
7
- data.tar.gz: 6cae50481f8df11d006d051b5ee46082db5ee6c6
3
+ data.tar.gz: ae57034ee26f014d90674e7123ce29aaa9c6f203
4
+ metadata.gz: 24241cb6aae911d4417cf25f9da0244850cacab9
5
+ SHA512:
6
+ data.tar.gz: e38ca811d78b40ad6c2eda4003d7238e4a24f99995aa582a2574c279f99d06fb2e48fcebb1e56264c8858d566d2dcae5ea15504dd794bf6d659a7d0e60ebd548
7
+ metadata.gz: 16b2b3f4990285e807ad742123844db6faa601b8227fef9cba77a30d75e50c7f71b9b7e4e82ade61f49553639a098acd47492f12e1f105e1ab221cad43857ab1
@@ -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 stream handling methods (but not worked in JRuby).
6
- * +LZ4.Raw.compress()+
7
- * +LZ4.Raw.compressHC()+
8
- * +LZ4.Raw.decompress()+
9
- * Rename +LZ4.uncompress()+ to +LZ4.decompress()+ .
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
@@ -28,6 +28,8 @@ jeweler_tasks = Jeweler::Tasks.new do |gem|
28
28
 
29
29
  gem.files.include("ext/lz4ruby/*.c")
30
30
  gem.files.include("ext/lz4ruby/*.h")
31
+
32
+ gem.required_ruby_version = '>= 1.9'
31
33
 
32
34
  # dependencies defined in Gemfile
33
35
  end
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.3.1
1
+ 0.3.2
Binary file
Binary file
@@ -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.length if in_size == nil
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
- return LZ4Internal::uncompress(input, in_size, varbyte_len, out_size)
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.length if in_size == nil
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.length, 5].min
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 length of source to compress (must be less than or equal to `source.length`)
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 length of source to compress (must be less than or equal to `source.length`)
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.length
116
+ input_size = source.bytesize
114
117
 
115
118
  else
116
- if source.length < input_size
117
- raise ArgumentError, "`:input_size` (#{input_size}) must be less than or equal `source.length` (#{source.length})"
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.length
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.length < max_output_size
133
- raise ArgumentError, "`:dest` buffer size (#{dest.length}) must be greater than or equal `:max_output_size` (#{max_output_size})"
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 length of source to decompress (must be less than or equal to `source.length`)
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.length
165
+ input_size = source.bytesize
163
166
 
164
167
  else
165
- if source.length < input_size
166
- raise ArgumentError, "`:input_size` (#{input_size}) must be less than or equal `source.length` (#{source.length})"
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.length < max_output_size
173
- raise ArgumentError, "`:dest` buffer size (#{dest.length}) must be greater than or equal `max_output_size` (#{max_output_size})"
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)
@@ -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
- uncompressed = LZ4.uncompress(compressed)
10
+ decompressed = LZ4.decompress(compressed)
9
11
 
10
- it "should be able to uncompress" do
11
- expect(uncompressed).to eql("")
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
- uncompressed = LZ4.uncompress(compressed)
20
+ decompressed = LZ4.decompress(compressed)
19
21
 
20
22
  it "should be compressed length less than original text" do
21
- expect(compressed.size).to be < text.length
23
+ expect(compressed.bytesize).to be < text.bytesize
22
24
  end
23
25
 
24
- it "should be able to uncompress" do
25
- expect(uncompressed).to eql(text)
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
- uncompressed = LZ4.uncompress(compressed)
36
- it "should be able to uncompress" do
37
- expect(uncompressed).to eql(text)
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
- uncompressed = LZ4.uncompress(compressed)
49
- it "should be able to uncompress" do
50
- expect(uncompressed).to eql(text)
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
@@ -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
- uncompressed = LZ4.uncompress(compressed)
10
+ decompressed = LZ4.decompress(compressed)
9
11
 
10
- it "should be able to uncompress" do
11
- expect(uncompressed).to eql("")
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
- uncompressed = LZ4.uncompress(compressed)
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 uncompress" do
25
- expect(uncompressed).to eql(text)
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
- uncompressed = LZ4.uncompress(compressed)
36
- it "should be able to uncompress" do
37
- expect(uncompressed).to eql(text)
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
- uncompressed = LZ4.uncompress(compressed)
49
- it "should be able to uncompress" do
50
- expect(uncompressed).to eql(text)
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.length` (20)")
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.length` (#{compressed.length})"
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,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lz4-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.3.2
5
5
  platform: x86-mingw32
6
6
  authors:
7
7
  - KOMIYA Atsushi
@@ -9,55 +9,55 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2014-04-30 00:00:00 Z
12
+ date: 2014-05-22 00:00:00 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rspec
16
- version_requirements: &id001 !ruby/object:Gem::Requirement
16
+ prerelease: false
17
+ requirement: &id001 !ruby/object:Gem::Requirement
17
18
  requirements:
18
19
  - &id003
19
20
  - ">="
20
21
  - !ruby/object:Gem::Version
21
22
  version: "0"
22
- prerelease: false
23
- requirement: *id001
24
23
  type: :development
24
+ version_requirements: *id001
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: rdoc
27
- version_requirements: &id002 !ruby/object:Gem::Requirement
27
+ prerelease: false
28
+ requirement: &id002 !ruby/object:Gem::Requirement
28
29
  requirements:
29
30
  - - ~>
30
31
  - !ruby/object:Gem::Version
31
32
  version: "3.12"
32
- prerelease: false
33
- requirement: *id002
34
33
  type: :development
34
+ version_requirements: *id002
35
35
  - !ruby/object:Gem::Dependency
36
36
  name: bundler
37
- version_requirements: &id004 !ruby/object:Gem::Requirement
37
+ prerelease: false
38
+ requirement: &id004 !ruby/object:Gem::Requirement
38
39
  requirements:
39
40
  - *id003
40
- prerelease: false
41
- requirement: *id004
42
41
  type: :development
42
+ version_requirements: *id004
43
43
  - !ruby/object:Gem::Dependency
44
44
  name: jeweler
45
- version_requirements: &id005 !ruby/object:Gem::Requirement
45
+ prerelease: false
46
+ requirement: &id005 !ruby/object:Gem::Requirement
46
47
  requirements:
47
48
  - - ~>
48
49
  - !ruby/object:Gem::Version
49
50
  version: 1.8.3
50
- prerelease: false
51
- requirement: *id005
52
51
  type: :development
52
+ version_requirements: *id005
53
53
  - !ruby/object:Gem::Dependency
54
54
  name: rake-compiler
55
- version_requirements: &id006 !ruby/object:Gem::Requirement
55
+ prerelease: false
56
+ requirement: &id006 !ruby/object:Gem::Requirement
56
57
  requirements:
57
58
  - *id003
58
- prerelease: false
59
- requirement: *id006
60
59
  type: :development
60
+ version_requirements: *id006
61
61
  description: Ruby bindings for LZ4. LZ4 is a very fast lossless compression algorithm.
62
62
  email: komiya.atsushi@gmail.com
63
63
  executables: []
@@ -112,7 +112,9 @@ require_paths:
112
112
  - lib
113
113
  required_ruby_version: !ruby/object:Gem::Requirement
114
114
  requirements:
115
- - *id003
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ version: "1.9"
116
118
  required_rubygems_version: !ruby/object:Gem::Requirement
117
119
  requirements:
118
120
  - *id003