snappy 0.0.10 → 0.0.11

Sign up to get free protection for your applications and to get access to all the features.
Files changed (47) hide show
  1. checksums.yaml +4 -4
  2. data/.gitmodules +3 -0
  3. data/Rakefile +12 -13
  4. data/ext/extconf.rb +22 -31
  5. data/lib/snappy/reader.rb +10 -7
  6. data/lib/snappy/version.rb +1 -1
  7. data/snappy.gemspec +24 -0
  8. data/test/test-snappy-reader.rb +16 -0
  9. data/vendor/snappy/AUTHORS +1 -0
  10. data/vendor/snappy/COPYING +54 -0
  11. data/vendor/snappy/ChangeLog +1916 -0
  12. data/vendor/snappy/Makefile.am +23 -0
  13. data/vendor/snappy/NEWS +128 -0
  14. data/vendor/snappy/README +135 -0
  15. data/vendor/snappy/autogen.sh +7 -0
  16. data/vendor/snappy/configure.ac +133 -0
  17. data/vendor/snappy/format_description.txt +110 -0
  18. data/vendor/snappy/framing_format.txt +135 -0
  19. data/vendor/snappy/m4/gtest.m4 +74 -0
  20. data/vendor/snappy/snappy-c.cc +90 -0
  21. data/vendor/snappy/snappy-c.h +138 -0
  22. data/vendor/snappy/snappy-internal.h +150 -0
  23. data/vendor/snappy/snappy-sinksource.cc +71 -0
  24. data/vendor/snappy/snappy-sinksource.h +137 -0
  25. data/vendor/snappy/snappy-stubs-internal.cc +42 -0
  26. data/vendor/snappy/snappy-stubs-internal.h +491 -0
  27. data/vendor/snappy/snappy-stubs-public.h.in +98 -0
  28. data/vendor/snappy/snappy-test.cc +606 -0
  29. data/vendor/snappy/snappy-test.h +582 -0
  30. data/vendor/snappy/snappy.cc +1306 -0
  31. data/vendor/snappy/snappy.h +184 -0
  32. data/vendor/snappy/snappy_unittest.cc +1355 -0
  33. data/vendor/snappy/testdata/alice29.txt +3609 -0
  34. data/vendor/snappy/testdata/asyoulik.txt +4122 -0
  35. data/vendor/snappy/testdata/baddata1.snappy +0 -0
  36. data/vendor/snappy/testdata/baddata2.snappy +0 -0
  37. data/vendor/snappy/testdata/baddata3.snappy +0 -0
  38. data/vendor/snappy/testdata/fireworks.jpeg +0 -0
  39. data/vendor/snappy/testdata/geo.protodata +0 -0
  40. data/vendor/snappy/testdata/html +1 -0
  41. data/vendor/snappy/testdata/html_x_4 +1 -0
  42. data/vendor/snappy/testdata/kppkn.gtb +0 -0
  43. data/vendor/snappy/testdata/lcet10.txt +7519 -0
  44. data/vendor/snappy/testdata/paper-100k.pdf +600 -2
  45. data/vendor/snappy/testdata/plrabn12.txt +10699 -0
  46. data/vendor/snappy/testdata/urls.10K +10000 -0
  47. metadata +51 -12
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: dc5a419cf7d20b6b439f767ad8fe39ad291e0fe8
4
- data.tar.gz: 2bf91b961d0f32227f2bad3fff85a832ee1d6393
3
+ metadata.gz: b4a1e7596c5afb723e2ce4a83f2fb7cb93209437
4
+ data.tar.gz: 04e9a2a418c1c689171973cd0c6dcac7eac8ce14
5
5
  SHA512:
6
- metadata.gz: 43acb4a258b8c4d5f20810833bd21f33ada143da1b142d6028e67fe59dc460773c65dfb9c6fddd497c037246e122b4fb092511a6578fd614f58a73875591e788
7
- data.tar.gz: 6c3fb1b4b998caf2b19bb966f88b4511320561179404954dfd053dc32b82cc60e9acf2570b337b277abd3e33c94e5e049f15e084e70eef2d32f491b52bfa2328
6
+ metadata.gz: 223724133a803ebebfc86d956885fdd9294910e86dbc3759714ee42e8332407254b6c0d6bb8325827f2acfa3c1c1edf1b337e537144c4d2721cafcfbf6e6e25d
7
+ data.tar.gz: 09de13c3bcbd183976ca76208b28c903811a3b96b7d327ac7762fe127208b536500a58fbbf9af3f8d8fd83dad6def9115fa40c0334cc95b27bd003480c2c8e6b
data/.gitmodules ADDED
@@ -0,0 +1,3 @@
1
+ [submodule "vendor/snappy"]
2
+ path = vendor/snappy
3
+ url = git@github.com:google/snappy.git
data/Rakefile CHANGED
@@ -2,6 +2,7 @@ require "bundler/setup"
2
2
  require "bundler/gem_tasks"
3
3
  require "rake/testtask"
4
4
  require "rbconfig"
5
+ DLEXT = RbConfig::CONFIG['DLEXT']
5
6
 
6
7
  Rake::TestTask.new do |t|
7
8
  t.warning = true
@@ -33,12 +34,6 @@ if defined?(JRUBY_VERSION)
33
34
  end
34
35
  end
35
36
 
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
37
  desc 'Package the jar'
43
38
  file 'lib/snappy_ext.jar' => :compile do |t|
44
39
  ant.jar destfile: 'lib/snappy_ext.jar', basedir: '${build.dir}' do
@@ -50,19 +45,23 @@ if defined?(JRUBY_VERSION)
50
45
  task :test => 'lib/snappy_ext.jar'
51
46
  task :build => [:clean, 'lib/snappy_ext.jar']
52
47
  else
53
- DLEXT = RbConfig::CONFIG["DLEXT"]
54
-
55
48
  file "ext/snappy_ext.#{DLEXT}" => Dir.glob("ext/*{.rb,.c}") do
56
49
  Dir.chdir("ext") do
57
- ruby "extconf.rb"
58
- sh "make"
50
+ ruby "extconf.rb"
51
+ sh "make"
59
52
  end
60
53
  cp "ext/snappy_ext.#{DLEXT}", "lib/snappy_ext.#{DLEXT}"
61
54
  end
62
55
 
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
56
 
67
57
  task :test => "ext/snappy_ext.#{DLEXT}"
68
58
  end
59
+
60
+ desc 'Clean up build artifacts'
61
+ task :clean do
62
+ rm_rf 'ext/java/build'
63
+ rm_rf 'lib/snappy_ext.jar'
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 :default => :test
data/ext/extconf.rb CHANGED
@@ -1,39 +1,30 @@
1
1
  require 'mkmf'
2
2
  require 'fileutils'
3
3
 
4
- unless have_library 'snappy_ext'
5
- dst = File.dirname File.expand_path __FILE__
6
-
7
- tar = 'tar'
8
- tar = 'gnutar' if find_executable 'gnutar'
9
-
10
- ver = "1.1.1"
11
- src = "snappy-#{ver}"
12
-
13
- FileUtils.rm_rf File.join dst, src
14
- system "curl -s http://snappy.googlecode.com/files/#{src}.tar.gz | #{tar} xz"
15
-
16
- src = File.join dst, src
17
-
18
- Dir.chdir src do
19
- system "./configure --disable-option-checking --disable-dependency-tracking --disable-gtest --without-gflags"
4
+ unless have_library 'snappy'
5
+ # build vendor/snappy
6
+ pwd = File.dirname File.expand_path __FILE__
7
+ dir = File.join pwd, '..', 'vendor', 'snappy'
8
+
9
+ Dir.chdir dir do
10
+ system './autogen.sh'
11
+ system './configure --disable-option-checking --disable-dependency-tracking --disable-gtest --without-gflags'
20
12
  end
21
13
 
22
- %w(
23
- config.h
24
- snappy-c.cc
25
- snappy-c.h
26
- snappy-internal.h
27
- snappy-sinksource.cc
28
- snappy-sinksource.h
29
- snappy-stubs-internal.cc
30
- snappy-stubs-internal.h
31
- snappy-stubs-public.h
32
- snappy.cc
33
- snappy.h
34
- ).each do |file|
35
- FileUtils.copy File.join(src, file), File.join(dst, file) if FileTest.exist? File.join(src, file)
36
- end
14
+ src = %w(
15
+ config.h
16
+ snappy-c.cc
17
+ snappy-c.h
18
+ snappy-internal.h
19
+ snappy-sinksource.cc
20
+ snappy-sinksource.h
21
+ snappy-stubs-internal.cc
22
+ snappy-stubs-internal.h
23
+ snappy-stubs-public.h
24
+ snappy.cc
25
+ snappy.h
26
+ ).map { |e| File.join dir, e }
27
+ FileUtils.cp src, pwd, :verbose => true
37
28
  end
38
29
 
39
30
  create_makefile 'snappy_ext'
data/lib/snappy/reader.rb CHANGED
@@ -11,8 +11,12 @@ module Snappy
11
11
 
12
12
  def each
13
13
  until @io.eof?
14
- size = @chunked ? @io.read(4).unpack("N").first : @io.length
15
- yield Snappy.inflate(@io.read(size)) if block_given?
14
+ if @chunked
15
+ size = @io.read(4).unpack('N').first
16
+ yield Snappy.inflate(@io.read(size)) if block_given?
17
+ else
18
+ yield Snappy.inflate @io.read if block_given?
19
+ end
16
20
  end
17
21
  end
18
22
 
@@ -40,13 +44,12 @@ module Snappy
40
44
  private
41
45
 
42
46
  def read_header!
43
- magic_byte = @io.readchar
44
- @io.ungetc(magic_byte)
45
-
46
- if @io.length >= 16 && magic_byte == Snappy::Writer::MAGIC[0]
47
- @magic, @default_version, @minimum_compatible_version = @io.read(16).unpack("a8NN")
47
+ header = @io.read Snappy::Writer::MAGIC.length
48
+ if header.length == Snappy::Writer::MAGIC.length && header == Snappy::Writer::MAGIC
49
+ @magic, @default_version, @minimum_compatible_version = header, *@io.read(8).unpack('NN')
48
50
  @chunked = true
49
51
  else
52
+ @io.rewind
50
53
  @chunked = false
51
54
  end
52
55
  end
@@ -1,3 +1,3 @@
1
1
  module Snappy
2
- VERSION = "0.0.10"
2
+ VERSION = "0.0.11"
3
3
  end
data/snappy.gemspec CHANGED
@@ -29,4 +29,28 @@ Gem::Specification.new do |spec|
29
29
  spec.add_development_dependency "bundler", "~> 1.3"
30
30
  spec.add_development_dependency "rake"
31
31
  spec.add_development_dependency "minitest"
32
+
33
+ # get an array of submodule dirs by executing 'pwd' inside each submodule
34
+ `git submodule --quiet foreach pwd`.split($\).each do |submodule_path|
35
+ # for each submodule, change working directory to that submodule
36
+ Dir.chdir(submodule_path) do
37
+
38
+ # issue git ls-files in submodule's directory
39
+ submodule_files = `git ls-files`.split($\)
40
+
41
+ # prepend the submodule path to create absolute file paths
42
+ submodule_files_fullpaths = submodule_files.map do |filename|
43
+ "#{submodule_path}/#{filename}"
44
+ end
45
+
46
+ # remove leading path parts to get paths relative to the gem's root dir
47
+ # (this assumes, that the gemspec resides in the gem's root dir)
48
+ submodule_files_paths = submodule_files_fullpaths.map do |filename|
49
+ filename.gsub "#{File.dirname(__FILE__)}/", ""
50
+ end
51
+
52
+ # add relative paths to gem.files
53
+ spec.files += submodule_files_paths
54
+ end
55
+ end
32
56
  end
@@ -45,12 +45,28 @@ describe Snappy::Reader do
45
45
  it "should inflate with a magic header" do
46
46
  subject.read.must_equal "HelloWorld" * 10
47
47
  end
48
+
49
+ it "should not receive `length' in eaching" do
50
+ length = MiniTest::Mock.new.expect(:call, 0)
51
+ @buffer.stub(:length, length) do
52
+ subject.read
53
+ end
54
+ -> { length.verify }.must_raise MockExpectationError
55
+ end
48
56
  end
49
57
 
50
58
  describe :io do
51
59
  it "should be a constructor argument" do
52
60
  subject.io.must_equal @buffer
53
61
  end
62
+
63
+ it "should not receive `length' in initializing" do
64
+ length = MiniTest::Mock.new.expect(:call, 0)
65
+ @buffer.stub(:length, length) do
66
+ Snappy::Reader.new @buffer
67
+ end
68
+ -> { length.verify }.must_raise MockExpectationError
69
+ end
54
70
  end
55
71
 
56
72
  describe :each do
@@ -0,0 +1 @@
1
+ opensource@google.com
@@ -0,0 +1,54 @@
1
+ Copyright 2011, Google Inc.
2
+ All rights reserved.
3
+
4
+ Redistribution and use in source and binary forms, with or without
5
+ modification, are permitted provided that the following conditions are
6
+ met:
7
+
8
+ * Redistributions of source code must retain the above copyright
9
+ notice, this list of conditions and the following disclaimer.
10
+ * Redistributions in binary form must reproduce the above
11
+ copyright notice, this list of conditions and the following disclaimer
12
+ in the documentation and/or other materials provided with the
13
+ distribution.
14
+ * Neither the name of Google Inc. nor the names of its
15
+ contributors may be used to endorse or promote products derived from
16
+ this software without specific prior written permission.
17
+
18
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19
+ "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20
+ LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21
+ A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22
+ OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23
+ SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24
+ LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25
+ DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26
+ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29
+
30
+ ===
31
+
32
+ Some of the benchmark data in util/zippy/testdata is licensed differently:
33
+
34
+ - fireworks.jpeg is Copyright 2013 Steinar H. Gunderson, and
35
+ is licensed under the Creative Commons Attribution 3.0 license
36
+ (CC-BY-3.0). See https://creativecommons.org/licenses/by/3.0/
37
+ for more information.
38
+
39
+ - kppkn.gtb is taken from the Gaviota chess tablebase set, and
40
+ is licensed under the MIT License. See
41
+ https://sites.google.com/site/gaviotachessengine/Home/endgame-tablebases-1
42
+ for more information.
43
+
44
+ - paper-100k.pdf is an excerpt (bytes 92160 to 194560) from the paper
45
+ “Combinatorial Modeling of Chromatin Features Quantitatively Predicts DNA
46
+ Replication Timing in _Drosophila_” by Federico Comoglio and Renato Paro,
47
+ which is licensed under the CC-BY license. See
48
+ http://www.ploscompbiol.org/static/license for more ifnormation.
49
+
50
+ - alice29.txt, asyoulik.txt, plrabn12.txt and lcet10.txt are from Project
51
+ Gutenberg. The first three have expired copyrights and are in the public
52
+ domain; the latter does not have expired copyright, but is still in the
53
+ public domain according to the license information
54
+ (http://www.gutenberg.org/ebooks/53).