image_optim 0.31.2 → 0.31.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/check.yml +7 -5
- data/.github/workflows/codeql.yml +1 -1
- data/.github/workflows/rubocop.yml +2 -2
- data/CHANGELOG.markdown +4 -0
- data/LICENSE.txt +1 -1
- data/README.markdown +4 -4
- data/image_optim.gemspec +1 -1
- data/lib/image_optim/cache.rb +1 -1
- data/lib/image_optim/config.rb +9 -1
- data/lib/image_optim/runner/option_parser.rb +4 -4
- data/lib/image_optim/runner.rb +1 -1
- data/lib/image_optim/space.rb +1 -1
- data/spec/files/config_with_range.yaml +3 -0
- data/spec/image_optim/config_spec.rb +39 -3
- data/spec/image_optim_spec.rb +3 -3
- metadata +5 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: edffa5fea26babe4654e681a829753b7df3d5d80a158a7b3d2974e97b46a49a5
|
4
|
+
data.tar.gz: 467cdc261c726ac97b5252b6b93507e4fac6e5d3804bd7fc17636ba32a6f565a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '0379e12d0d4ef8dd0af9e047a728bc9acf0177136b83b9b4aced834238067d0ab3248350bc1813cc76b33eaa3fc5751032a72c14f03a81d3dad9eed61abb0b99'
|
7
|
+
data.tar.gz: 68489aa06564d6f8555adf409c23454fb4b9d57fa74117cd9b1174787ad65bc56a101a8cce9e455ba0e3474f1a1b7e8c8b9707549768be1bb3a94a063c200721
|
data/.github/workflows/check.yml
CHANGED
@@ -20,12 +20,12 @@ jobs:
|
|
20
20
|
- '2.7'
|
21
21
|
- '3.0'
|
22
22
|
- '3.1'
|
23
|
-
-
|
23
|
+
- '3.2'
|
24
24
|
- jruby-9.3
|
25
25
|
- jruby-9.4
|
26
26
|
fail-fast: false
|
27
27
|
steps:
|
28
|
-
- uses: actions/checkout@
|
28
|
+
- uses: actions/checkout@v3
|
29
29
|
- uses: ruby/setup-ruby@v1
|
30
30
|
with:
|
31
31
|
ruby-version: "${{ matrix.ruby }}"
|
@@ -43,9 +43,11 @@ jobs:
|
|
43
43
|
- '2.7'
|
44
44
|
- '3.0'
|
45
45
|
- '3.1'
|
46
|
+
- '3.2'
|
46
47
|
fail-fast: false
|
48
|
+
continue-on-error: ${{ matrix.ruby == '3.2' }}
|
47
49
|
steps:
|
48
|
-
- uses: actions/checkout@
|
50
|
+
- uses: actions/checkout@v3
|
49
51
|
- uses: ruby/setup-ruby@v1
|
50
52
|
with:
|
51
53
|
ruby-version: "${{ matrix.ruby }}"
|
@@ -70,10 +72,10 @@ jobs:
|
|
70
72
|
env:
|
71
73
|
CC_TEST_REPORTER_ID: b433c6540d220a2da0663670c9b260806bafdb3a43c6f22b2e81bfb1f87b12fe
|
72
74
|
steps:
|
73
|
-
- uses: actions/checkout@
|
75
|
+
- uses: actions/checkout@v3
|
74
76
|
- uses: ruby/setup-ruby@v1
|
75
77
|
with:
|
76
|
-
ruby-version: '3
|
78
|
+
ruby-version: '3'
|
77
79
|
bundler-cache: true
|
78
80
|
- run: sudo npm install -g svgo
|
79
81
|
- run: curl -L "https://github.com/shssoichiro/oxipng/releases/download/v4.0.3/oxipng-4.0.3-x86_64-unknown-linux-musl.tar.gz" | tar -xz -C /usr/local/bin --strip-components 1 --wildcards '*oxipng'
|
data/CHANGELOG.markdown
CHANGED
@@ -2,6 +2,10 @@
|
|
2
2
|
|
3
3
|
## unreleased
|
4
4
|
|
5
|
+
## v0.31.3 (2023-02-17)
|
6
|
+
|
7
|
+
* Support Psych4/Ruby 3.1 changes to use safe_yaml methods by default [#203](https://github.com/toy/image_optim/issues/203) [#204](https://github.com/toy/image_optim/pull/204) [@oscillot](https://github.com/oscillot) [@toy](https://github.com/toy)
|
8
|
+
|
5
9
|
## v0.31.2 (2022-11-27)
|
6
10
|
|
7
11
|
* Support jruby 9.4 [@toy](https://github.com/toy)
|
data/LICENSE.txt
CHANGED
data/README.markdown
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
[![Gem Version](https://img.shields.io/gem/v/image_optim?logo=rubygems)](https://rubygems.org/gems/image_optim)
|
2
|
-
[![Build Status](https://img.shields.io/github/workflow/status/toy/image_optim/check
|
3
|
-
[![Rubocop](https://img.shields.io/github/workflow/status/toy/image_optim/rubocop
|
4
|
-
[![CodeQL](https://img.shields.io/github/workflow/status/toy/image_optim/codeql
|
2
|
+
[![Build Status](https://img.shields.io/github/actions/workflow/status/toy/image_optim/check.yml?logo=github)](https://github.com/toy/image_optim/actions/workflows/check.yml)
|
3
|
+
[![Rubocop](https://img.shields.io/github/actions/workflow/status/toy/image_optim/rubocop.yml?label=rubocop&logo=rubocop)](https://github.com/toy/image_optim/actions/workflows/rubocop.yml)
|
4
|
+
[![CodeQL](https://img.shields.io/github/actions/workflow/status/toy/image_optim/codeql.yml?label=codeql&logo=github)](https://github.com/toy/image_optim/actions/workflows/codeql.yml)
|
5
5
|
[![Code Climate](https://img.shields.io/codeclimate/maintainability/toy/image_optim?logo=codeclimate)](https://codeclimate.com/github/toy/image_optim)
|
6
6
|
[![Code Climate Coverage](https://img.shields.io/codeclimate/coverage/toy/image_optim?logo=codeclimate)](https://codeclimate.com/github/toy/image_optim)
|
7
7
|
[![Depfu](https://img.shields.io/depfu/toy/image_optim)](https://depfu.com/github/toy/image_optim)
|
@@ -390,4 +390,4 @@ In separate file [CHANGELOG.markdown](CHANGELOG.markdown).
|
|
390
390
|
|
391
391
|
## Copyright
|
392
392
|
|
393
|
-
Copyright (c) 2012-
|
393
|
+
Copyright (c) 2012-2023 Ivan Kuchin. See [LICENSE.txt](LICENSE.txt) for details.
|
data/image_optim.gemspec
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
4
|
s.name = 'image_optim'
|
5
|
-
s.version = '0.31.
|
5
|
+
s.version = '0.31.3'
|
6
6
|
s.summary = %q{Command line tool and ruby interface to optimize (lossless compress, optionally lossy) jpeg, png, gif and svg images using external utilities (advpng, gifsicle, jhead, jpeg-recompress, jpegoptim, jpegrescan, jpegtran, optipng, oxipng, pngcrush, pngout, pngquant, svgo)}
|
7
7
|
s.homepage = "https://github.com/toy/#{s.name}"
|
8
8
|
s.authors = ['Ivan Kuchin']
|
data/lib/image_optim/cache.rb
CHANGED
data/lib/image_optim/config.rb
CHANGED
@@ -33,7 +33,7 @@ class ImageOptim
|
|
33
33
|
end
|
34
34
|
return {} unless File.size?(full_path)
|
35
35
|
|
36
|
-
config =
|
36
|
+
config = load_yaml_file(full_path)
|
37
37
|
unless config.is_a?(Hash)
|
38
38
|
fail "expected hash, got #{config.inspect}"
|
39
39
|
end
|
@@ -43,6 +43,14 @@ class ImageOptim
|
|
43
43
|
warn "exception when reading #{full_path}: #{e}"
|
44
44
|
{}
|
45
45
|
end
|
46
|
+
|
47
|
+
def load_yaml_file(path)
|
48
|
+
if YAML.respond_to?(:safe_load_file)
|
49
|
+
YAML.safe_load_file(path, permitted_classes: [Range])
|
50
|
+
else
|
51
|
+
YAML.load_file(path)
|
52
|
+
end
|
53
|
+
end
|
46
54
|
end
|
47
55
|
|
48
56
|
# Merge config from files with passed options
|
@@ -202,13 +202,13 @@ ImageOptim::Runner::OptionParser::DEFINE = proc do |op, options|
|
|
202
202
|
type, marking = case
|
203
203
|
when [TrueClass, FalseClass, ImageOptim::TrueFalseNil].include?(type)
|
204
204
|
[type, 'B']
|
205
|
-
when
|
205
|
+
when type <= Integer
|
206
206
|
[Integer, 'N']
|
207
|
-
when
|
207
|
+
when type <= Array
|
208
208
|
[Array, 'a,b,c']
|
209
|
-
when
|
209
|
+
when type <= String
|
210
210
|
[String, 'S']
|
211
|
-
when ImageOptim::NonNegativeIntegerRange
|
211
|
+
when type == ImageOptim::NonNegativeIntegerRange
|
212
212
|
[type, 'M-N']
|
213
213
|
else
|
214
214
|
fail "Unknown type #{type}"
|
data/lib/image_optim/runner.rb
CHANGED
data/lib/image_optim/space.rb
CHANGED
@@ -223,7 +223,7 @@ describe ImageOptim::Config do
|
|
223
223
|
with(path).and_return(full_path)
|
224
224
|
expect(File).to receive(:size?).
|
225
225
|
with(full_path).and_return(true)
|
226
|
-
expect(
|
226
|
+
expect(IOConfig).to receive(:load_yaml_file).
|
227
227
|
with(full_path).and_return(stringified)
|
228
228
|
|
229
229
|
expect(IOConfig.read_options(path)).to eq(symbolized)
|
@@ -235,7 +235,7 @@ describe ImageOptim::Config do
|
|
235
235
|
with(path).and_return(full_path)
|
236
236
|
expect(File).to receive(:size?).
|
237
237
|
with(full_path).and_return(true)
|
238
|
-
expect(
|
238
|
+
expect(IOConfig).to receive(:load_yaml_file).
|
239
239
|
with(full_path).and_return([:config])
|
240
240
|
|
241
241
|
expect(IOConfig.read_options(path)).to eq({})
|
@@ -247,10 +247,46 @@ describe ImageOptim::Config do
|
|
247
247
|
with(path).and_return(full_path)
|
248
248
|
expect(File).to receive(:size?).
|
249
249
|
with(full_path).and_return(true)
|
250
|
-
expect(
|
250
|
+
expect(IOConfig).to receive(:load_yaml_file).
|
251
251
|
with(full_path).and_raise
|
252
252
|
|
253
253
|
expect(IOConfig.read_options(path)).to eq({})
|
254
254
|
end
|
255
255
|
end
|
256
|
+
|
257
|
+
describe '.load_yaml_file' do
|
258
|
+
describe 'selecting method' do
|
259
|
+
let(:path){ 'foo' }
|
260
|
+
let(:result){ 'bar' }
|
261
|
+
let(:yaml){ double }
|
262
|
+
|
263
|
+
before do
|
264
|
+
stub_const('YAML', yaml)
|
265
|
+
end
|
266
|
+
|
267
|
+
it 'uses YAML.safe_load_file if available' do
|
268
|
+
expect(yaml).to receive(:safe_load_file).
|
269
|
+
with(path, permitted_classes: [Range]).and_return(result)
|
270
|
+
|
271
|
+
expect(IOConfig.load_yaml_file(path)).to eq(result)
|
272
|
+
end
|
273
|
+
|
274
|
+
it 'uses YAML.load if safe_load_file is not available' do
|
275
|
+
expect(yaml).to receive(:load_file).
|
276
|
+
with(path).and_return(result)
|
277
|
+
|
278
|
+
expect(IOConfig.load_yaml_file(path)).to eq(result)
|
279
|
+
end
|
280
|
+
end
|
281
|
+
|
282
|
+
it 'handles yaml that includes `!ruby/range`' do
|
283
|
+
path = 'spec/files/config_with_range.yaml'
|
284
|
+
|
285
|
+
expect(IOConfig.load_yaml_file(path)).to eq({
|
286
|
+
'range' => 80..99,
|
287
|
+
'number' => 3,
|
288
|
+
'string' => 'foo',
|
289
|
+
})
|
290
|
+
end
|
291
|
+
end
|
256
292
|
end
|
data/spec/image_optim_spec.rb
CHANGED
@@ -121,9 +121,9 @@ describe ImageOptim do
|
|
121
121
|
it 'sends timeout to every worker' do
|
122
122
|
some_path = instance_of(ImageOptim::Path)
|
123
123
|
|
124
|
-
expect(workers[0]).to receive(:optimize).with(some_path, some_path, timeout: timer)
|
125
|
-
expect(workers[1]).to receive(:optimize).with(some_path, some_path, timeout: timer)
|
126
|
-
expect(workers[2]).to receive(:optimize).with(some_path, some_path, timeout: timer)
|
124
|
+
expect(workers[0]).to receive(:optimize).with(some_path, some_path, {timeout: timer})
|
125
|
+
expect(workers[1]).to receive(:optimize).with(some_path, some_path, {timeout: timer})
|
126
|
+
expect(workers[2]).to receive(:optimize).with(some_path, some_path, {timeout: timer})
|
127
127
|
|
128
128
|
image_optim.optimize_image(path)
|
129
129
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: image_optim
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.31.
|
4
|
+
version: 0.31.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ivan Kuchin
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-02-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: fspath
|
@@ -232,6 +232,7 @@ files:
|
|
232
232
|
- script/template/worker_analysis.erb
|
233
233
|
- script/update_worker_options_in_readme
|
234
234
|
- script/worker_analysis
|
235
|
+
- spec/files/config_with_range.yaml
|
235
236
|
- spec/image_optim/bin_resolver/comparable_condition_spec.rb
|
236
237
|
- spec/image_optim/bin_resolver/simple_version_spec.rb
|
237
238
|
- spec/image_optim/bin_resolver_spec.rb
|
@@ -292,7 +293,7 @@ licenses:
|
|
292
293
|
metadata:
|
293
294
|
bug_tracker_uri: https://github.com/toy/image_optim/issues
|
294
295
|
changelog_uri: https://github.com/toy/image_optim/blob/master/CHANGELOG.markdown
|
295
|
-
documentation_uri: https://www.rubydoc.info/gems/image_optim/0.31.
|
296
|
+
documentation_uri: https://www.rubydoc.info/gems/image_optim/0.31.3
|
296
297
|
source_code_uri: https://github.com/toy/image_optim
|
297
298
|
post_install_message: |
|
298
299
|
Rails image assets optimization is extracted into image_optim_rails gem
|
@@ -319,6 +320,7 @@ summary: Command line tool and ruby interface to optimize (lossless compress, op
|
|
319
320
|
jhead, jpeg-recompress, jpegoptim, jpegrescan, jpegtran, optipng, oxipng, pngcrush,
|
320
321
|
pngout, pngquant, svgo)
|
321
322
|
test_files:
|
323
|
+
- spec/files/config_with_range.yaml
|
322
324
|
- spec/image_optim/bin_resolver/comparable_condition_spec.rb
|
323
325
|
- spec/image_optim/bin_resolver/simple_version_spec.rb
|
324
326
|
- spec/image_optim/bin_resolver_spec.rb
|