snappy 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/ext/api.cc +43 -19
- data/ext/extconf.rb +8 -3
- data/snappy.gemspec +7 -7
- metadata +13 -15
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.3
|
data/ext/api.cc
CHANGED
@@ -2,44 +2,68 @@
|
|
2
2
|
#include "snappy.h"
|
3
3
|
|
4
4
|
static VALUE rb_mSnappy;
|
5
|
-
static
|
5
|
+
static VALUE rb_eSnappy;
|
6
6
|
|
7
7
|
static VALUE
|
8
|
-
snappy_deflate(VALUE
|
8
|
+
snappy_deflate(int argc, VALUE *argv, VALUE self)
|
9
9
|
{
|
10
|
-
|
10
|
+
VALUE src, dst;
|
11
11
|
size_t output_length;
|
12
12
|
|
13
|
-
|
14
|
-
|
13
|
+
rb_scan_args(argc, argv, "11", &src, &dst);
|
14
|
+
StringValue(src);
|
15
15
|
|
16
|
-
|
16
|
+
output_length = snappy::MaxCompressedLength(RSTRING_LEN(src));
|
17
|
+
|
18
|
+
if (NIL_P(dst)) {
|
19
|
+
dst = rb_str_new(NULL, output_length);
|
20
|
+
} else {
|
21
|
+
StringValue(dst);
|
22
|
+
rb_str_resize(dst, output_length);
|
23
|
+
}
|
24
|
+
|
25
|
+
snappy::RawCompress(RSTRING_PTR(src), RSTRING_LEN(src), RSTRING_PTR(dst), &output_length);
|
26
|
+
rb_str_resize(dst, output_length);
|
27
|
+
|
28
|
+
return dst;
|
17
29
|
}
|
18
30
|
|
19
31
|
static VALUE
|
20
|
-
snappy_inflate(VALUE
|
32
|
+
snappy_inflate(int argc, VALUE *argv, VALUE self)
|
21
33
|
{
|
22
|
-
|
34
|
+
VALUE src, dst;
|
35
|
+
size_t output_length;
|
36
|
+
|
37
|
+
rb_scan_args(argc, argv, "11", &src, &dst);
|
38
|
+
StringValue(src);
|
23
39
|
|
24
|
-
|
25
|
-
|
26
|
-
!snappy::Uncompress(RSTRING_PTR(source), RSTRING_LEN(source), &output)) {
|
27
|
-
rb_raise(rb_eRuntimeError, "Couldn't inflate");
|
40
|
+
if (!snappy::GetUncompressedLength(RSTRING_PTR(src), RSTRING_LEN(src), &output_length)) {
|
41
|
+
rb_raise(rb_eSnappy, "snappy::GetUncompressedLength");
|
28
42
|
}
|
29
43
|
|
30
|
-
|
44
|
+
if (NIL_P(dst)) {
|
45
|
+
dst = rb_str_new(NULL, output_length);
|
46
|
+
} else {
|
47
|
+
StringValue(dst);
|
48
|
+
rb_str_resize(dst, output_length);
|
49
|
+
}
|
50
|
+
|
51
|
+
if (!snappy::RawUncompress(RSTRING_PTR(src), RSTRING_LEN(src), RSTRING_PTR(dst))) {
|
52
|
+
rb_raise(rb_eSnappy, "snappy::RawUncompress");
|
53
|
+
}
|
54
|
+
|
55
|
+
return dst;
|
31
56
|
}
|
32
57
|
|
33
58
|
extern "C" {
|
34
59
|
void Init_snappy()
|
35
60
|
{
|
36
61
|
rb_mSnappy = rb_define_module("Snappy");
|
37
|
-
|
38
|
-
rb_define_singleton_method(rb_mSnappy, "
|
39
|
-
|
40
|
-
rb_define_singleton_method(rb_mSnappy, "compress", (VALUE (*)(...))snappy_deflate, 1);
|
41
|
-
rb_define_singleton_method(rb_mSnappy, "uncompress", (VALUE (*)(...))snappy_inflate, 1);
|
62
|
+
rb_eSnappy = rb_define_class_under(rb_mSnappy, "Error", rb_eStandardError);
|
63
|
+
rb_define_singleton_method(rb_mSnappy, "deflate", (VALUE (*)(...))snappy_deflate, -1);
|
64
|
+
rb_define_singleton_method(rb_mSnappy, "inflate", (VALUE (*)(...))snappy_inflate, -1);
|
42
65
|
|
43
|
-
|
66
|
+
rb_define_singleton_method(rb_mSnappy, "compress", (VALUE (*)(...))snappy_deflate, -1);
|
67
|
+
rb_define_singleton_method(rb_mSnappy, "uncompress", (VALUE (*)(...))snappy_inflate, -1);
|
44
68
|
}
|
45
69
|
}
|
data/ext/extconf.rb
CHANGED
@@ -20,11 +20,14 @@ def try_configure
|
|
20
20
|
have_header 'stdlib.h'
|
21
21
|
have_header 'strings.h'
|
22
22
|
have_header 'string.h'
|
23
|
+
have_header 'sys/byteswap.h'
|
24
|
+
have_header 'sys/endian.h'
|
23
25
|
have_header 'sys/mman.h'
|
26
|
+
have_header 'sys/resource.h'
|
24
27
|
have_header 'sys/stat.h'
|
25
28
|
have_header 'sys/types.h'
|
26
|
-
have_header 'sys/resource.h'
|
27
29
|
have_header 'unistd.h'
|
30
|
+
have_header 'windows.h'
|
28
31
|
|
29
32
|
if try_run 'int main(int argc, char** argv){ int i = 1; return *((char*)&i); }'
|
30
33
|
$defs << '-DWORDS_BIGENDIAN'
|
@@ -37,7 +40,7 @@ unless have_library 'snappy'
|
|
37
40
|
tar = 'tar'
|
38
41
|
tar = 'gnutar' if find_executable 'gnutar'
|
39
42
|
|
40
|
-
ver = "1.0.
|
43
|
+
ver = "1.0.4"
|
41
44
|
src = "snappy-#{ver}"
|
42
45
|
|
43
46
|
FileUtils.rm_rf File.join dst, src
|
@@ -51,6 +54,8 @@ unless have_library 'snappy'
|
|
51
54
|
|
52
55
|
%w(
|
53
56
|
config.h
|
57
|
+
snappy-c.cc
|
58
|
+
snappy-c.h
|
54
59
|
snappy-internal.h
|
55
60
|
snappy-sinksource.cc
|
56
61
|
snappy-sinksource.h
|
@@ -68,7 +73,7 @@ snappy.h
|
|
68
73
|
%r'#if @ac_cv_have_stddef_h@' => '#ifdef HAVE_STDDEF_H',
|
69
74
|
%r'@SNAPPY_MAJOR@' => '1',
|
70
75
|
%r'@SNAPPY_MINOR@' => '0',
|
71
|
-
%r'@SNAPPY_PATCHLEVEL@' => '
|
76
|
+
%r'@SNAPPY_PATCHLEVEL@' => '4',
|
72
77
|
}.each { |ptn, str| hdr.gsub! ptn, str }
|
73
78
|
File.open(File.join(dst, 'snappy-stubs-public.h'), 'wb'){ |f| f.write hdr }
|
74
79
|
|
data/snappy.gemspec
CHANGED
@@ -5,14 +5,14 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{snappy}
|
8
|
-
s.version = "0.0.
|
8
|
+
s.version = "0.0.3"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
-
s.authors = [
|
12
|
-
s.date = %q{2011-
|
11
|
+
s.authors = [%q{miyucy}]
|
12
|
+
s.date = %q{2011-10-13}
|
13
13
|
s.description = %q{libsnappy binding for Ruby}
|
14
14
|
s.email = %q{miyucy@gmail.com}
|
15
|
-
s.extensions = [
|
15
|
+
s.extensions = [%q{ext/extconf.rb}]
|
16
16
|
s.extra_rdoc_files = [
|
17
17
|
"LICENSE.txt",
|
18
18
|
"README.rdoc"
|
@@ -33,9 +33,9 @@ Gem::Specification.new do |s|
|
|
33
33
|
"spec/spec_helper.rb"
|
34
34
|
]
|
35
35
|
s.homepage = %q{http://github.com/miyucy/snappy}
|
36
|
-
s.licenses = [
|
37
|
-
s.require_paths = [
|
38
|
-
s.rubygems_version = %q{1.
|
36
|
+
s.licenses = [%q{MIT}]
|
37
|
+
s.require_paths = [%q{lib}]
|
38
|
+
s.rubygems_version = %q{1.8.9}
|
39
39
|
s.summary = %q{libsnappy binding for Ruby}
|
40
40
|
s.test_files = [
|
41
41
|
"spec/snappy_spec.rb",
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: snappy
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 25
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 3
|
10
|
+
version: 0.0.3
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- miyucy
|
@@ -15,8 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-
|
19
|
-
default_executable:
|
18
|
+
date: 2011-10-13 00:00:00 Z
|
20
19
|
dependencies:
|
21
20
|
- !ruby/object:Gem::Dependency
|
22
21
|
version_requirements: &id001 !ruby/object:Gem::Requirement
|
@@ -30,9 +29,9 @@ dependencies:
|
|
30
29
|
- 3
|
31
30
|
- 0
|
32
31
|
version: 2.3.0
|
33
|
-
prerelease: false
|
34
|
-
type: :development
|
35
32
|
requirement: *id001
|
33
|
+
type: :development
|
34
|
+
prerelease: false
|
36
35
|
name: rspec
|
37
36
|
- !ruby/object:Gem::Dependency
|
38
37
|
version_requirements: &id002 !ruby/object:Gem::Requirement
|
@@ -46,9 +45,9 @@ dependencies:
|
|
46
45
|
- 0
|
47
46
|
- 0
|
48
47
|
version: 1.0.0
|
49
|
-
prerelease: false
|
50
|
-
type: :development
|
51
48
|
requirement: *id002
|
49
|
+
type: :development
|
50
|
+
prerelease: false
|
52
51
|
name: bundler
|
53
52
|
- !ruby/object:Gem::Dependency
|
54
53
|
version_requirements: &id003 !ruby/object:Gem::Requirement
|
@@ -62,9 +61,9 @@ dependencies:
|
|
62
61
|
- 5
|
63
62
|
- 2
|
64
63
|
version: 1.5.2
|
65
|
-
prerelease: false
|
66
|
-
type: :development
|
67
64
|
requirement: *id003
|
65
|
+
type: :development
|
66
|
+
prerelease: false
|
68
67
|
name: jeweler
|
69
68
|
- !ruby/object:Gem::Dependency
|
70
69
|
version_requirements: &id004 !ruby/object:Gem::Requirement
|
@@ -76,9 +75,9 @@ dependencies:
|
|
76
75
|
segments:
|
77
76
|
- 0
|
78
77
|
version: "0"
|
79
|
-
prerelease: false
|
80
|
-
type: :development
|
81
78
|
requirement: *id004
|
79
|
+
type: :development
|
80
|
+
prerelease: false
|
82
81
|
name: rcov
|
83
82
|
description: libsnappy binding for Ruby
|
84
83
|
email: miyucy@gmail.com
|
@@ -103,7 +102,6 @@ files:
|
|
103
102
|
- snappy.gemspec
|
104
103
|
- spec/snappy_spec.rb
|
105
104
|
- spec/spec_helper.rb
|
106
|
-
has_rdoc: true
|
107
105
|
homepage: http://github.com/miyucy/snappy
|
108
106
|
licenses:
|
109
107
|
- MIT
|
@@ -133,7 +131,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
133
131
|
requirements: []
|
134
132
|
|
135
133
|
rubyforge_project:
|
136
|
-
rubygems_version: 1.
|
134
|
+
rubygems_version: 1.8.9
|
137
135
|
signing_key:
|
138
136
|
specification_version: 3
|
139
137
|
summary: libsnappy binding for Ruby
|