lz4-ruby 0.1.3 → 0.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.
- data/Rakefile +2 -2
- data/VERSION +1 -1
- data/ext/lz4ruby.c +8 -8
- data/lib/lz4-ruby.rb +6 -4
- data/lz4-ruby.gemspec +4 -4
- data/test/test_lz4-ruby.rb +20 -0
- metadata +5 -5
data/Rakefile
CHANGED
@@ -18,8 +18,8 @@ Jeweler::Tasks.new do |gem|
|
|
18
18
|
gem.name = "lz4-ruby"
|
19
19
|
gem.homepage = "http://github.com/komiya-atsushi/lz4-ruby"
|
20
20
|
gem.license = "MIT"
|
21
|
-
gem.summary = %Q{Ruby bindings for LZ4.}
|
22
|
-
gem.description = %Q{Ruby bindings for LZ4.}
|
21
|
+
gem.summary = %Q{Ruby bindings for LZ4 (Extremely Fast Compression algorithm).}
|
22
|
+
gem.description = %Q{Ruby bindings for LZ4. LZ4 is a very fast lossless compression algorithm.}
|
23
23
|
gem.email = "komiya.atsushi@gmail.com"
|
24
24
|
gem.authors = ["KOMIYA Atsushi"]
|
25
25
|
gem.extensions = "ext/extconf.rb"
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.4
|
data/ext/lz4ruby.c
CHANGED
@@ -52,7 +52,7 @@ static int decode_varbyte(const char *src, int len, int *value) {
|
|
52
52
|
return 5;
|
53
53
|
}
|
54
54
|
|
55
|
-
static VALUE compress(CompressFunc compressor, VALUE self, VALUE source) {
|
55
|
+
static VALUE compress(CompressFunc compressor, VALUE self, VALUE source, VALUE src_size_prm) {
|
56
56
|
const char *src_p = NULL;
|
57
57
|
char varbyte[5];
|
58
58
|
char *buf = NULL;
|
@@ -64,7 +64,7 @@ static VALUE compress(CompressFunc compressor, VALUE self, VALUE source) {
|
|
64
64
|
|
65
65
|
Check_Type(source, T_STRING);
|
66
66
|
src_p = RSTRING_PTR(source);
|
67
|
-
src_size =
|
67
|
+
src_size = NUM2INT(src_size_prm);
|
68
68
|
buf_size = LZ4_compressBound(src_size);
|
69
69
|
|
70
70
|
varbyte_len = encode_varbyte(src_size, varbyte);
|
@@ -80,12 +80,12 @@ static VALUE compress(CompressFunc compressor, VALUE self, VALUE source) {
|
|
80
80
|
return result;
|
81
81
|
}
|
82
82
|
|
83
|
-
static VALUE lz4_ruby_compress(VALUE self, VALUE source) {
|
84
|
-
return compress(LZ4_compress, self, source);
|
83
|
+
static VALUE lz4_ruby_compress(VALUE self, VALUE source, VALUE src_size) {
|
84
|
+
return compress(LZ4_compress, self, source, src_size);
|
85
85
|
}
|
86
86
|
|
87
|
-
static VALUE lz4_ruby_compressHC(VALUE self, VALUE source) {
|
88
|
-
return compress(LZ4_compressHC, self, source);
|
87
|
+
static VALUE lz4_ruby_compressHC(VALUE self, VALUE source, VALUE src_size) {
|
88
|
+
return compress(LZ4_compressHC, self, source, src_size);
|
89
89
|
}
|
90
90
|
|
91
91
|
static VALUE lz4_ruby_uncompress(VALUE self, VALUE source) {
|
@@ -117,8 +117,8 @@ static VALUE lz4_ruby_uncompress(VALUE self, VALUE source) {
|
|
117
117
|
void Init_lz4ruby(void) {
|
118
118
|
lz4 = rb_define_module("LZ4Native");
|
119
119
|
|
120
|
-
rb_define_module_function(lz4, "compress", lz4_ruby_compress,
|
121
|
-
rb_define_module_function(lz4, "compressHC", lz4_ruby_compressHC,
|
120
|
+
rb_define_module_function(lz4, "compress", lz4_ruby_compress, 2);
|
121
|
+
rb_define_module_function(lz4, "compressHC", lz4_ruby_compressHC, 2);
|
122
122
|
rb_define_module_function(lz4, "uncompress", lz4_ruby_uncompress, 1);
|
123
123
|
|
124
124
|
lz4_error = rb_define_class_under(lz4, "Error", rb_eStandardError);
|
data/lib/lz4-ruby.rb
CHANGED
@@ -1,12 +1,14 @@
|
|
1
1
|
require 'lz4ruby'
|
2
2
|
|
3
3
|
class LZ4
|
4
|
-
def self.compress(source)
|
5
|
-
|
4
|
+
def self.compress(source, src_size = nil)
|
5
|
+
src_size = source.length if src_size == nil
|
6
|
+
return LZ4Native::compress(source, src_size)
|
6
7
|
end
|
7
8
|
|
8
|
-
def self.compressHC(source)
|
9
|
-
|
9
|
+
def self.compressHC(source, src_size = nil)
|
10
|
+
src_size = source.length if src_size == nil
|
11
|
+
return LZ4Native::compressHC(source, src_size)
|
10
12
|
end
|
11
13
|
|
12
14
|
def self.uncompress(source)
|
data/lz4-ruby.gemspec
CHANGED
@@ -5,12 +5,12 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = "lz4-ruby"
|
8
|
-
s.version = "0.1.
|
8
|
+
s.version = "0.1.4"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["KOMIYA Atsushi"]
|
12
|
-
s.date = "2012-06-
|
13
|
-
s.description = "Ruby bindings for LZ4."
|
12
|
+
s.date = "2012-06-06"
|
13
|
+
s.description = "Ruby bindings for LZ4. LZ4 is a very fast lossless compression algorithm."
|
14
14
|
s.email = "komiya.atsushi@gmail.com"
|
15
15
|
s.extensions = ["ext/extconf.rb"]
|
16
16
|
s.extra_rdoc_files = [
|
@@ -40,7 +40,7 @@ Gem::Specification.new do |s|
|
|
40
40
|
s.licenses = ["MIT"]
|
41
41
|
s.require_paths = ["lib"]
|
42
42
|
s.rubygems_version = "1.8.23"
|
43
|
-
s.summary = "Ruby bindings for LZ4."
|
43
|
+
s.summary = "Ruby bindings for LZ4 (Extremely Fast Compression algorithm)."
|
44
44
|
|
45
45
|
if s.respond_to? :specification_version then
|
46
46
|
s.specification_version = 3
|
data/test/test_lz4-ruby.rb
CHANGED
@@ -33,6 +33,16 @@ class TestLz4Ruby < Test::Unit::TestCase
|
|
33
33
|
assert_equal(text, uncompressed)
|
34
34
|
end
|
35
35
|
end
|
36
|
+
|
37
|
+
text = "b" * LOOP_COUNT
|
38
|
+
LOOP_COUNT.times do |t|
|
39
|
+
len = t + 1
|
40
|
+
should "#{len} bytes substring of #{LOOP_COUNT} bytes \"b\"'s" do
|
41
|
+
compressed = LZ4::compress(text, len)
|
42
|
+
uncompressed = LZ4::uncompress(compressed)
|
43
|
+
assert_equal(text[0, len], uncompressed)
|
44
|
+
end
|
45
|
+
end
|
36
46
|
end
|
37
47
|
|
38
48
|
context "LZ4::compressHC" do
|
@@ -63,5 +73,15 @@ class TestLz4Ruby < Test::Unit::TestCase
|
|
63
73
|
assert_equal(text, uncompressed)
|
64
74
|
end
|
65
75
|
end
|
76
|
+
|
77
|
+
text = "b" * LOOP_COUNT
|
78
|
+
LOOP_COUNT.times do |t|
|
79
|
+
len = t + 1
|
80
|
+
should "#{len} bytes substring of #{LOOP_COUNT} bytes \"b\"'s" do
|
81
|
+
compressed = LZ4::compressHC(text, len)
|
82
|
+
uncompressed = LZ4::uncompress(compressed)
|
83
|
+
assert_equal(text[0, len], uncompressed)
|
84
|
+
end
|
85
|
+
end
|
66
86
|
end
|
67
87
|
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.1.
|
4
|
+
version: 0.1.4
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-06-
|
12
|
+
date: 2012-06-06 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: shoulda
|
@@ -75,7 +75,7 @@ dependencies:
|
|
75
75
|
- - ~>
|
76
76
|
- !ruby/object:Gem::Version
|
77
77
|
version: 1.8.3
|
78
|
-
description: Ruby bindings for LZ4.
|
78
|
+
description: Ruby bindings for LZ4. LZ4 is a very fast lossless compression algorithm.
|
79
79
|
email: komiya.atsushi@gmail.com
|
80
80
|
executables: []
|
81
81
|
extensions:
|
@@ -116,7 +116,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
116
116
|
version: '0'
|
117
117
|
segments:
|
118
118
|
- 0
|
119
|
-
hash:
|
119
|
+
hash: 70067389
|
120
120
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
121
121
|
none: false
|
122
122
|
requirements:
|
@@ -128,5 +128,5 @@ rubyforge_project:
|
|
128
128
|
rubygems_version: 1.8.23
|
129
129
|
signing_key:
|
130
130
|
specification_version: 3
|
131
|
-
summary: Ruby bindings for LZ4.
|
131
|
+
summary: Ruby bindings for LZ4 (Extremely Fast Compression algorithm).
|
132
132
|
test_files: []
|