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 +4 -4
- data/.github/workflows/main.yml +35 -0
- data/.github/workflows/publish.yml +34 -0
- data/Gemfile +3 -1
- data/Rakefile +14 -8
- data/ext/extconf.rb +36 -33
- data/ext/zopfli.c +13 -0
- data/lib/zopfli/version.rb +1 -1
- data/test/test_helper.rb +7 -0
- data/test/zopfli_test.rb +63 -0
- data/zopfli.gemspec +6 -7
- metadata +13 -54
- data/.travis.yml +0 -23
- data/spec/fixtures/alice29.txt +0 -3609
- data/spec/spec_helper.rb +0 -2
- data/spec/zopfli_spec.rb +0 -68
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ea7e06b8390382908a91c402f02754fa8f2a325699d424731f3903595cbe2d73
|
4
|
+
data.tar.gz: 138f867202c10b77cca5cd0c06545add1a630dd8721e5d67dc667d5257c55915
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
data/Rakefile
CHANGED
@@ -1,5 +1,7 @@
|
|
1
|
+
require "bundler/setup"
|
1
2
|
require "bundler/gem_tasks"
|
2
|
-
require "
|
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
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
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
|
-
|
22
|
-
|
23
|
-
|
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
|
data/ext/extconf.rb
CHANGED
@@ -8,37 +8,40 @@
|
|
8
8
|
# the ZopfliOptions first.
|
9
9
|
require "mkmf"
|
10
10
|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
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"
|
data/ext/zopfli.c
CHANGED
@@ -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
|
}
|
data/lib/zopfli/version.rb
CHANGED
data/test/test_helper.rb
ADDED
data/test/zopfli_test.rb
ADDED
@@ -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
|
data/zopfli.gemspec
CHANGED
@@ -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 =
|
12
|
-
spec.summary =
|
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.
|
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
|
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-
|
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
|
-
-
|
75
|
-
-
|
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.
|
84
|
+
rubygems_version: 3.2.3
|
125
85
|
signing_key:
|
126
86
|
specification_version: 4
|
127
87
|
summary: zopfli
|
128
88
|
test_files:
|
129
|
-
-
|
130
|
-
-
|
131
|
-
- spec/zopfli_spec.rb
|
89
|
+
- test/test_helper.rb
|
90
|
+
- test/zopfli_test.rb
|