image_optim 0.24.0 → 0.24.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,15 +1,7 @@
1
1
  ---
2
- !binary "U0hBMQ==":
3
- metadata.gz: !binary |-
4
- ZmNjZjBjNmNkYzRmNjQxMmZkMDg3ZGYzYjY5MTQ3MjllYmVjOTQ1MQ==
5
- data.tar.gz: !binary |-
6
- YmZlNWUxYzFmZmU4NDFmZjgxZDYwOTNlNzBlZTA0NTc0YzQ4NzJkNA==
2
+ SHA1:
3
+ metadata.gz: bb7d895e52e7a9630b4c7d6970b8619a6d121fa1
4
+ data.tar.gz: 5a806c1499ef299274fcc427c2718262a4e94ee3
7
5
  SHA512:
8
- metadata.gz: !binary |-
9
- NGYzMjA1MTMxMTJhMzM1ODg1NTc4MGIyNzk5ZWNiMzFkMGRlMjQ5OTZjNTFm
10
- YjJiZTdkZjgxYmQ3Y2U2MmNhMmRhYzE0YjkxZmJlY2EwMTg1MDNiMjUyMGNk
11
- NjFhYWM3ZGVlOWY4MTRjYjg4ZDUwZmUyMzI1OTBhYTM4ZDI4ZGY=
12
- data.tar.gz: !binary |-
13
- MjQ0MjZkN2RhYjYyMWU2ZWJhYTVhMDkyMjI3YWY0NTM1ZTgxN2U5YjY2NTM3
14
- YmQ3OWNkNzNjZmI4NjFjM2I0YTYxZWE1ODQ5ZjU0ODYyNTVkOGZjMmE1MDE4
15
- YjIyODM5OTI3YzQ5N2Y4MmYxMDFkYTc0OGQ2MmNkMjQ4MGZmMGQ=
6
+ metadata.gz: 9c3745cbf55f2b9bcd4a3f9cf64c680790a13cfc3da4fadad950f5f7a997199768442b6fc8d781cbc7d5ed22ddcdc314717b78104168564d4bc13b006b170d4d
7
+ data.tar.gz: 4e4873812c576ee9428a8dfa20b69b4977f349ee9692fd36740b2266934b310ef96abec8d7f78531d2dddeef243d308e8ee444ca56c236f372e58bf594fca519
data/.rubocop.yml CHANGED
@@ -6,9 +6,18 @@ AllCops:
6
6
  Lint/EndAlignment:
7
7
  AlignWith: variable
8
8
 
9
+ Lint/UnneededSplatExpansion:
10
+ Enabled: false
11
+
9
12
  Metrics/AbcSize:
10
13
  Max: 30
11
14
 
15
+ Metrics/BlockLength:
16
+ Exclude:
17
+ - 'lib/image_optim/runner/option_parser.rb'
18
+ - 'script/worker_analysis'
19
+ - 'spec/**/*.rb'
20
+
12
21
  Metrics/ClassLength:
13
22
  Max: 150
14
23
 
data/.travis.yml CHANGED
@@ -34,6 +34,8 @@ before_install: |
34
34
  }
35
35
  fi
36
36
  )
37
+ after_success:
38
+ - if [ -n "$CODECLIMATE" ]; then bundle exec codeclimate-test-reporter; fi
37
39
  matrix:
38
40
  fast_finish: true
39
41
  include:
data/CHANGELOG.markdown CHANGED
@@ -2,6 +2,12 @@
2
2
 
3
3
  ## unreleased
4
4
 
5
+ ## v0.24.1 (2016-11-20)
6
+
7
+ * Use `image_size ~> 1.5` with `apng` detection, so apng images are not optimised to one frame version [#142](https://github.com/toy/image_optim/issues/142) [@toy](https://github.com/toy)
8
+ * Don't show `?` for unknown bin version in message about inability to determine version [@toy](https://github.com/toy)
9
+ * Deduplicate bin resolving error messages [@toy](https://github.com/toy)
10
+
5
11
  ## v0.24.0 (2016-08-14)
6
12
 
7
13
  * Rails image assets optimization is extracted into [image\_optim\_rails gem](https://github.com/toy/image_optim_rails) [#127](https://github.com/toy/image_optim/issues/127) [@toy](https://github.com/toy)
@@ -237,7 +243,7 @@
237
243
 
238
244
  ## v0.7.1 (2013-01-17)
239
245
 
240
- * Use more compatible redirect syntax `>&` [#9](https://github.com/toy/image_optim/issues/9) @"Chris Thompson"
246
+ * Use more compatible redirect syntax `>&` [#9](https://github.com/toy/image_optim/issues/9) [@teaforthecat](https://github.com/teaforthecat)
241
247
 
242
248
  ## v0.7.0 (2013-01-17)
243
249
 
data/Gemfile CHANGED
@@ -3,5 +3,8 @@ source 'https://rubygems.org'
3
3
  gemspec
4
4
 
5
5
  if ENV['CODECLIMATE']
6
- gem 'codeclimate-test-reporter', :group => :test, :require => nil
6
+ group :test do
7
+ gem 'simplecov'
8
+ gem 'codeclimate-test-reporter'
9
+ end
7
10
  end
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.24.0'
5
+ s.version = '0.24.1'
6
6
  s.summary = %q{Optimize (lossless compress, optionally lossy) images (jpeg, png, gif, svg) using external utilities (advpng, gifsicle, jhead, jpeg-recompress, jpegoptim, jpegrescan, jpegtran, optipng, pngcrush, pngout, pngquant, svgo)}
7
7
  s.homepage = "http://github.com/toy/#{s.name}"
8
8
  s.authors = ['Ivan Kuchin']
@@ -21,7 +21,7 @@ You can safely remove `config.assets.image_optim = false` if you are not going t
21
21
  EOF
22
22
 
23
23
  s.add_dependency 'fspath', '~> 3.0'
24
- s.add_dependency 'image_size', '~> 1.3'
24
+ s.add_dependency 'image_size', '~> 1.5'
25
25
  s.add_dependency 'exifr', '~> 1.2', '>= 1.2.2'
26
26
  s.add_dependency 'progress', '~> 3.0', '>= 3.0.1'
27
27
  s.add_dependency 'in_threads', '~> 1.3'
@@ -48,7 +48,9 @@ class ImageOptim
48
48
 
49
49
  # Fail if version will not work properly
50
50
  def check_fail!
51
- fail UnknownVersion, "didn't get version of #{self}" unless version
51
+ unless version
52
+ fail UnknownVersion, "could not get version of #{name} at #{path}"
53
+ end
52
54
 
53
55
  FAIL_CHECKS.each do |bin_name, matcher, message|
54
56
  next unless bin_name == name
@@ -65,11 +65,12 @@ class ImageOptim
65
65
  end
66
66
 
67
67
  unless errors.empty?
68
+ messages = errors.map(&:to_s).uniq
68
69
  if image_optim.skip_missing_workers
69
- errors.each{ |error| warn error }
70
+ messages.each{ |message| warn message }
70
71
  else
71
- message = ['Bin resolving errors:', *errors].join("\n")
72
- fail BinResolver::Error, message
72
+ joint_message = ['Bin resolving errors:', *messages].join("\n")
73
+ fail BinResolver::Error, joint_message
73
74
  end
74
75
  end
75
76
 
@@ -81,10 +81,6 @@ Process.times.class.class_eval do
81
81
  end
82
82
 
83
83
  ImageOptim::Path.class_eval do
84
- def shellescape
85
- to_s.shellescape
86
- end
87
-
88
84
  def digest
89
85
  @digest ||= Digest::SHA256.file(to_s).hexdigest
90
86
  end
@@ -313,13 +309,13 @@ class Analyser
313
309
  images = [flatten_animation(@path), flatten_animation(other)]
314
310
 
315
311
  alpha_presence = images.map do |image|
316
- Cmd.capture("identify -format '%A' #{image.shellescape}")
312
+ Cmd.capture("identify -format '%A' #{image.to_s.shellescape}")
317
313
  end
318
314
  if alpha_presence.uniq.length == 2
319
315
  images.map!{ |image| underlay_noise(image) }
320
316
  end
321
317
 
322
- nrmse_command = %W[
318
+ nrmse = Cmd.capture(%W[
323
319
  convert
324
320
  #{images[0]} -auto-orient
325
321
  #{images[1]} -auto-orient
@@ -327,8 +323,7 @@ class Analyser
327
323
  -compare
328
324
  -format %[distortion]
329
325
  info:
330
- ].shelljoin
331
- nrmse = Cmd.capture(nrmse_command).to_f
326
+ ].shelljoin).to_f
332
327
  unless $CHILD_STATUS.success?
333
328
  fail "failed comparison of #{@path} with #{other}"
334
329
  end
@@ -342,14 +337,11 @@ class Analyser
342
337
  flattened = image.temp_path
343
338
  Cmd.run(*%W[
344
339
  convert
345
- #{image.shellescape}
340
+ #{image}
346
341
  -coalesce
347
342
  -append
348
- #{flattened.shellescape}
349
- ])
350
- unless $CHILD_STATUS.success?
351
- fail "failed flattening of #{image}"
352
- end
343
+ #{flattened}
344
+ ]) || fail("failed flattening of #{image}")
353
345
  flattened
354
346
  else
355
347
  image
@@ -362,16 +354,13 @@ class Analyser
362
354
  with_noise = image.temp_path
363
355
  Cmd.run(*%W[
364
356
  convert
365
- #{image.shellescape}
357
+ #{image}
366
358
  +noise Random
367
- #{image.shellescape}
359
+ #{image}
368
360
  -flatten
369
361
  -alpha off
370
- #{with_noise.shellescape}
371
- ])
372
- unless $CHILD_STATUS.success?
373
- fail "failed underlaying noise to #{image}"
374
- end
362
+ #{with_noise}
363
+ ]) || fail("failed underlaying noise to #{image}")
375
364
  with_noise
376
365
  end
377
366
  end
@@ -255,7 +255,7 @@ describe ImageOptim::BinResolver do
255
255
  5.times do
256
256
  expect do
257
257
  resolver.resolve!(:pngcrush)
258
- end.to raise_error Bin::UnknownVersion
258
+ end.to raise_error Bin::UnknownVersion, %r{pngcrush at /bin/pngcrush}
259
259
  end
260
260
  end
261
261
 
@@ -269,7 +269,7 @@ describe ImageOptim::BinResolver do
269
269
  5.times do
270
270
  expect do
271
271
  resolver.resolve!(:pngcrush)
272
- end.to raise_error Bin::BadVersion
272
+ end.to raise_error Bin::BadVersion, /is known to produce broken pngs/
273
273
  end
274
274
  end
275
275
 
@@ -280,7 +280,7 @@ describe ImageOptim::BinResolver do
280
280
  expect(Bin).to receive(:new).and_return(bin)
281
281
  allow(bin).to receive(:version).and_return(SimpleVersion.new('1.15'))
282
282
 
283
- expect(bin).to receive(:warn).once
283
+ expect(bin).to receive(:warn).once.with(match(/does not use zopfli/))
284
284
 
285
285
  5.times do
286
286
  resolver.resolve!(:pngcrush)
@@ -160,11 +160,11 @@ describe ImageOptim::Worker do
160
160
 
161
161
  describe 'with missing workers' do
162
162
  let(:workers) do
163
- Array.new(3) do |i|
163
+ %w[a b c c].map do |bin|
164
164
  worker = worker_double
165
- unless i == 1
165
+ unless bin == 'b'
166
166
  allow(worker).to receive(:resolve_used_bins!).
167
- and_raise(BinResolver::BinNotFound, "not found #{i}")
167
+ and_raise(BinResolver::BinNotFound, "not found #{bin}")
168
168
  end
169
169
  worker
170
170
  end
@@ -176,32 +176,27 @@ describe ImageOptim::Worker do
176
176
  end
177
177
 
178
178
  describe 'if skip_missing_workers is true' do
179
- define :bin_not_found do |message|
180
- match do |error|
181
- error.is_a?(BinResolver::BinNotFound) && error.message == message
182
- end
183
- end
184
-
185
- it 'shows warnings and returns resolved workers ' do
179
+ it 'shows deduplicated warnings and returns resolved workers ' do
186
180
  allow(image_optim).to receive(:skip_missing_workers).and_return(true)
187
181
 
188
- expect(Worker).to receive(:warn).
189
- once.with(bin_not_found('not found 0'))
190
- expect(Worker).to receive(:warn).
191
- once.with(bin_not_found('not found 2'))
182
+ expect(Worker).to receive(:warn).once.with('not found a')
183
+ expect(Worker).to receive(:warn).once.with('not found c')
192
184
 
193
- expect(Worker.create_all(image_optim){ {} }).
194
- to eq([workers[1]])
185
+ expect(Worker.create_all(image_optim){ {} }).to eq([workers[1]])
195
186
  end
196
187
  end
197
188
 
198
189
  describe 'if skip_missing_workers is false' do
199
- it 'fails with a joint exception' do
190
+ it 'fails with a joint exception of deduplicated messages' do
200
191
  allow(image_optim).to receive(:skip_missing_workers).and_return(false)
201
192
 
202
193
  expect do
203
194
  Worker.create_all(image_optim){ {} }
204
- end.to raise_error(BinResolver::Error, /not found 0\nnot found 2/)
195
+ end.to raise_error(BinResolver::Error, [
196
+ 'Bin resolving errors:',
197
+ 'not found a',
198
+ 'not found c',
199
+ ].join("\n"))
205
200
  end
206
201
  end
207
202
  end
data/spec/spec_helper.rb CHANGED
@@ -1,6 +1,6 @@
1
- if ENV['CODECLIMATE'] && ENV['CODECLIMATE_REPO_TOKEN']
2
- require 'codeclimate-test-reporter'
3
- CodeClimate::TestReporter.start
1
+ if ENV['CODECLIMATE']
2
+ require 'simplecov'
3
+ SimpleCov.start
4
4
  end
5
5
 
6
6
  require 'image_optim/pack'
@@ -26,11 +26,11 @@ def flatten_animation(image)
26
26
  flattened = image.temp_path
27
27
  command = %W[
28
28
  convert
29
- #{image.to_s.shellescape}
29
+ #{image}
30
30
  -coalesce
31
31
  -append
32
- #{flattened.to_s.shellescape}
33
- ].join(' ')
32
+ #{flattened}
33
+ ].shelljoin
34
34
  expect(ImageOptim::Cmd.run(command)).to be_truthy
35
35
  flattened
36
36
  else
@@ -41,7 +41,7 @@ end
41
41
  def mepp(image_a, image_b)
42
42
  coalesce_a = flatten_animation(image_a)
43
43
  coalesce_b = flatten_animation(image_b)
44
- command = %W[
44
+ output = ImageOptim::Cmd.capture(%W[
45
45
  compare
46
46
  -metric MEPP
47
47
  -alpha Background
@@ -49,14 +49,12 @@ def mepp(image_a, image_b)
49
49
  #{coalesce_b.to_s.shellescape}
50
50
  #{ImageOptim::Path::NULL}
51
51
  2>&1
52
- ].join(' ')
53
- output = ImageOptim::Cmd.capture(command)
54
- if [0, 1].include?($CHILD_STATUS.exitstatus)
55
- num_r = '\d+(?:\.\d+(?:[eE][-+]?\d+)?)?'
56
- output[/\((#{num_r}), #{num_r}\)/, 1].to_f
57
- else
52
+ ].join(' '))
53
+ unless [0, 1].include?($CHILD_STATUS.exitstatus)
58
54
  fail "compare #{image_a} with #{image_b} failed with `#{output}`"
59
55
  end
56
+ num_r = '\d+(?:\.\d+(?:[eE][-+]?\d+)?)?'
57
+ output[/\((#{num_r}), #{num_r}\)/, 1].to_f
60
58
  end
61
59
 
62
60
  RSpec::Matchers.define :be_smaller_than do |expected|
@@ -78,7 +76,7 @@ module CapabilityCheckHelpers
78
76
  def any_file_modes_allowed?
79
77
  Tempfile.open 'posix' do |f|
80
78
  File.chmod(0, f.path)
81
- (File.stat(f.path).mode & 0o777).zero?
79
+ return (File.stat(f.path).mode & 0o777).zero?
82
80
  end
83
81
  end
84
82
 
metadata CHANGED
@@ -1,131 +1,145 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: image_optim
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.24.0
4
+ version: 0.24.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ivan Kuchin
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-08-14 00:00:00.000000000 Z
11
+ date: 2016-11-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: fspath
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ~>
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
19
  version: '3.0'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ~>
24
+ - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: '3.0'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: image_size
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ~>
31
+ - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '1.3'
33
+ version: '1.5'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - ~>
38
+ - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: '1.3'
40
+ version: '1.5'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: exifr
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - ~>
45
+ - - "~>"
46
46
  - !ruby/object:Gem::Version
47
47
  version: '1.2'
48
- - - ! '>='
48
+ - - ">="
49
49
  - !ruby/object:Gem::Version
50
50
  version: 1.2.2
51
51
  type: :runtime
52
52
  prerelease: false
53
53
  version_requirements: !ruby/object:Gem::Requirement
54
54
  requirements:
55
- - - ~>
55
+ - - "~>"
56
56
  - !ruby/object:Gem::Version
57
57
  version: '1.2'
58
- - - ! '>='
58
+ - - ">="
59
59
  - !ruby/object:Gem::Version
60
60
  version: 1.2.2
61
61
  - !ruby/object:Gem::Dependency
62
62
  name: progress
63
63
  requirement: !ruby/object:Gem::Requirement
64
64
  requirements:
65
- - - ~>
65
+ - - "~>"
66
66
  - !ruby/object:Gem::Version
67
67
  version: '3.0'
68
- - - ! '>='
68
+ - - ">="
69
69
  - !ruby/object:Gem::Version
70
70
  version: 3.0.1
71
71
  type: :runtime
72
72
  prerelease: false
73
73
  version_requirements: !ruby/object:Gem::Requirement
74
74
  requirements:
75
- - - ~>
75
+ - - "~>"
76
76
  - !ruby/object:Gem::Version
77
77
  version: '3.0'
78
- - - ! '>='
78
+ - - ">="
79
79
  - !ruby/object:Gem::Version
80
80
  version: 3.0.1
81
81
  - !ruby/object:Gem::Dependency
82
82
  name: in_threads
83
83
  requirement: !ruby/object:Gem::Requirement
84
84
  requirements:
85
- - - ~>
85
+ - - "~>"
86
86
  - !ruby/object:Gem::Version
87
87
  version: '1.3'
88
88
  type: :runtime
89
89
  prerelease: false
90
90
  version_requirements: !ruby/object:Gem::Requirement
91
91
  requirements:
92
- - - ~>
92
+ - - "~>"
93
93
  - !ruby/object:Gem::Version
94
94
  version: '1.3'
95
95
  - !ruby/object:Gem::Dependency
96
96
  name: image_optim_pack
97
97
  requirement: !ruby/object:Gem::Requirement
98
98
  requirements:
99
- - - ~>
99
+ - - "~>"
100
100
  - !ruby/object:Gem::Version
101
101
  version: '0.2'
102
- - - ! '>='
102
+ - - ">="
103
103
  - !ruby/object:Gem::Version
104
104
  version: 0.2.2
105
105
  type: :development
106
106
  prerelease: false
107
107
  version_requirements: !ruby/object:Gem::Requirement
108
108
  requirements:
109
- - - ~>
109
+ - - "~>"
110
110
  - !ruby/object:Gem::Version
111
111
  version: '0.2'
112
- - - ! '>='
112
+ - - ">="
113
113
  - !ruby/object:Gem::Version
114
114
  version: 0.2.2
115
115
  - !ruby/object:Gem::Dependency
116
116
  name: rspec
117
117
  requirement: !ruby/object:Gem::Requirement
118
118
  requirements:
119
- - - ~>
119
+ - - "~>"
120
120
  - !ruby/object:Gem::Version
121
121
  version: '3.0'
122
122
  type: :development
123
123
  prerelease: false
124
124
  version_requirements: !ruby/object:Gem::Requirement
125
125
  requirements:
126
- - - ~>
126
+ - - "~>"
127
127
  - !ruby/object:Gem::Version
128
128
  version: '3.0'
129
+ - !ruby/object:Gem::Dependency
130
+ name: rubocop
131
+ requirement: !ruby/object:Gem::Requirement
132
+ requirements:
133
+ - - "~>"
134
+ - !ruby/object:Gem::Version
135
+ version: '0.37'
136
+ type: :development
137
+ prerelease: false
138
+ version_requirements: !ruby/object:Gem::Requirement
139
+ requirements:
140
+ - - "~>"
141
+ - !ruby/object:Gem::Version
142
+ version: '0.37'
129
143
  description:
130
144
  email:
131
145
  executables:
@@ -133,10 +147,10 @@ executables:
133
147
  extensions: []
134
148
  extra_rdoc_files: []
135
149
  files:
136
- - .appveyor.yml
137
- - .gitignore
138
- - .rubocop.yml
139
- - .travis.yml
150
+ - ".appveyor.yml"
151
+ - ".gitignore"
152
+ - ".rubocop.yml"
153
+ - ".travis.yml"
140
154
  - CHANGELOG.markdown
141
155
  - CONTRIBUTING.markdown
142
156
  - Gemfile
@@ -240,24 +254,20 @@ homepage: http://github.com/toy/image_optim
240
254
  licenses:
241
255
  - MIT
242
256
  metadata: {}
243
- post_install_message: ! 'Rails image assets optimization is extracted into image_optim_rails
244
- gem
245
-
246
- You can safely remove `config.assets.image_optim = false` if you are not going to
247
- use that gem
248
-
249
- '
257
+ post_install_message: |
258
+ Rails image assets optimization is extracted into image_optim_rails gem
259
+ You can safely remove `config.assets.image_optim = false` if you are not going to use that gem
250
260
  rdoc_options: []
251
261
  require_paths:
252
262
  - lib
253
263
  required_ruby_version: !ruby/object:Gem::Requirement
254
264
  requirements:
255
- - - ! '>='
265
+ - - ">="
256
266
  - !ruby/object:Gem::Version
257
267
  version: '0'
258
268
  required_rubygems_version: !ruby/object:Gem::Requirement
259
269
  requirements:
260
- - - ! '>='
270
+ - - ">="
261
271
  - !ruby/object:Gem::Version
262
272
  version: '0'
263
273
  requirements: []
@@ -317,4 +327,3 @@ test_files:
317
327
  - spec/images/transparency2.png
318
328
  - spec/images/vergroessert.jpg
319
329
  - spec/spec_helper.rb
320
- has_rdoc: