snappy 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (46) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/main.yml +34 -0
  3. data/.github/workflows/publish.yml +34 -0
  4. data/Gemfile +3 -4
  5. data/Rakefile +32 -30
  6. data/ext/api.c +6 -1
  7. data/lib/snappy.rb +5 -5
  8. data/lib/snappy/hadoop/reader.rb +6 -2
  9. data/lib/snappy/reader.rb +11 -7
  10. data/lib/snappy/shim.rb +1 -1
  11. data/lib/snappy/version.rb +1 -1
  12. data/snappy.gemspec +13 -9
  13. data/test/hadoop/snappy_hadoop_reader_test.rb +115 -0
  14. data/test/hadoop/snappy_hadoop_writer_test.rb +48 -0
  15. data/test/snappy_hadoop_test.rb +26 -0
  16. data/test/snappy_reader_test.rb +148 -0
  17. data/test/snappy_test.rb +95 -0
  18. data/test/snappy_writer_test.rb +55 -0
  19. data/test/test_helper.rb +7 -0
  20. data/vendor/snappy/CMakeLists.txt +177 -54
  21. data/vendor/snappy/NEWS +8 -0
  22. data/vendor/snappy/README.md +19 -20
  23. data/vendor/snappy/cmake/SnappyConfig.cmake.in +33 -0
  24. data/vendor/snappy/cmake/config.h.in +6 -6
  25. data/vendor/snappy/docs/README.md +72 -0
  26. data/vendor/snappy/snappy-internal.h +12 -5
  27. data/vendor/snappy/snappy-stubs-internal.cc +1 -1
  28. data/vendor/snappy/snappy-stubs-internal.h +60 -15
  29. data/vendor/snappy/snappy-stubs-public.h.in +16 -36
  30. data/vendor/snappy/snappy-test.cc +16 -15
  31. data/vendor/snappy/snappy-test.h +12 -60
  32. data/vendor/snappy/snappy.cc +333 -187
  33. data/vendor/snappy/snappy.h +14 -10
  34. data/vendor/snappy/snappy_compress_fuzzer.cc +59 -0
  35. data/vendor/snappy/snappy_uncompress_fuzzer.cc +57 -0
  36. data/vendor/snappy/snappy_unittest.cc +220 -124
  37. metadata +26 -20
  38. data/.travis.yml +0 -31
  39. data/smoke.sh +0 -8
  40. data/test/hadoop/test-snappy-hadoop-reader.rb +0 -103
  41. data/test/hadoop/test-snappy-hadoop-writer.rb +0 -48
  42. data/test/test-snappy-hadoop.rb +0 -22
  43. data/test/test-snappy-reader.rb +0 -129
  44. data/test/test-snappy-writer.rb +0 -55
  45. data/test/test-snappy.rb +0 -58
  46. data/vendor/snappy/cmake/SnappyConfig.cmake +0 -1
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.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - miyucy
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-12-04 00:00:00.000000000 Z
11
+ date: 2020-12-26 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: libsnappy binding for Ruby
14
14
  email:
@@ -18,9 +18,10 @@ extensions:
18
18
  - ext/extconf.rb
19
19
  extra_rdoc_files: []
20
20
  files:
21
+ - ".github/workflows/main.yml"
22
+ - ".github/workflows/publish.yml"
21
23
  - ".gitignore"
22
24
  - ".gitmodules"
23
- - ".travis.yml"
24
25
  - Gemfile
25
26
  - LICENSE.txt
26
27
  - README.md
@@ -37,22 +38,23 @@ files:
37
38
  - lib/snappy/shim.rb
38
39
  - lib/snappy/version.rb
39
40
  - lib/snappy/writer.rb
40
- - smoke.sh
41
41
  - snappy.gemspec
42
- - test/hadoop/test-snappy-hadoop-reader.rb
43
- - test/hadoop/test-snappy-hadoop-writer.rb
44
- - test/test-snappy-hadoop.rb
45
- - test/test-snappy-reader.rb
46
- - test/test-snappy-writer.rb
47
- - test/test-snappy.rb
42
+ - test/hadoop/snappy_hadoop_reader_test.rb
43
+ - test/hadoop/snappy_hadoop_writer_test.rb
44
+ - test/snappy_hadoop_test.rb
45
+ - test/snappy_reader_test.rb
46
+ - test/snappy_test.rb
47
+ - test/snappy_writer_test.rb
48
+ - test/test_helper.rb
48
49
  - vendor/snappy/AUTHORS
49
50
  - vendor/snappy/CMakeLists.txt
50
51
  - vendor/snappy/CONTRIBUTING.md
51
52
  - vendor/snappy/COPYING
52
53
  - vendor/snappy/NEWS
53
54
  - vendor/snappy/README.md
54
- - vendor/snappy/cmake/SnappyConfig.cmake
55
+ - vendor/snappy/cmake/SnappyConfig.cmake.in
55
56
  - vendor/snappy/cmake/config.h.in
57
+ - vendor/snappy/docs/README.md
56
58
  - vendor/snappy/format_description.txt
57
59
  - vendor/snappy/framing_format.txt
58
60
  - vendor/snappy/snappy-c.cc
@@ -67,11 +69,15 @@ files:
67
69
  - vendor/snappy/snappy-test.h
68
70
  - vendor/snappy/snappy.cc
69
71
  - vendor/snappy/snappy.h
72
+ - vendor/snappy/snappy_compress_fuzzer.cc
73
+ - vendor/snappy/snappy_uncompress_fuzzer.cc
70
74
  - vendor/snappy/snappy_unittest.cc
71
75
  homepage: http://github.com/miyucy/snappy
72
76
  licenses:
73
77
  - MIT
74
- metadata: {}
78
+ metadata:
79
+ homepage_uri: http://github.com/miyucy/snappy
80
+ source_code_uri: http://github.com/miyucy/snappy
75
81
  post_install_message:
76
82
  rdoc_options: []
77
83
  require_paths:
@@ -87,15 +93,15 @@ required_rubygems_version: !ruby/object:Gem::Requirement
87
93
  - !ruby/object:Gem::Version
88
94
  version: '0'
89
95
  requirements: []
90
- rubyforge_project:
91
- rubygems_version: 2.7.6.2
96
+ rubygems_version: 3.1.4
92
97
  signing_key:
93
98
  specification_version: 4
94
99
  summary: libsnappy binding for Ruby
95
100
  test_files:
96
- - test/hadoop/test-snappy-hadoop-reader.rb
97
- - test/hadoop/test-snappy-hadoop-writer.rb
98
- - test/test-snappy-hadoop.rb
99
- - test/test-snappy-reader.rb
100
- - test/test-snappy-writer.rb
101
- - test/test-snappy.rb
101
+ - test/hadoop/snappy_hadoop_reader_test.rb
102
+ - test/hadoop/snappy_hadoop_writer_test.rb
103
+ - test/snappy_hadoop_test.rb
104
+ - test/snappy_reader_test.rb
105
+ - test/snappy_test.rb
106
+ - test/snappy_writer_test.rb
107
+ - test/test_helper.rb
@@ -1,31 +0,0 @@
1
- language: ruby
2
- sudo: false
3
- cache:
4
- bundler: true
5
- directories:
6
- - "$HOME/.ccache"
7
- rvm:
8
- - 1.9.3
9
- - 2.2
10
- - 2.3
11
- - 2.4
12
- - 2.5
13
- - jruby-19mode
14
- env:
15
- global:
16
- - PATH="/usr/lib/ccache:$PATH"
17
- before_install:
18
- - travis_retry gem install bundler --no-document -v 1.16.1
19
- addons:
20
- apt:
21
- packages:
22
- - cmake
23
- deploy:
24
- provider: rubygems
25
- api_key:
26
- secure: Jwk5pSUD9dUb34fO4dLamqhQw9U/t/5pHX7l5LKE4e1MDlD9fq/KB/DFpRTSfA0s8XUu+NZYtRO+6GZBEBY5UjZyPcUk5izaQzMWANP6QEMI4mYheSFUXTGkimV8MFxo2Fp7itZBM9SsLccDp/59nmbhBUMdr4OECZtd1Igjz63AtRdD7JgZwhC2XqBVbcxyx78VcZH8r4JEZzpcnZjjGN9YwQFubhiPs0V2uTMp/kGSWeP4U3T71MrvRmDlu8QJTsTRsvhv+zDatFySzs2SGsn25+cUCOqWnb5vcwtCbfj7trY+DLO3FqZOvQlvDfvyOy9LlLRpovhu6w+L42Z2ZN5U1Ovz0bMjk5WGLlXRxCLTRqXihvJrtFuL/7B2YSXcWPBNt5HWFwtapEJDm+CJoKpqa/WB7gEgO+uAocHbRqbg64rnPLODOEH0xGeRNSXBA3P5JeVNYhvpFdX8LclRFaVpfYDDenzRV9zpIppMXSq3Suzw/nZPBL9cuuIsBYG6hnijhZertWIRjZqw8D/1wEBd6VT7cDQ+PsNBGKhvPBVd5Nb7Zh9YjwCv4BQHB6XekiKi7mGFN4X/6eTzudRYxG7KyrYqk9AQ6KmEv5U/Xv+Wcar86O49LtNqYykYKLknC9CiUwTDp4lkVD8D3LoIzkL2/AeZyI6NQso8tymB0CM=
27
- gem: snappy
28
- on:
29
- tags: true
30
- repo: miyucy/snappy
31
- script: bundle exec rake && ./smoke.sh
data/smoke.sh DELETED
@@ -1,8 +0,0 @@
1
- #!/bin/bash
2
- gem list | grep snappy && gem uninstall --force snappy
3
- bundle exec rake clean build
4
- gem install --no-document "$(ls pkg/snappy-*.gem)"
5
- cat <<EOF | ruby
6
- require 'snappy'
7
- abort if Snappy.inflate(Snappy.deflate(File.read('smoke.sh'))) != File.read('smoke.sh')
8
- EOF
@@ -1,103 +0,0 @@
1
- require "minitest/autorun"
2
- require "minitest/spec"
3
- require "snappy"
4
- require "stringio"
5
-
6
- describe Snappy::Hadoop::Reader do
7
- before do
8
- @buffer = StringIO.new
9
- Snappy::Hadoop::Writer.new @buffer do |w|
10
- w << "foo"
11
- w << "bar"
12
- w << "baz"
13
- w << "quux"
14
- end
15
- @buffer.rewind
16
- end
17
-
18
- subject do
19
- Snappy::Hadoop::Reader.new @buffer
20
- end
21
-
22
- describe :initialize do
23
- it "should yield itself to the block" do
24
- yielded = nil
25
- returned = Snappy::Hadoop::Reader.new @buffer do |r|
26
- yielded = r
27
- end
28
- returned.must_equal yielded
29
- end
30
- end
31
-
32
- describe :io do
33
- it "should be a constructor argument" do
34
- subject.io.must_equal @buffer
35
- end
36
-
37
- it "should not receive `length' in initializing" do
38
- length = MiniTest::Mock.new.expect(:call, 0)
39
- @buffer.stub(:length, length) do
40
- Snappy::Hadoop::Reader.new @buffer
41
- end
42
- -> { length.verify }.must_raise MockExpectationError
43
- end
44
- end
45
-
46
- describe :each do
47
- before do
48
- Snappy::Hadoop::Writer.new @buffer do |w|
49
- w << "foo"
50
- w << "bar"
51
- w.dump!
52
- w << "baz"
53
- w << "quux"
54
- end
55
- @buffer.rewind
56
- end
57
-
58
- it "should yield each chunk" do
59
- chunks = []
60
- Snappy::Hadoop::Reader.new(@buffer).each do |chunk|
61
- chunks << chunk
62
- end
63
- chunks.must_equal ["foobar", "bazquux"]
64
- end
65
- end
66
-
67
- describe :read do
68
- before do
69
- Snappy::Hadoop::Writer.new @buffer do |w|
70
- w << "foo"
71
- w << "bar"
72
- w << "baz"
73
- w << "quux"
74
- end
75
- @buffer.rewind
76
- end
77
-
78
- it "should return the bytes" do
79
- Snappy::Hadoop::Reader.new(@buffer).read.must_equal "foobarbazquux"
80
- end
81
- end
82
-
83
- describe :each_line do
84
- before do
85
- Snappy::Hadoop::Writer.new @buffer do |w|
86
- w << "foo\n"
87
- w << "bar"
88
- w.dump!
89
- w << "baz\n"
90
- w << "quux\n"
91
- end
92
- @buffer.rewind
93
- end
94
-
95
- it "should yield each line" do
96
- lines = []
97
- Snappy::Hadoop::Reader.new(@buffer).each_line do |line|
98
- lines << line
99
- end
100
- lines.must_equal ["foo", "barbaz", "quux"]
101
- end
102
- end
103
- end
@@ -1,48 +0,0 @@
1
- require "minitest/autorun"
2
- require "minitest/spec"
3
- require "snappy"
4
- require "stringio"
5
-
6
- describe Snappy::Hadoop::Writer do
7
- before do
8
- @buffer = StringIO.new
9
- end
10
-
11
- subject do
12
- Snappy::Hadoop::Writer.new @buffer
13
- end
14
-
15
- describe :initialize do
16
- it "should yield itself to the block" do
17
- yielded = nil
18
- returned = Snappy::Hadoop::Writer.new @buffer do |w|
19
- yielded = w
20
- end
21
- returned.must_equal yielded
22
- end
23
-
24
- it "should dump on the end of yield" do
25
- Snappy::Hadoop::Writer.new @buffer do |w|
26
- w << "foo"
27
- end
28
- @buffer.string.must_equal "\u0000\u0000\u0000\u0003\u0000\u0000\u0000\u0005\u0003\bfoo"
29
- end
30
- end
31
-
32
- describe :io do
33
- it "should be a constructor argument" do
34
- io = StringIO.new
35
- Snappy::Hadoop::Writer.new(io).io.must_equal io
36
- end
37
- end
38
-
39
- describe :block_size do
40
- it "should default to DEFAULT_BLOCK_SIZE" do
41
- Snappy::Hadoop::Writer.new(StringIO.new).block_size.must_equal Snappy::Hadoop::Writer::DEFAULT_BLOCK_SIZE
42
- end
43
-
44
- it "should be settable via the constructor" do
45
- Snappy::Hadoop::Writer.new(StringIO.new, 42).block_size.must_equal 42
46
- end
47
- end
48
- end
@@ -1,22 +0,0 @@
1
- require 'minitest/autorun'
2
- require 'minitest/spec'
3
- require 'snappy'
4
-
5
- describe Snappy::Hadoop do
6
- T = [*'a'..'z', *'A'..'Z', *'0'..'9']
7
-
8
- it 'well done' do
9
- s = Array.new(1024){T.sample}.join
10
- Snappy::Hadoop.inflate(Snappy::Hadoop.deflate s).must_equal(s)
11
- end
12
-
13
- it 'well done (pair)' do
14
- s = Array.new(1024){T.sample}.join
15
- [
16
- [:deflate, :inflate],
17
- ].each do |(i, o)|
18
- Snappy::Hadoop.__send__(o, (Snappy::Hadoop.__send__ i, s)).must_equal(s)
19
- eval %{Snappy::Hadoop.#{o}(Snappy::Hadoop.#{i} s).must_equal(s)}
20
- end
21
- end
22
- end
@@ -1,129 +0,0 @@
1
- require "minitest/autorun"
2
- require "minitest/spec"
3
- require "snappy"
4
- require "stringio"
5
-
6
- describe Snappy::Reader do
7
- before do
8
- @buffer = StringIO.new
9
- Snappy::Writer.new @buffer do |w|
10
- w << "foo"
11
- w << "bar"
12
- w << "baz"
13
- w << "quux"
14
- end
15
- @buffer.rewind
16
- end
17
-
18
- subject do
19
- Snappy::Reader.new @buffer
20
- end
21
-
22
- describe :initialize do
23
- it "should yield itself to the block" do
24
- yielded = nil
25
- returned = Snappy::Reader.new @buffer do |r|
26
- yielded = r
27
- end
28
- returned.must_equal yielded
29
- end
30
-
31
- it "should read the header" do
32
- subject.magic.must_equal Snappy::Writer::MAGIC
33
- subject.default_version.must_equal Snappy::Writer::DEFAULT_VERSION
34
- subject.minimum_compatible_version.must_equal Snappy::Writer::MINIMUM_COMPATIBLE_VERSION
35
- end
36
- end
37
-
38
- describe :initialize_without_headers do
39
- before do
40
- @buffer = StringIO.new
41
- @buffer << Snappy.deflate("HelloWorld" * 10)
42
- @buffer.rewind
43
- end
44
-
45
- it "should inflate with a magic header" do
46
- subject.read.must_equal "HelloWorld" * 10
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
56
- end
57
-
58
- describe :io do
59
- it "should be a constructor argument" do
60
- subject.io.must_equal @buffer
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
70
- end
71
-
72
- describe :each do
73
- before do
74
- Snappy::Writer.new @buffer do |w|
75
- w << "foo"
76
- w << "bar"
77
- w.dump!
78
- w << "baz"
79
- w << "quux"
80
- end
81
- @buffer.rewind
82
- end
83
-
84
- it "should yield each chunk" do
85
- chunks = []
86
- Snappy::Reader.new(@buffer).each do |chunk|
87
- chunks << chunk
88
- end
89
- chunks.must_equal ["foobar", "bazquux"]
90
- end
91
- end
92
-
93
- describe :read do
94
- before do
95
- Snappy::Writer.new @buffer do |w|
96
- w << "foo"
97
- w << "bar"
98
- w << "baz"
99
- w << "quux"
100
- end
101
- @buffer.rewind
102
- end
103
-
104
- it "should return the bytes" do
105
- Snappy::Reader.new(@buffer).read.must_equal "foobarbazquux"
106
- end
107
- end
108
-
109
- describe :each_line do
110
- before do
111
- Snappy::Writer.new @buffer do |w|
112
- w << "foo\n"
113
- w << "bar"
114
- w.dump!
115
- w << "baz\n"
116
- w << "quux\n"
117
- end
118
- @buffer.rewind
119
- end
120
-
121
- it "should yield each line" do
122
- lines = []
123
- Snappy::Reader.new(@buffer).each_line do |line|
124
- lines << line
125
- end
126
- lines.must_equal ["foo", "barbaz", "quux"]
127
- end
128
- end
129
- end