snappy 0.0.11-java → 0.0.12-java

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
2
  SHA1:
3
- metadata.gz: ae43704311dd9c266a56ea3db47155a802af4678
4
- data.tar.gz: 249e896fe57ef12e526e886ab8f03565021e0445
3
+ metadata.gz: ad3c31a8a7d40bdd357a4604828f89212a4808af
4
+ data.tar.gz: ed9fd36c6e42df33b37203722d5f680545902fb4
5
5
  SHA512:
6
- metadata.gz: 560ecc38c945f8c129a92b8250650cbf81efd6f3a83067009eb4eb7740e209fa1be1dde9e09243ee62ae5a53a3fc2acba47396d1e4b739f0521369ce7fc96056
7
- data.tar.gz: 98caa4b5bddd555800e8189cae2f7b9a1c169aa6f45ef2ad741813ed96bdfd349868d78844e11c52db14369bd08f62eba45e7feac42ba7c5c001c2c26b8e310f
6
+ metadata.gz: d326d3a46cd91ccd2ded284e65f2a0929cf7712355b83c7a839a3c3ed60e38dd39e5cea3badfb07aed8af944749488dc8cab9e6f4d1883f033fd4fb638e18cd2
7
+ data.tar.gz: 4dcc660ffffc348070ca7db7653baadcb2e44d583c3930b18b3dac0dfbc2bc8faa2bdc933df12a92d11973dcd84e10c2dc8e6a1a31c3164dad1558a1b2a812ac
data/.gitmodules CHANGED
@@ -1,3 +1,3 @@
1
1
  [submodule "vendor/snappy"]
2
2
  path = vendor/snappy
3
- url = git@github.com:google/snappy.git
3
+ url = git://github.com/google/snappy.git
data/.travis.yml ADDED
@@ -0,0 +1,4 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.2.2
4
+ - jruby-19mode
data/README.md CHANGED
@@ -1,6 +1,16 @@
1
- # Snappy
1
+ # Snappy ![](https://travis-ci.org/miyucy/snappy.svg?branch=master)
2
2
 
3
- see http://code.google.com/p/snappy
3
+ see https://github.com/google/snappy
4
+
5
+ ## Preparation
6
+
7
+ Use libsnappy
8
+
9
+ $ brew install snappy
10
+
11
+ Or
12
+
13
+ $ brew install autoconf automake libtool
4
14
 
5
15
  ## Installation
6
16
 
data/ext/api.c CHANGED
@@ -21,7 +21,7 @@ static VALUE
21
21
  snappy_deflate(int argc, VALUE *argv, VALUE self)
22
22
  {
23
23
  VALUE src, dst;
24
- size_t output_length;
24
+ size_t output_length;
25
25
  snappy_status result;
26
26
 
27
27
  rb_scan_args(argc, argv, "11", &src, &dst);
@@ -37,12 +37,12 @@ snappy_deflate(int argc, VALUE *argv, VALUE self)
37
37
  }
38
38
 
39
39
  result = snappy_compress(RSTRING_PTR(src), RSTRING_LEN(src), RSTRING_PTR(dst), &output_length);
40
- if (result == SNAPPY_OK) {
41
- rb_str_resize(dst, output_length);
42
- return dst;
43
- } else {
40
+ if (result != SNAPPY_OK) {
44
41
  return snappy_raise(result);
45
42
  }
43
+
44
+ rb_str_resize(dst, output_length);
45
+ return dst;
46
46
  }
47
47
 
48
48
  static VALUE
@@ -72,24 +72,39 @@ snappy_inflate(int argc, VALUE *argv, VALUE self)
72
72
  return snappy_raise(result);
73
73
  }
74
74
 
75
- StringValue(dst);
76
75
  rb_str_resize(dst, output_length);
77
-
78
76
  return dst;
79
77
  }
80
78
 
79
+ static VALUE
80
+ snappy_valid_p(VALUE self, VALUE str)
81
+ {
82
+ snappy_status result;
83
+
84
+ StringValue(str);
85
+ result = snappy_validate_compressed_buffer(RSTRING_PTR(str), RSTRING_LEN(str));
86
+ if (result == SNAPPY_OK) {
87
+ return Qtrue;
88
+ } else {
89
+ return Qfalse;
90
+ }
91
+ }
92
+
81
93
  void Init_snappy_ext()
82
94
  {
95
+ VALUE rb_mSnappy_singleton;
96
+
83
97
  rb_mSnappy = rb_define_module("Snappy");
84
98
  rb_eSnappy = rb_define_class_under(rb_mSnappy, "Error", rb_eStandardError);
85
99
  rb_define_singleton_method(rb_mSnappy, "deflate", snappy_deflate, -1);
86
100
  rb_define_singleton_method(rb_mSnappy, "inflate", snappy_inflate, -1);
101
+ rb_define_singleton_method(rb_mSnappy, "valid?", snappy_valid_p, 1);
87
102
 
88
- VALUE rb_mSnappy_singleton = rb_singleton_class(rb_mSnappy);
103
+ rb_mSnappy_singleton = rb_singleton_class(rb_mSnappy);
89
104
 
90
105
  rb_define_alias(rb_mSnappy_singleton, "compress", "deflate");
91
106
  rb_define_alias(rb_mSnappy_singleton, "dump", "deflate");
92
107
 
93
108
  rb_define_alias(rb_mSnappy_singleton, "uncompress", "inflate");
94
109
  rb_define_alias(rb_mSnappy_singleton, "load", "inflate");
95
- }
110
+ }
data/ext/extconf.rb CHANGED
@@ -1,14 +1,22 @@
1
1
  require 'mkmf'
2
2
  require 'fileutils'
3
3
 
4
+ def patch_autogen
5
+ # s/libtoolize/glibtoolize/
6
+ File.write('autogen.sh', File.read('autogen.sh').gsub(/libtoolize/, 'glibtoolize'))
7
+ end
8
+
4
9
  unless have_library 'snappy'
5
10
  # build vendor/snappy
6
11
  pwd = File.dirname File.expand_path __FILE__
7
12
  dir = File.join pwd, '..', 'vendor', 'snappy'
8
13
 
9
14
  Dir.chdir dir do
10
- system './autogen.sh'
11
- system './configure --disable-option-checking --disable-dependency-tracking --disable-gtest --without-gflags'
15
+ unless system './autogen.sh'
16
+ patch_autogen
17
+ raise '`autogen.sh` failed' unless system './autogen.sh'
18
+ end
19
+ raise '`configure` failed' unless system './configure --disable-option-checking --disable-dependency-tracking --disable-gtest --without-gflags'
12
20
  end
13
21
 
14
22
  src = %w(
@@ -1,3 +1,3 @@
1
1
  module Snappy
2
- VERSION = "0.0.11"
2
+ VERSION = "0.0.12"
3
3
  end
data/lib/snappy_ext.jar CHANGED
Binary file
data/test/test-snappy.rb CHANGED
@@ -1,16 +1,16 @@
1
- require "minitest/autorun"
2
- require "minitest/spec"
3
- require "snappy"
1
+ require 'minitest/autorun'
2
+ require 'minitest/spec'
3
+ require 'snappy'
4
4
 
5
5
  describe Snappy do
6
- T = [*"a".."z", *"A".."Z", *"0".."9"]
6
+ T = [*'a'..'z', *'A'..'Z', *'0'..'9']
7
7
 
8
- it "well done" do
8
+ it 'well done' do
9
9
  s = Array.new(1024){T.sample}.join
10
10
  Snappy.inflate(Snappy.deflate s).must_equal(s)
11
11
  end
12
12
 
13
- it "well done (pair)" do
13
+ it 'well done (pair)' do
14
14
  s = Array.new(1024){T.sample}.join
15
15
  [
16
16
  [:deflate, :inflate],
@@ -21,4 +21,38 @@ describe Snappy do
21
21
  eval %{Snappy.#{o}(Snappy.#{i} s).must_equal(s)}
22
22
  end
23
23
  end
24
+
25
+ describe '#deflate' do
26
+ it 'can pass buffer' do
27
+ skip 'cannot pass buffer in jruby' if defined? JRUBY_VERSION
28
+ s = 'a' * 1024
29
+ d = ' ' * 1024
30
+ r = Snappy.deflate(s, d)
31
+ d.must_be_same_as r
32
+ end
33
+ end
34
+
35
+ describe '#inflate' do
36
+ it 'can pass buffer' do
37
+ skip 'cannot pass buffer in jruby' if defined? JRUBY_VERSION
38
+ s = Snappy.deflate('a' * 1024)
39
+ d = ' ' * 1024
40
+ r = Snappy.inflate(s, d)
41
+ d.must_be_same_as r
42
+ end
43
+ end
44
+
45
+ describe '#valid?' do
46
+ it 'return true when passed deflated data' do
47
+ skip 'snappy-jars does not have valid?' if defined? JRUBY_VERSION
48
+ d = Snappy.deflate(Array.new(1024){T.sample}.join)
49
+ Snappy.valid?(d).must_equal true
50
+ end
51
+
52
+ it 'return false when passed invalid data' do
53
+ skip 'snappy-jars does not have valid?' if defined? JRUBY_VERSION
54
+ d = Snappy.deflate(Array.new(1024){T.sample}.join).reverse
55
+ Snappy.valid?(d).must_equal false
56
+ end
57
+ end
24
58
  end
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.11
4
+ version: 0.0.12
5
5
  platform: java
6
6
  authors:
7
7
  - miyucy
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-09-24 00:00:00.000000000 Z
11
+ date: 2015-06-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  requirement: !ruby/object:Gem::Requirement
@@ -75,6 +75,7 @@ extra_rdoc_files: []
75
75
  files:
76
76
  - .gitignore
77
77
  - .gitmodules
78
+ - .travis.yml
78
79
  - Gemfile
79
80
  - LICENSE.txt
80
81
  - README.md
@@ -87,11 +88,11 @@ files:
87
88
  - lib/snappy/reader.rb
88
89
  - lib/snappy/version.rb
89
90
  - lib/snappy/writer.rb
91
+ - lib/snappy_ext.jar
90
92
  - snappy.gemspec
91
93
  - test/test-snappy-reader.rb
92
94
  - test/test-snappy-writer.rb
93
95
  - test/test-snappy.rb
94
- - lib/snappy_ext.jar
95
96
  - vendor/snappy/AUTHORS
96
97
  - vendor/snappy/COPYING
97
98
  - vendor/snappy/ChangeLog
@@ -150,7 +151,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
150
151
  version: '0'
151
152
  requirements: []
152
153
  rubyforge_project:
153
- rubygems_version: 2.1.9
154
+ rubygems_version: 2.4.6
154
155
  signing_key:
155
156
  specification_version: 4
156
157
  summary: libsnappy binding for Ruby