snappy 0.0.8 → 0.0.9
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.
- checksums.yaml +6 -14
- data/.gitignore +7 -0
- data/Gemfile +1 -1
- data/Rakefile +59 -14
- data/ext/api.c +2 -5
- data/ext/extconf.rb +2 -2
- data/ext/java/src/SnappyExtService.java +18 -0
- data/ext/java/src/snappy/SnappyModule.java +32 -0
- data/lib/snappy.rb +6 -0
- data/lib/snappy/version.rb +1 -1
- data/snappy.gemspec +8 -1
- metadata +12 -9
checksums.yaml
CHANGED
@@ -1,15 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
metadata.gz: !binary |-
|
9
|
-
MWViMjZmOWIxNTFjMDk0MjQyZTE0MWJmM2EwMzc2NTEzYWNhM2Q4M2Y5NzI0
|
10
|
-
NWU5YzFiZmM0ZTA4ZWVhNDRhMTBkZmJmNjQwZjQ3MWE2MTBhYTJlYWY4ZDhh
|
11
|
-
NzM1OGU2MDQxZDQwZmE1YjZjZDY0NzJkNTExNzAwOTU3YzMzMzQ=
|
12
|
-
data.tar.gz: !binary |-
|
13
|
-
ZThjMmIwYzBhNTM3YjU0ZDNiMWE0N2I4YzYzNThkNmRhYzk1ZWEwZmRmODRk
|
14
|
-
NzI0OTZjODMwYjMzYTM2YjYyNmFmOGU0NGRlMGFmY2ZkMzNiYzRlMjhhMDU1
|
15
|
-
N2YxNGNmMmY3ODAyZWYxNzJmODQyNWYyYTAwZmZlMmJmZmI4MDU=
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 990c047e2344f52eae8e3ba76bb893a77faa986b
|
4
|
+
data.tar.gz: ec20ae0e67ba95f05f9a0747461a77fee9db34b8
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 4093ccce5bab5fd572922c3d6062b5fe72158e449111414bbd3cfbe056e8bd51c21435f94a24b4665a1f04da84ea72e03922d6290284f96b980eed4043faa7c7
|
7
|
+
data.tar.gz: afe38b265e257d36158a653286a689568c86a8229b623693b9c8165beec89b784dfd1d043f4525f8d4d8de4c853e17099c125e768e5c9480528b9eb7c41a3cb9
|
data/.gitignore
CHANGED
data/Gemfile
CHANGED
data/Rakefile
CHANGED
@@ -1,23 +1,68 @@
|
|
1
|
+
require "bundler/setup"
|
1
2
|
require "bundler/gem_tasks"
|
2
3
|
require "rake/testtask"
|
3
4
|
require "rbconfig"
|
4
5
|
|
5
|
-
|
6
|
+
Rake::TestTask.new do |t|
|
7
|
+
t.warning = true
|
8
|
+
t.verbose = true
|
9
|
+
end
|
10
|
+
|
11
|
+
if defined?(JRUBY_VERSION)
|
12
|
+
require 'ant'
|
13
|
+
|
14
|
+
directory 'ext/java/build'
|
6
15
|
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
16
|
+
task :setup => 'ext/java/build' do
|
17
|
+
ant.property name: 'src.dir', value: 'ext/java/src'
|
18
|
+
ant.property name: 'build.dir', value: 'ext/java/build'
|
19
|
+
|
20
|
+
ant.path id: 'compile.class.path' do
|
21
|
+
pathelement location: File.join(RbConfig::CONFIG['prefix'], 'lib', 'jruby.jar')
|
22
|
+
$LOAD_PATH.flat_map { |path| Dir[File.join(path, '**', '*.jar')] }.each do |jar|
|
23
|
+
pathelement location: jar
|
24
|
+
end
|
25
|
+
end
|
11
26
|
end
|
12
|
-
cp "ext/snappy.#{DLEXT}", "lib"
|
13
|
-
end
|
14
27
|
|
15
|
-
|
16
|
-
|
17
|
-
|
28
|
+
desc 'Compile the extension'
|
29
|
+
task :compile => :setup do
|
30
|
+
ant.javac destdir: '${build.dir}', includeantruntime: 'no', target: '1.6', source: '1.6', debug: 'on' do
|
31
|
+
classpath refid: 'compile.class.path'
|
32
|
+
src { pathelement location: '${src.dir}' }
|
33
|
+
end
|
34
|
+
end
|
18
35
|
|
19
|
-
|
20
|
-
|
21
|
-
|
36
|
+
desc 'Clean up build artifacts'
|
37
|
+
task :clean do
|
38
|
+
rm_rf 'ext/java/build'
|
39
|
+
rm_rf 'lib/snappy_ext.jar'
|
40
|
+
end
|
41
|
+
|
42
|
+
desc 'Package the jar'
|
43
|
+
file 'lib/snappy_ext.jar' => :compile do |t|
|
44
|
+
ant.jar destfile: 'lib/snappy_ext.jar', basedir: '${build.dir}' do
|
45
|
+
ant.fileset dir: '${build.dir}', includes: 'snappy/*.class'
|
46
|
+
ant.fileset dir: '${build.dir}', includes: 'SnappyExtLibraryService.class'
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
task :test => 'lib/snappy_ext.jar'
|
51
|
+
task :build => [:clean, 'lib/snappy_ext.jar']
|
52
|
+
else
|
53
|
+
DLEXT = RbConfig::CONFIG["DLEXT"]
|
54
|
+
|
55
|
+
file "ext/snappy_ext.#{DLEXT}" => Dir.glob("ext/*{.rb,.c}") do
|
56
|
+
Dir.chdir("ext") do
|
57
|
+
ruby "extconf.rb"
|
58
|
+
sh "make"
|
59
|
+
end
|
60
|
+
cp "ext/snappy_ext.#{DLEXT}", "lib/snappy_ext.#{DLEXT}"
|
61
|
+
end
|
62
|
+
|
63
|
+
task :clean do
|
64
|
+
rm_rf(["ext/snappy_ext.#{DLEXT}", "lib/snappy_ext.#{DLEXT}", "ext/mkmf.log", "ext/config.h", "ext/api.o", "ext/Makefile", "ext/snappy.cc", "ext/snappy.h", "ext/snappy.o"] + Dir["ext/snappy-*"])
|
65
|
+
end
|
66
|
+
|
67
|
+
task :test => "ext/snappy_ext.#{DLEXT}"
|
22
68
|
end
|
23
|
-
task :test => "ext/snappy.#{DLEXT}"
|
data/ext/api.c
CHANGED
@@ -78,7 +78,7 @@ snappy_inflate(int argc, VALUE *argv, VALUE self)
|
|
78
78
|
return dst;
|
79
79
|
}
|
80
80
|
|
81
|
-
void
|
81
|
+
void Init_snappy_ext()
|
82
82
|
{
|
83
83
|
rb_mSnappy = rb_define_module("Snappy");
|
84
84
|
rb_eSnappy = rb_define_class_under(rb_mSnappy, "Error", rb_eStandardError);
|
@@ -92,7 +92,4 @@ void Init_snappy()
|
|
92
92
|
|
93
93
|
rb_define_alias(rb_mSnappy_singleton, "uncompress", "inflate");
|
94
94
|
rb_define_alias(rb_mSnappy_singleton, "load", "inflate");
|
95
|
-
|
96
|
-
rb_require("snappy/writer");
|
97
|
-
rb_require("snappy/reader");
|
98
|
-
}
|
95
|
+
}
|
data/ext/extconf.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
require 'mkmf'
|
2
2
|
require 'fileutils'
|
3
3
|
|
4
|
-
unless have_library '
|
4
|
+
unless have_library 'snappy_ext'
|
5
5
|
dst = File.dirname File.expand_path __FILE__
|
6
6
|
|
7
7
|
tar = 'tar'
|
@@ -36,4 +36,4 @@ snappy.h
|
|
36
36
|
end
|
37
37
|
end
|
38
38
|
|
39
|
-
create_makefile '
|
39
|
+
create_makefile 'snappy_ext'
|
@@ -0,0 +1,18 @@
|
|
1
|
+
import org.jruby.Ruby;
|
2
|
+
import org.jruby.RubyModule;
|
3
|
+
import org.jruby.anno.JRubyMethod;
|
4
|
+
import org.jruby.runtime.ThreadContext;
|
5
|
+
import org.jruby.runtime.builtin.IRubyObject;
|
6
|
+
import org.jruby.runtime.load.Library;
|
7
|
+
import org.jruby.runtime.load.BasicLibraryService;
|
8
|
+
|
9
|
+
import snappy.SnappyModule;
|
10
|
+
|
11
|
+
|
12
|
+
public class SnappyExtService implements BasicLibraryService {
|
13
|
+
public boolean basicLoad(final Ruby runtime) {
|
14
|
+
RubyModule snappyModule = runtime.defineModule("Snappy");
|
15
|
+
snappyModule.defineAnnotatedMethods(SnappyModule.class);
|
16
|
+
return true;
|
17
|
+
}
|
18
|
+
}
|
@@ -0,0 +1,32 @@
|
|
1
|
+
package snappy;
|
2
|
+
|
3
|
+
import java.io.IOException;
|
4
|
+
|
5
|
+
import org.jruby.RubyString;
|
6
|
+
import org.jruby.anno.JRubyModule;
|
7
|
+
import org.jruby.anno.JRubyMethod;
|
8
|
+
import org.jruby.runtime.ThreadContext;
|
9
|
+
import org.jruby.runtime.builtin.IRubyObject;
|
10
|
+
import org.jruby.util.ByteList;
|
11
|
+
|
12
|
+
import org.xerial.snappy.Snappy;
|
13
|
+
|
14
|
+
|
15
|
+
@JRubyModule(name = "Snappy")
|
16
|
+
public class SnappyModule {
|
17
|
+
@JRubyMethod(module = true, name = {"deflate", "compress", "dump"})
|
18
|
+
public static IRubyObject deflate(ThreadContext context, IRubyObject self, IRubyObject str) throws IOException {
|
19
|
+
ByteList input = str.convertToString().getByteList();
|
20
|
+
byte[] compressed = new byte[Snappy.maxCompressedLength(input.length())];
|
21
|
+
int compressedLength = Snappy.compress(input.unsafeBytes(), input.begin(), input.length(), compressed, 0);
|
22
|
+
return RubyString.newStringNoCopy(context.runtime, compressed, 0, compressedLength);
|
23
|
+
}
|
24
|
+
|
25
|
+
@JRubyMethod(module = true, name = {"inflate", "uncompress", "load"})
|
26
|
+
public static IRubyObject inflate(ThreadContext context, IRubyObject self, IRubyObject str) throws IOException {
|
27
|
+
ByteList input = str.convertToString().getByteList();
|
28
|
+
byte[] uncompressed = new byte[Snappy.uncompressedLength(input.unsafeBytes(), input.begin(), input.length())];
|
29
|
+
int uncompressedLength = Snappy.uncompress(input.unsafeBytes(), input.begin(), input.length(), uncompressed, 0);
|
30
|
+
return RubyString.newStringNoCopy(context.runtime, uncompressed, 0, uncompressedLength);
|
31
|
+
}
|
32
|
+
}
|
data/lib/snappy.rb
ADDED
data/lib/snappy/version.rb
CHANGED
data/snappy.gemspec
CHANGED
@@ -17,7 +17,14 @@ Gem::Specification.new do |spec|
|
|
17
17
|
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
18
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
19
|
spec.require_paths = ["lib"]
|
20
|
-
|
20
|
+
|
21
|
+
if defined?(JRUBY_VERSION)
|
22
|
+
spec.files += %w[lib/snappy_ext.jar]
|
23
|
+
spec.platform = 'java'
|
24
|
+
spec.add_dependency 'snappy-jars', '~> 1.1.0'
|
25
|
+
else
|
26
|
+
spec.extensions = ["ext/extconf.rb"]
|
27
|
+
end
|
21
28
|
|
22
29
|
spec.add_development_dependency "bundler", "~> 1.3"
|
23
30
|
spec.add_development_dependency "rake"
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: snappy
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- miyucy
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-
|
11
|
+
date: 2013-12-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -28,28 +28,28 @@ dependencies:
|
|
28
28
|
name: rake
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- -
|
31
|
+
- - '>='
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: '0'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- -
|
38
|
+
- - '>='
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: minitest
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- -
|
45
|
+
- - '>='
|
46
46
|
- !ruby/object:Gem::Version
|
47
47
|
version: '0'
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- -
|
52
|
+
- - '>='
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '0'
|
55
55
|
description: libsnappy binding for Ruby
|
@@ -67,6 +67,9 @@ files:
|
|
67
67
|
- Rakefile
|
68
68
|
- ext/api.c
|
69
69
|
- ext/extconf.rb
|
70
|
+
- ext/java/src/SnappyExtService.java
|
71
|
+
- ext/java/src/snappy/SnappyModule.java
|
72
|
+
- lib/snappy.rb
|
70
73
|
- lib/snappy/reader.rb
|
71
74
|
- lib/snappy/version.rb
|
72
75
|
- lib/snappy/writer.rb
|
@@ -84,17 +87,17 @@ require_paths:
|
|
84
87
|
- lib
|
85
88
|
required_ruby_version: !ruby/object:Gem::Requirement
|
86
89
|
requirements:
|
87
|
-
- -
|
90
|
+
- - '>='
|
88
91
|
- !ruby/object:Gem::Version
|
89
92
|
version: '0'
|
90
93
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
91
94
|
requirements:
|
92
|
-
- -
|
95
|
+
- - '>='
|
93
96
|
- !ruby/object:Gem::Version
|
94
97
|
version: '0'
|
95
98
|
requirements: []
|
96
99
|
rubyforge_project:
|
97
|
-
rubygems_version: 2.
|
100
|
+
rubygems_version: 2.1.11
|
98
101
|
signing_key:
|
99
102
|
specification_version: 4
|
100
103
|
summary: libsnappy binding for Ruby
|