image_optim_pack 0.2.1.20160510 → 0.2.1.20160610

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- ZDE3ZDdlMTg2OGJmZTI0Y2E2ODc5Y2Q2OTRmZWY4NmJhNjA2MDY0ZA==
4
+ NjI1NTMyNzkyNmU0NjYzNTkzNzBlYmNhNGFkNjU2M2Y5YzFkYWNhOQ==
5
5
  data.tar.gz: !binary |-
6
- ZDFhMTFhMjBmYzNiMDVjMDgxMTQ2MGRhNzI1OTI5OTE2ZGU4YjJkOA==
6
+ NmQ2OGI1MWZjYmE0MWYxMmI5MTdkYWFjMzcwNmU3NDY4MDRlY2I4Nw==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- YTIyZWEzZTk3NjUzNWQ5ZjUwMDlmYWFmNjgwN2U4NzlmZmRlMGU3MjQ5ZDlj
10
- NjU0M2FjY2E2YjM4ODViNDhiZDY4YTE2MGI5YWU5M2E4NWEyOWE3OGQ3OTk1
11
- NDRiOTdkMDZiMWFmNWNjNTBlN2QyMGFhNzIwOGZlOWNmOTIwY2I=
9
+ NWM0ZTA1YzNlNTZmYzU0OWNmNDQxNzViOWEzOWM3ZTZiZTZkNGY0NjQ2ZDgz
10
+ M2FlMTYyMzVmNDE1NWU0MDM4ZDY1NDYwYmZjOGFiYjg0NzVkNzcwYjhlMTg5
11
+ NmNmOGE3NDM3YWZmYmVmY2Y2ZmVmMDM1MGUyNDI1MzUwYmZiNWI=
12
12
  data.tar.gz: !binary |-
13
- ZjI0ZmI4M2I1NzJjMmU2NjM1NjlkZDBkNDE1ZjE1Njk5ZTg1NWIzNTU4YmI4
14
- YmY4NGNmNTc2MWY5NDcxZDA4N2Q5ZTJmMmY5OTBiMzYzZTU0MDdlMDQ1MGYz
15
- MjEzNjFmNTQ1MGIzM2Y0NGY2MTc2YjRjMjE2NWJiNTQ5MGIzOWM=
13
+ ZDlhMmM1MjUyMjUzYThkNGZiZGNhNjlhYThmNTJiNzM2OTZjODI4YjVmN2Vi
14
+ YTI1ODYyYTIyYmM2MDAzNzRkNDBkMWM2MzM2NDRjZTliOGIzYTZjNTVhODY4
15
+ ZTNhNDA0YmU5NGMzYzk1ZThjYTU2NDAxNzNhZThmNTJmZGQwOTk=
data/.travis.yml CHANGED
@@ -17,8 +17,12 @@ script:
17
17
  ; else
18
18
  bundle exec rubocop
19
19
  ; fi
20
+ before_install:
21
+ if [ $TRAVIS_OS_NAME == osx ]; then brew update && brew install imagemagick; fi
20
22
  matrix:
21
23
  fast_finish: true
22
24
  include:
25
+ - os: osx
26
+ rvm: default
23
27
  - env: RUBOCOP=true
24
28
  rvm: default
data/Makefile CHANGED
@@ -9,11 +9,11 @@ JPEGARCHIVE_VER := 2.1.1
9
9
  JPEGOPTIM_VER := 1.4.3
10
10
  LIBJPEG_VER := 9b
11
11
  LIBMOZJPEG_VER := 3.1
12
- LIBPNG_VER := 1.6.21
12
+ LIBPNG_VER := 1.6.23
13
13
  LIBZ_VER := 1.2.8
14
14
  OPTIPNG_VER := 0.7.6
15
15
  PNGCRUSH_VER := 1.8.1
16
- PNGQUANT_VER := 2.7.0
16
+ PNGQUANT_VER := 2.7.1
17
17
 
18
18
  # ====== CONSTANTS ======
19
19
 
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = 'image_optim_pack'
5
- s.version = '0.2.1.20160510'
5
+ s.version = '0.2.1.20160610'
6
6
  s.summary = %q{Precompiled binaries for image_optim: advpng, gifsicle, jhead, jpeg-recompress, jpegoptim, jpegtran, optipng, pngcrush, pngquant}
7
7
  s.homepage = "http://github.com/toy/#{s.name}"
8
8
  s.authors = ['Ivan Kuchin']
@@ -5,106 +5,36 @@ require 'tempfile'
5
5
  require 'English'
6
6
 
7
7
  describe ImageOptim do
8
- def self.temp_copy(image)
9
- image.temp_path.tap{ |path| image.copy(path) }
10
- end
11
-
12
8
  before do
13
9
  stub_const('Cmd', ImageOptim::Cmd)
14
10
  end
15
11
 
16
- def flatten_animation(image)
17
- if image.format == :gif
18
- flattened = image.temp_path
19
- flatten_command = %W[
20
- convert
21
- #{image.to_s.shellescape}
22
- -coalesce
23
- -append
24
- #{flattened.to_s.shellescape}
25
- ].join(' ')
26
- expect(Cmd.run(flatten_command)).to be_truthy
27
- flattened
28
- else
29
- image
30
- end
31
- end
32
-
33
- def nrmse(image_a, image_b)
34
- coalesce_a = flatten_animation(image_a)
35
- coalesce_b = flatten_animation(image_b)
36
- nrmse_command = %W[
37
- compare
38
- -metric RMSE
39
- -alpha Background
40
- #{coalesce_a.to_s.shellescape}
41
- #{coalesce_b.to_s.shellescape}
42
- /dev/null
43
- 2>&1
44
- ].join(' ')
45
- output = Cmd.capture(nrmse_command)
46
- if [0, 1].include?($CHILD_STATUS.exitstatus)
47
- output[/\((\d+(\.\d+)?)\)/, 1].to_f
48
- else
49
- fail "compare #{image_a} with #{image_b} failed with `#{output}`"
50
- end
51
- end
52
-
53
- define :have_same_data_as do |expected|
54
- match{ |actual| actual.binread == expected.binread }
55
- end
56
-
57
- define :have_size do
58
- match(&:size?)
59
- end
60
-
61
- define :be_smaller_than do |expected|
62
- match{ |actual| actual.size < expected.size }
63
- end
64
-
65
- define :be_pixel_identical_to do |expected|
66
- match do |actual|
67
- @diff = nrmse(actual, expected)
68
- @diff == 0
69
- end
70
- failure_message do |actual|
71
- "expected #{actual} to be pixel identical to #{expected}, got "\
72
- "normalized root-mean-square error of #{@diff}"
73
- end
74
- end
75
-
76
- image_optim = ImageOptim.new
77
-
78
12
  # grab images from image_optim gem
79
13
  image_optim_root = Gem.loaded_specs['image_optim'].gem_dir
80
- images_dir = ImageOptim::ImagePath.new(image_optim_root) / 'spec/images'
14
+ images_dir = FSPath.new(image_optim_root) / 'spec/images'
81
15
  test_images = images_dir.glob('**/*.*')
82
16
 
83
- # select images which for which there are workers
84
- test_images = test_images.select do |image|
85
- image_optim.workers_for_image(image)
17
+ isolated_options_base = {:skip_missing_workers => false}
18
+ ImageOptim::Worker.klasses.each do |klass|
19
+ isolated_options_base[klass.bin_sym] = false
86
20
  end
87
21
 
88
- rotated = images_dir / 'orient/original.jpg'
89
- rotate_images = images_dir.glob('orient/?.jpg')
90
-
91
- copies = test_images.map{ |image| temp_copy(image) }
92
- original_by_copy = Hash[copies.zip(test_images)]
93
-
94
- image_optim.optimize_images(copies) do |copy, optimized|
95
- fail 'expected copy to not be nil' if copy.nil?
96
- original = original_by_copy[copy]
22
+ ImageOptim::Worker.klasses.each do |worker_klass|
23
+ next if [:pngout, :svgo].include?(worker_klass.bin_sym)
97
24
 
98
- it "optimizes #{original}" do
99
- expect(copy).to have_same_data_as(original)
25
+ describe "#{worker_klass.bin_sym} worker" do
26
+ it 'optimizes at least one test image' do
27
+ options = isolated_options_base.merge(worker_klass.bin_sym => true)
100
28
 
101
- expect(optimized).not_to be_nil
102
- expect(optimized).to have_size
103
- expect(optimized).to be_smaller_than(original)
104
- expect(optimized).not_to have_same_data_as(original)
29
+ image_optim = ImageOptim.new(options)
30
+ if Array(worker_klass.init(image_optim)).empty?
31
+ image_optim = ImageOptim.new(options.merge(:allow_lossy => true))
32
+ end
105
33
 
106
- compare_to = rotate_images.include?(original) ? rotated : original
107
- expect(optimized).to be_pixel_identical_to(compare_to)
34
+ expect(test_images.any? do |original|
35
+ image_optim.optimize_image(original)
36
+ end).to be true
37
+ end
108
38
  end
109
39
  end
110
40
  end
data/spec/spec_helper.rb CHANGED
@@ -0,0 +1,8 @@
1
+ RSpec.configure do |c|
2
+ c.before do
3
+ stub_const('ImageOptim::Config::GLOBAL_PATH', '/dev/null')
4
+ stub_const('ImageOptim::Config::LOCAL_PATH', '/dev/null')
5
+ end
6
+
7
+ c.order = :random
8
+ end
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: image_optim_pack
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1.20160510
4
+ version: 0.2.1.20160610
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-05-10 00:00:00.000000000 Z
11
+ date: 2016-06-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: image_optim
@@ -209,7 +209,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
209
209
  version: '0'
210
210
  requirements: []
211
211
  rubyforge_project: image_optim_pack
212
- rubygems_version: 2.4.8
212
+ rubygems_version: 2.6.4
213
213
  signing_key:
214
214
  specification_version: 4
215
215
  summary: ! 'Precompiled binaries for image_optim: advpng, gifsicle, jhead, jpeg-recompress,