image_optim 0.28.0 → 0.29.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: 818160db3036f1fd4305077d943e59991aebe5fb1023b3c7e46db02e63c5fb37
4
- data.tar.gz: 76c76ec43a5c05b9e35de21757928ec8793709a3db27e8a982cc46612f8d491e
3
+ metadata.gz: 9035f1f635ab728b4622dc5e99d2f5e9f96eab86ea35038c4037587fd3ca90d7
4
+ data.tar.gz: d24f6305c1461483d9a67a9338c4e9385ef9282070aecdc53cf0b79e7bffb5ed
5
5
  SHA512:
6
- metadata.gz: f30e6f493be6ff4e98407bb611d8fd868733af14da078b225b6708c7f6aabaa41d00b08e82c3801c788bd70c4d7278ee91a186a3dc54bc7bdcc16e685d27c7a8
7
- data.tar.gz: b3402efe19eeb298518cfeb117f38c7aca1e0bbabe68313663107269d3ab87f8900f238db182042377adb5ebc12f69dd133ee5c922fcbde54c4b647bc9efa836
6
+ metadata.gz: 3501154596158ee61209215d7c3a4df1b82d7384d8b54248a16992e5897701eb1e1c10bca9bbbe92312f728e403544dfa6f0dd3c3dfc33918026497550f72ef4
7
+ data.tar.gz: 72ef8a7dacc6a7cc8850d996a716a5df2098cbe47e91f58a051e95664a83494346c0daa03f61384f4bd0c6674a65e4c383ac931863ef31ffed2cc6a8d57ef4a3
data/.appveyor.yml CHANGED
@@ -6,6 +6,8 @@ install:
6
6
  - gem --version
7
7
  - bundle package --all
8
8
 
9
+ - ps: Install-Product node
10
+
9
11
  - ps: git --work-tree=tmp\bin checkout origin/windows-binaries -- '*.exe'
10
12
 
11
13
  - ps: | # svgo
@@ -0,0 +1,9 @@
1
+ - id: image_optim
2
+ name: image_optim
3
+ entry: image_optim
4
+ language: ruby
5
+ types:
6
+ - image
7
+ args: []
8
+ additional_dependencies:
9
+ - image_optim_pack
data/.rubocop.yml CHANGED
@@ -103,6 +103,9 @@ Style/ExpandPathArguments:
103
103
  Style/FormatStringToken:
104
104
  Enabled: false
105
105
 
106
+ Style/HashConversion:
107
+ Enabled: false
108
+
106
109
  Style/HashEachMethods:
107
110
  Enabled: true
108
111
 
data/.travis.yml CHANGED
@@ -1,5 +1,4 @@
1
- sudo: false
2
- dist: trusty
1
+ dist: xenial
3
2
  language: ruby
4
3
  cache:
5
4
  bundler: true
@@ -13,10 +12,11 @@ rvm:
13
12
  - '2.2.10'
14
13
  - '2.3.8'
15
14
  - '2.4.10'
16
- - '2.5.8'
17
- - '2.6.6'
18
- - '2.7.2'
19
- - 'jruby-9.2.11.1'
15
+ - '2.5.9'
16
+ - '2.6.7'
17
+ - '2.7.3'
18
+ - '3.0.1'
19
+ - 'jruby-9.2.14.0'
20
20
  script:
21
21
  - bundle exec image_optim --info
22
22
  - bundle exec rspec
@@ -26,8 +26,8 @@ before_install:
26
26
  - update_rubygems
27
27
  - gem install bundler || gem install bundler --version '< 2'
28
28
  - nvm install stable
29
- - mkdir -p ~/bin
30
29
  - command -v svgo || npm install -g svgo
30
+ - mkdir -p ~/bin
31
31
  - command -v pngout || curl -L "https://www.jonof.id.au/files/kenutils/pngout-20200115-linux.tar.gz" | tar -xz -C ~/bin --strip-components 2 --wildcards '*/amd64/pngout'
32
32
  matrix:
33
33
  include:
data/CHANGELOG.markdown CHANGED
@@ -2,6 +2,13 @@
2
2
 
3
3
  ## unreleased
4
4
 
5
+ ## v0.29.0 (2021-04-28)
6
+
7
+ * Require at least ruby 1.9.3 [@toy](https://github.com/toy)
8
+ * Add support for use as [pre-commit](https://pre-commit.com/) hook [#192](https://github.com/toy/image_optim/pull/192) [@proinsias](https://github.com/proinsias)
9
+ * Fix `Path#copy_metadata` by rescuing also `Errno::EACCES` as it is done in `fileutils` [#187](https://github.com/toy/image_optim/issues/187) [@toy](https://github.com/toy)
10
+ * More precise regular expression for capturing svgo version [@toy](https://github.com/toy)
11
+
5
12
  ## v0.28.0 (2020-12-18)
6
13
 
7
14
  * Fix and update list of markers in jpegoptim worker: allow to pass `com` instead of incorrect `comments` and add missing `xmp` and `none` [#188](https://github.com/toy/image_optim/issues/188) [@toy](https://github.com/toy)
data/LICENSE.txt CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2012-2020 Ivan Kuchin
1
+ Copyright (c) 2012-2021 Ivan Kuchin
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining
4
4
  a copy of this software and associated documentation files (the
data/README.markdown CHANGED
@@ -60,7 +60,7 @@ With version:
60
60
 
61
61
  <!---<update-version>-->
62
62
  ```ruby
63
- gem 'image_optim', '~> 0.28'
63
+ gem 'image_optim', '~> 0.29'
64
64
  ```
65
65
  <!---</update-version>-->
66
66
 
@@ -362,4 +362,4 @@ In separate file [CHANGELOG.markdown](CHANGELOG.markdown).
362
362
 
363
363
  ## Copyright
364
364
 
365
- Copyright (c) 2012-2020 Ivan Kuchin. See [LICENSE.txt](LICENSE.txt) for details.
365
+ Copyright (c) 2012-2021 Ivan Kuchin. See [LICENSE.txt](LICENSE.txt) for details.
data/image_optim.gemspec CHANGED
@@ -2,12 +2,14 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = 'image_optim'
5
- s.version = '0.28.0'
5
+ s.version = '0.29.0'
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, pngcrush, pngout, pngquant, svgo)}
7
7
  s.homepage = "https://github.com/toy/#{s.name}"
8
8
  s.authors = ['Ivan Kuchin']
9
9
  s.license = 'MIT'
10
10
 
11
+ s.required_ruby_version = '>= 1.9.3'
12
+
11
13
  s.metadata = {
12
14
  'bug_tracker_uri' => "https://github.com/toy/#{s.name}/issues",
13
15
  'changelog_uri' => "https://github.com/toy/#{s.name}/blob/master/CHANGELOG.markdown",
@@ -35,5 +37,6 @@ EOF
35
37
  s.add_development_dependency 'rspec', '~> 3.0'
36
38
  if RUBY_VERSION >= '2.4' && !Gem.win_platform? && !defined?(JRUBY_VERSION)
37
39
  s.add_development_dependency 'rubocop', '~> 1.0'
40
+ s.add_development_dependency 'rubocop-rspec', '~> 2.0'
38
41
  end
39
42
  end
data/lib/image_optim.rb CHANGED
@@ -188,12 +188,6 @@ class ImageOptim
188
188
  optimize_image_method?(method) || super
189
189
  end
190
190
 
191
- if RUBY_VERSION < '1.9'
192
- def respond_to?(method, include_private = false)
193
- optimize_image_method?(method) || super
194
- end
195
- end
196
-
197
191
  # Version of image_optim gem spec loaded
198
192
  def version
199
193
  Gem.loaded_specs['image_optim'].version.to_s
@@ -112,7 +112,7 @@ class ImageOptim
112
112
  when :gifsicle, :jpegoptim, :optipng
113
113
  capture("#{escaped_path} --version 2> #{Path::NULL}")[/\d+(\.\d+)+/]
114
114
  when :svgo, :pngquant
115
- capture("#{escaped_path} --version 2>&1")[/\d+(\.\d+)+/]
115
+ capture("#{escaped_path} --version 2>&1")[/\A\d+(\.\d+)+/]
116
116
  when :jhead, :'jpeg-recompress'
117
117
  capture("#{escaped_path} -V 2> #{Path::NULL}")[/\d+(\.\d+)+/]
118
118
  when :jpegtran
@@ -15,9 +15,7 @@ class ImageOptim
15
15
 
16
16
  # Global config path at `$XDG_CONFIG_HOME/image_optim.yml` (by default
17
17
  # `~/.config/image_optim.yml`)
18
- GLOBAL_PATH = begin
19
- File.join(ENV['XDG_CONFIG_HOME'] || '~/.config', 'image_optim.yml')
20
- end
18
+ GLOBAL_PATH = File.join(ENV['XDG_CONFIG_HOME'] || '~/.config', 'image_optim.yml')
21
19
 
22
20
  # Local config path at `./.image_optim.yml`
23
21
  LOCAL_PATH = './.image_optim.yml'
@@ -41,7 +41,7 @@ class ImageOptim
41
41
  dst.utime(stat.atime, stat.mtime) if time
42
42
  begin
43
43
  dst.chown(stat.uid, stat.gid)
44
- rescue Errno::EPERM
44
+ rescue Errno::EPERM, Errno::EACCES
45
45
  dst.chmod(stat.mode & 0o1777)
46
46
  else
47
47
  dst.chmod(stat.mode)
@@ -142,21 +142,12 @@ class ImageOptim
142
142
  # Run command defining environment, setting nice level, removing output and
143
143
  # reraising signal exception
144
144
  def run_command(cmd_args)
145
- args = if RUBY_VERSION < '1.9' || defined?(JRUBY_VERSION)
146
- %W[
147
- env PATH=#{@image_optim.env_path.shellescape}
148
- nice -n #{@image_optim.nice}
149
- #{cmd_args.shelljoin}
150
- > #{Path::NULL} 2>&1
151
- ].join(' ')
152
- else
153
- [
154
- {'PATH' => @image_optim.env_path},
155
- %W[nice -n #{@image_optim.nice}],
156
- cmd_args,
157
- {:out => Path::NULL, :err => Path::NULL},
158
- ].flatten
159
- end
145
+ args = [
146
+ {'PATH' => @image_optim.env_path},
147
+ *%W[nice -n #{@image_optim.nice}],
148
+ *cmd_args,
149
+ {:out => Path::NULL, :err => Path::NULL},
150
+ ]
160
151
  Cmd.run(*args)
161
152
  end
162
153
  end
@@ -358,20 +358,18 @@ class Analyser
358
358
  end
359
359
 
360
360
  def flatten_animation(image)
361
- run_cache[:flatten][image.digest] ||= begin
362
- if image.image_format == :gif
363
- flattened = image.temp_path
364
- Cmd.run(*%W[
365
- convert
366
- #{image.image_format}:#{image}
367
- -coalesce
368
- -append
369
- #{image.image_format}:#{flattened}
370
- ]) || fail("failed flattening of #{image}")
371
- flattened
372
- else
373
- image
374
- end
361
+ run_cache[:flatten][image.digest] ||= if image.image_format == :gif
362
+ flattened = image.temp_path
363
+ Cmd.run(*%W[
364
+ convert
365
+ #{image.image_format}:#{image}
366
+ -coalesce
367
+ -append
368
+ #{image.image_format}:#{flattened}
369
+ ]) || fail("failed flattening of #{image}")
370
+ flattened
371
+ else
372
+ image
375
373
  end
376
374
  end
377
375
 
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.28.0
4
+ version: 0.29.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ivan Kuchin
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-12-18 00:00:00.000000000 Z
11
+ date: 2021-04-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: fspath
@@ -146,6 +146,20 @@ dependencies:
146
146
  - - "~>"
147
147
  - !ruby/object:Gem::Version
148
148
  version: '1.0'
149
+ - !ruby/object:Gem::Dependency
150
+ name: rubocop-rspec
151
+ requirement: !ruby/object:Gem::Requirement
152
+ requirements:
153
+ - - "~>"
154
+ - !ruby/object:Gem::Version
155
+ version: '2.0'
156
+ type: :development
157
+ prerelease: false
158
+ version_requirements: !ruby/object:Gem::Requirement
159
+ requirements:
160
+ - - "~>"
161
+ - !ruby/object:Gem::Version
162
+ version: '2.0'
149
163
  description:
150
164
  email:
151
165
  executables:
@@ -155,6 +169,7 @@ extra_rdoc_files: []
155
169
  files:
156
170
  - ".appveyor.yml"
157
171
  - ".gitignore"
172
+ - ".pre-commit-hooks.yaml"
158
173
  - ".rubocop.yml"
159
174
  - ".travis.yml"
160
175
  - CHANGELOG.markdown
@@ -264,7 +279,7 @@ licenses:
264
279
  metadata:
265
280
  bug_tracker_uri: https://github.com/toy/image_optim/issues
266
281
  changelog_uri: https://github.com/toy/image_optim/blob/master/CHANGELOG.markdown
267
- documentation_uri: https://www.rubydoc.info/gems/image_optim/0.28.0
282
+ documentation_uri: https://www.rubydoc.info/gems/image_optim/0.29.0
268
283
  source_code_uri: https://github.com/toy/image_optim
269
284
  post_install_message: |
270
285
  Rails image assets optimization is extracted into image_optim_rails gem
@@ -276,7 +291,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
276
291
  requirements:
277
292
  - - ">="
278
293
  - !ruby/object:Gem::Version
279
- version: '0'
294
+ version: 1.9.3
280
295
  required_rubygems_version: !ruby/object:Gem::Requirement
281
296
  requirements:
282
297
  - - ">="