zopfli 0.0.8 → 0.1.0

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
  SHA256:
3
- metadata.gz: 3121a61abacb0a102a03f4ec91ac9e6ee4a6132942d6e402bcfded04a25f39bd
4
- data.tar.gz: 544aee94aaaa325abcaee491d8b052a59dbd6809794fb2cdd4dd3fd787c466dd
3
+ metadata.gz: ea7e06b8390382908a91c402f02754fa8f2a325699d424731f3903595cbe2d73
4
+ data.tar.gz: 138f867202c10b77cca5cd0c06545add1a630dd8721e5d67dc667d5257c55915
5
5
  SHA512:
6
- metadata.gz: 5ff282d1b59f9bd4ab899cb1a16b63cadc64bb5a24c72b76289b136eadd8b50fcd14cb3a787169bc342ca1c6bb4ca5f405cc412eb3c13af6f4aa0c389cae2ec9
7
- data.tar.gz: 24c803340ae499cf43da0d62b4fd916a0a05db1db07967461a7e65145810b70129a8063d4b972a1dad67ec8a6691b0ecf4d057390a78be771efae17983cae142
6
+ metadata.gz: b6bbf82746d164940dd0781b512623fc22101c12240dc32b8745007f8ce04079d4fd07e6d1c25dea78f96bfaed8202c85ed18fb766041b4050a4dd3339bf46a1
7
+ data.tar.gz: f5415a40dee71d25d4cfd8279ccf5ec6ce3269551055be2dfddc8c375635481e39fbfdebc9f7547928631762a67dcada8e99c8da33cb669734bd2a218ff809e7
@@ -0,0 +1,35 @@
1
+ name: Ruby
2
+
3
+ on: [pull_request]
4
+
5
+ jobs:
6
+ build:
7
+ strategy:
8
+ fail-fast: false
9
+ matrix:
10
+ ruby: [2.5, 2.6, 2.7, 3.0]
11
+ runs-on: ubuntu-latest
12
+ steps:
13
+ - uses: actions/checkout@v2
14
+ with:
15
+ submodules: true
16
+ - name: Set up Ruby
17
+ uses: ruby/setup-ruby@v1
18
+ with:
19
+ ruby-version: ${{ matrix.ruby }}
20
+ bundler-cache: true
21
+ - name: Run the default task
22
+ run: |
23
+ bundle exec rake clobber test build
24
+ gem install --no-document "$(ls pkg/zopfli-*.gem)"
25
+ cat <<EOF | ruby
26
+ require "zopfli"
27
+ require "zlib"
28
+ if Zlib::Inflate.inflate(Zopfli.deflate(File.read("README.md"))) == File.read("README.md")
29
+ puts "OK"
30
+ exit 0
31
+ else
32
+ puts "NG"
33
+ exit 0
34
+ end
35
+ EOF
@@ -0,0 +1,34 @@
1
+ name: Publish Gem
2
+
3
+ on:
4
+ push:
5
+ tags:
6
+ - 'v*'
7
+
8
+ jobs:
9
+ build:
10
+ strategy:
11
+ fail-fast: false
12
+ matrix:
13
+ ruby: [3.0]
14
+ runs-on: ubuntu-latest
15
+ steps:
16
+ - uses: actions/checkout@v2
17
+ with:
18
+ submodules: true
19
+ - name: Set up Ruby
20
+ uses: ruby/setup-ruby@v1
21
+ with:
22
+ ruby-version: ${{ matrix.ruby }}
23
+ bundler-cache: true
24
+ - name: Run release task
25
+ run: |
26
+ mkdir -p ~/.gem
27
+ cat << EOF > ~/.gem/credentials
28
+ ---
29
+ :github: Bearer ${{secrets.GITHUB_TOKEN}}
30
+ :rubygems_api_key: ${{secrets.RUBYGEMS_API_KEY}}
31
+ EOF
32
+ chmod 600 ~/.gem/credentials
33
+ bundle exec rake release[remote]
34
+ rm -f ~/.gem/credentials
data/Gemfile CHANGED
@@ -3,4 +3,6 @@ source 'https://rubygems.org'
3
3
  # Specify your gem's dependencies in zopfli.gemspec
4
4
  gemspec
5
5
 
6
- gem 'travis'
6
+ gem "rake", "~> 13.0"
7
+ gem "test-unit", "~> 3.0"
8
+ gem "test-unit-rr"
data/Rakefile CHANGED
@@ -1,5 +1,7 @@
1
+ require "bundler/setup"
1
2
  require "bundler/gem_tasks"
2
- require "rspec/core/rake_task"
3
+ require "rake/clean"
4
+ require "rake/testtask"
3
5
  require "rbconfig"
4
6
 
5
7
  DLEXT = RbConfig::CONFIG["DLEXT"]
@@ -12,12 +14,16 @@ file "ext/zopfli.#{DLEXT}" => Dir.glob("ext/*{.rb,.c,.h}") do
12
14
  cp "ext/zopfli.#{DLEXT}", "lib"
13
15
  end
14
16
 
15
- task :clean do
16
- files = Dir["ext/*"] - ["ext/extconf.rb", "ext/zopfli.c"]
17
- files += ["ext/zopfli.#{DLEXT}", "lib/zopfli.#{DLEXT}"]
18
- rm_rf(files) unless files.empty?
17
+ Rake::TestTask.new(:test) do |t|
18
+ t.libs << "test"
19
+ t.test_files = FileList["test/**/*_test.rb"]
20
+ t.warning = true
21
+ t.verbose = true
19
22
  end
20
23
 
21
- RSpec::Core::RakeTask.new(:spec)
22
- task :spec => "ext/zopfli.#{DLEXT}"
23
- task :default => :spec
24
+ CLEAN.include "ext/zopfli.#{DLEXT}", "lib/zopfli.#{DLEXT}"
25
+ CLEAN.include "ext/*"
26
+ CLEAN.exclude "ext/extconf.rb", "ext/zopfli.c"
27
+
28
+ task :test => "ext/zopfli.#{DLEXT}"
29
+ task :default => :test
@@ -8,37 +8,40 @@
8
8
  # the ZopfliOptions first.
9
9
  require "mkmf"
10
10
 
11
- dst = File.dirname File.expand_path __FILE__
12
- src = File.join dst, "..", "vendor", "zopfli", "src", "zopfli"
13
-
14
- %w(
15
- blocksplitter.c
16
- blocksplitter.h
17
- cache.c
18
- cache.h
19
- deflate.c
20
- deflate.h
21
- gzip_container.c
22
- gzip_container.h
23
- hash.c
24
- hash.h
25
- katajainen.c
26
- katajainen.h
27
- lz77.c
28
- lz77.h
29
- squeeze.c
30
- squeeze.h
31
- symbols.h
32
- tree.c
33
- tree.h
34
- util.c
35
- util.h
36
- zlib_container.c
37
- zlib_container.h
38
- zopfli.h
39
- zopfli_lib.c
40
- ).each do |file|
41
- FileUtils.copy File.join(src, file), File.join(dst, file) if FileTest.exist? File.join(src, file)
11
+ dir_config("zopfli")
12
+ if have_header("zopfli/zopfli.h") && have_library("zopfli", "ZopfliCompress", "zopfli/zopfli.h")
13
+ create_makefile "zopfli"
14
+ else
15
+ dst = File.dirname File.expand_path __FILE__
16
+ src = File.join dst, "..", "vendor", "zopfli", "src", "zopfli"
17
+ %w[
18
+ blocksplitter.c
19
+ blocksplitter.h
20
+ cache.c
21
+ cache.h
22
+ deflate.c
23
+ deflate.h
24
+ gzip_container.c
25
+ gzip_container.h
26
+ hash.c
27
+ hash.h
28
+ katajainen.c
29
+ katajainen.h
30
+ lz77.c
31
+ lz77.h
32
+ squeeze.c
33
+ squeeze.h
34
+ symbols.h
35
+ tree.c
36
+ tree.h
37
+ util.c
38
+ util.h
39
+ zlib_container.c
40
+ zlib_container.h
41
+ zopfli.h
42
+ zopfli_lib.c
43
+ ].each do |file|
44
+ FileUtils.copy File.join(src, file), File.join(dst, file) if FileTest.exist? File.join(src, file)
45
+ end
46
+ create_makefile "zopfli"
42
47
  end
43
-
44
- create_makefile "zopfli"
@@ -1,6 +1,12 @@
1
1
  #include "ruby.h"
2
+ #ifdef HAVE_RUBY_THREAD_H
2
3
  #include "ruby/thread.h"
4
+ #endif
5
+ #ifdef HAVE_ZOPFLI_ZOPFLI_H
6
+ #include "zopfli/zopfli.h"
7
+ #else
3
8
  #include "zopfli.h"
9
+ #endif
4
10
 
5
11
  #define CSTR2SYM(x) ID2SYM(rb_intern(x))
6
12
  #define DEFAULT_FORMAT ZOPFLI_FORMAT_ZLIB
@@ -94,7 +100,11 @@ zopfli_deflate(int argc, VALUE *argv, VALUE self)
94
100
  args.out = NULL;
95
101
  args.outsize = 0;
96
102
 
103
+ #ifdef HAVE_RUBY_THREAD_H
97
104
  rb_thread_call_without_gvl(zopfli_deflate_no_gvl, (void *)&args, NULL, NULL);
105
+ #else
106
+ zopfli_deflate_no_gvl((void *)&args);
107
+ #endif
98
108
 
99
109
  out = rb_str_new((const char*)args.out, args.outsize);
100
110
 
@@ -106,6 +116,9 @@ zopfli_deflate(int argc, VALUE *argv, VALUE self)
106
116
  void
107
117
  Init_zopfli()
108
118
  {
119
+ #if HAVE_RB_EXT_RACTOR_SAFE
120
+ rb_ext_ractor_safe(true);
121
+ #endif
109
122
  VALUE rb_mZopfli = rb_define_module("Zopfli");
110
123
  rb_define_singleton_method(rb_mZopfli, "deflate", zopfli_deflate, -1);
111
124
  }
@@ -1,3 +1,3 @@
1
1
  module Zopfli
2
- VERSION = "0.0.8"
2
+ VERSION = "0.1.0"
3
3
  end
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ $LOAD_PATH.unshift File.expand_path("../lib", __dir__)
4
+ require "zopfli"
5
+
6
+ require "test-unit"
7
+ require "test/unit/rr"
@@ -0,0 +1,63 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "test_helper"
4
+ require "zlib"
5
+ require "stringio"
6
+
7
+ class ZopfliTest < Test::Unit::TestCase
8
+ T = [*"a".."z", *"A".."Z", *"0".."9"].freeze
9
+
10
+ def random_data(length = 1024)
11
+ Array.new(length) { T.sample }.join
12
+ end
13
+
14
+ test "VERSION" do
15
+ assert do
16
+ ::Zopfli.const_defined?(:VERSION)
17
+ end
18
+ end
19
+
20
+ test "well done" do
21
+ s = random_data
22
+ assert_equal s, Zlib::Inflate.inflate(Zopfli.deflate(s, format: :zlib))
23
+ end
24
+
25
+ test "well done(default format is zlib)" do
26
+ s = random_data
27
+ assert_equal Zopfli.deflate(s, format: :zlib), Zopfli.deflate(s)
28
+ end
29
+
30
+ test "well done(gzip format)" do
31
+ s = random_data
32
+ assert_equal s, Zlib::GzipReader.wrap(StringIO.new(Zopfli.deflate(s, format: :gzip)), &:read)
33
+ end
34
+
35
+ test "well done(deflate)" do
36
+ s = random_data
37
+ assert_nothing_raised do
38
+ Zopfli.deflate(s, format: :deflate)
39
+ end
40
+ end
41
+
42
+ test "raise error when pass invalid format" do
43
+ s = random_data
44
+ assert_raise ArgumentError do
45
+ Zopfli.deflate(s, format: :lzma)
46
+ end
47
+ end
48
+
49
+ sub_test_case "Ractor safe" do
50
+ test "able to invoke non-main ractor" do
51
+ unless defined? ::Ractor
52
+ notify "Ractor not defined"
53
+ omit
54
+ end
55
+ a = Array.new(2) do
56
+ Ractor.new(random_data) do |s|
57
+ Zlib::Inflate.inflate(Zopfli.deflate(s)) == s
58
+ end
59
+ end
60
+ assert_equal [true, true], a.map(&:take)
61
+ end
62
+ end
63
+ end
@@ -8,12 +8,15 @@ Gem::Specification.new do |spec|
8
8
  spec.version = Zopfli::VERSION
9
9
  spec.authors = ["miyucy"]
10
10
  spec.email = ["fistfvck@gmail.com"]
11
- spec.description = %q{zopfli}
12
- spec.summary = %q{zopfli}
11
+ spec.description = "zopfli"
12
+ spec.summary = "zopfli"
13
13
  spec.homepage = "http://github.com/miyucy/zopfli"
14
14
  spec.license = "MIT"
15
15
 
16
- spec.test_files = `git ls-files -z -- spec`.split("\x0")
16
+ spec.metadata["homepage_uri"] = spec.homepage
17
+ spec.metadata["source_code_uri"] = spec.homepage
18
+
19
+ spec.test_files = `git ls-files -z -- test`.split("\x0")
17
20
  spec.files = `git ls-files -z`.split("\x0")
18
21
  spec.files -= spec.test_files
19
22
  spec.files -= ['vendor/zopfli']
@@ -23,8 +26,4 @@ Gem::Specification.new do |spec|
23
26
  spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
24
27
  spec.require_paths = ["lib"]
25
28
  spec.extensions = ["ext/extconf.rb"]
26
-
27
- spec.add_development_dependency "bundler", "~> 2.1.4"
28
- spec.add_development_dependency "rake"
29
- spec.add_development_dependency "rspec"
30
29
  end
metadata CHANGED
@@ -1,57 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: zopfli
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.8
4
+ version: 0.1.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-10-02 00:00:00.000000000 Z
12
- dependencies:
13
- - !ruby/object:Gem::Dependency
14
- name: bundler
15
- requirement: !ruby/object:Gem::Requirement
16
- requirements:
17
- - - "~>"
18
- - !ruby/object:Gem::Version
19
- version: 2.1.4
20
- type: :development
21
- prerelease: false
22
- version_requirements: !ruby/object:Gem::Requirement
23
- requirements:
24
- - - "~>"
25
- - !ruby/object:Gem::Version
26
- version: 2.1.4
27
- - !ruby/object:Gem::Dependency
28
- name: rake
29
- requirement: !ruby/object:Gem::Requirement
30
- requirements:
31
- - - ">="
32
- - !ruby/object:Gem::Version
33
- version: '0'
34
- type: :development
35
- prerelease: false
36
- version_requirements: !ruby/object:Gem::Requirement
37
- requirements:
38
- - - ">="
39
- - !ruby/object:Gem::Version
40
- version: '0'
41
- - !ruby/object:Gem::Dependency
42
- name: rspec
43
- requirement: !ruby/object:Gem::Requirement
44
- requirements:
45
- - - ">="
46
- - !ruby/object:Gem::Version
47
- version: '0'
48
- type: :development
49
- prerelease: false
50
- version_requirements: !ruby/object:Gem::Requirement
51
- requirements:
52
- - - ">="
53
- - !ruby/object:Gem::Version
54
- version: '0'
11
+ date: 2020-12-28 00:00:00.000000000 Z
12
+ dependencies: []
55
13
  description: zopfli
56
14
  email:
57
15
  - fistfvck@gmail.com
@@ -60,9 +18,10 @@ extensions:
60
18
  - ext/extconf.rb
61
19
  extra_rdoc_files: []
62
20
  files:
21
+ - ".github/workflows/main.yml"
22
+ - ".github/workflows/publish.yml"
63
23
  - ".gitignore"
64
24
  - ".gitmodules"
65
- - ".travis.yml"
66
25
  - Gemfile
67
26
  - LICENSE.txt
68
27
  - README.md
@@ -71,9 +30,8 @@ files:
71
30
  - ext/zopfli.c
72
31
  - lib/zopfli/version.rb
73
32
  - smoke.sh
74
- - spec/fixtures/alice29.txt
75
- - spec/spec_helper.rb
76
- - spec/zopfli_spec.rb
33
+ - test/test_helper.rb
34
+ - test/zopfli_test.rb
77
35
  - vendor/zopfli/COPYING
78
36
  - vendor/zopfli/src/zopfli/blocksplitter.c
79
37
  - vendor/zopfli/src/zopfli/blocksplitter.h
@@ -105,7 +63,9 @@ files:
105
63
  homepage: http://github.com/miyucy/zopfli
106
64
  licenses:
107
65
  - MIT
108
- metadata: {}
66
+ metadata:
67
+ homepage_uri: http://github.com/miyucy/zopfli
68
+ source_code_uri: http://github.com/miyucy/zopfli
109
69
  post_install_message:
110
70
  rdoc_options: []
111
71
  require_paths:
@@ -121,11 +81,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
121
81
  - !ruby/object:Gem::Version
122
82
  version: '0'
123
83
  requirements: []
124
- rubygems_version: 3.0.8
84
+ rubygems_version: 3.2.3
125
85
  signing_key:
126
86
  specification_version: 4
127
87
  summary: zopfli
128
88
  test_files:
129
- - spec/fixtures/alice29.txt
130
- - spec/spec_helper.rb
131
- - spec/zopfli_spec.rb
89
+ - test/test_helper.rb
90
+ - test/zopfli_test.rb