image_optim_pack 0.2.1.20160510 → 0.2.1.20160610
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 +8 -8
 - data/.travis.yml +4 -0
 - data/Makefile +2 -2
 - data/image_optim_pack.gemspec +1 -1
 - data/spec/image_optim_spec.rb +17 -87
 - data/spec/spec_helper.rb +8 -0
 - data/vendor/darwin/i386/jhead +0 -0
 - data/vendor/darwin/i386/jpeg-recompress +0 -0
 - data/vendor/darwin/i386/libpng.dylib +0 -0
 - data/vendor/darwin/i386/optipng +0 -0
 - data/vendor/darwin/i386/pngcrush +0 -0
 - data/vendor/darwin/i386/pngquant +0 -0
 - data/vendor/darwin/x86_64/jhead +0 -0
 - data/vendor/darwin/x86_64/jpeg-recompress +0 -0
 - data/vendor/darwin/x86_64/libpng.dylib +0 -0
 - data/vendor/darwin/x86_64/optipng +0 -0
 - data/vendor/darwin/x86_64/pngcrush +0 -0
 - data/vendor/darwin/x86_64/pngquant +0 -0
 - data/vendor/linux/i686/libpng.so +0 -0
 - data/vendor/linux/i686/optipng +0 -0
 - data/vendor/linux/i686/pngcrush +0 -0
 - data/vendor/linux/i686/pngquant +0 -0
 - data/vendor/linux/x86_64/libpng.so +0 -0
 - data/vendor/linux/x86_64/optipng +0 -0
 - data/vendor/linux/x86_64/pngcrush +0 -0
 - data/vendor/linux/x86_64/pngquant +0 -0
 - metadata +3 -3
 
    
        checksums.yaml
    CHANGED
    
    | 
         @@ -1,15 +1,15 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            ---
         
     | 
| 
       2 
2 
     | 
    
         
             
            !binary "U0hBMQ==":
         
     | 
| 
       3 
3 
     | 
    
         
             
              metadata.gz: !binary |-
         
     | 
| 
       4 
     | 
    
         
            -
                 
     | 
| 
      
 4 
     | 
    
         
            +
                NjI1NTMyNzkyNmU0NjYzNTkzNzBlYmNhNGFkNjU2M2Y5YzFkYWNhOQ==
         
     | 
| 
       5 
5 
     | 
    
         
             
              data.tar.gz: !binary |-
         
     | 
| 
       6 
     | 
    
         
            -
                 
     | 
| 
      
 6 
     | 
    
         
            +
                NmQ2OGI1MWZjYmE0MWYxMmI5MTdkYWFjMzcwNmU3NDY4MDRlY2I4Nw==
         
     | 
| 
       7 
7 
     | 
    
         
             
            SHA512:
         
     | 
| 
       8 
8 
     | 
    
         
             
              metadata.gz: !binary |-
         
     | 
| 
       9 
     | 
    
         
            -
                 
     | 
| 
       10 
     | 
    
         
            -
                 
     | 
| 
       11 
     | 
    
         
            -
                 
     | 
| 
      
 9 
     | 
    
         
            +
                NWM0ZTA1YzNlNTZmYzU0OWNmNDQxNzViOWEzOWM3ZTZiZTZkNGY0NjQ2ZDgz
         
     | 
| 
      
 10 
     | 
    
         
            +
                M2FlMTYyMzVmNDE1NWU0MDM4ZDY1NDYwYmZjOGFiYjg0NzVkNzcwYjhlMTg5
         
     | 
| 
      
 11 
     | 
    
         
            +
                NmNmOGE3NDM3YWZmYmVmY2Y2ZmVmMDM1MGUyNDI1MzUwYmZiNWI=
         
     | 
| 
       12 
12 
     | 
    
         
             
              data.tar.gz: !binary |-
         
     | 
| 
       13 
     | 
    
         
            -
                 
     | 
| 
       14 
     | 
    
         
            -
                 
     | 
| 
       15 
     | 
    
         
            -
                 
     | 
| 
      
 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. 
     | 
| 
      
 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. 
     | 
| 
      
 16 
     | 
    
         
            +
            PNGQUANT_VER := 2.7.1
         
     | 
| 
       17 
17 
     | 
    
         | 
| 
       18 
18 
     | 
    
         
             
            # ====== CONSTANTS ======
         
     | 
| 
       19 
19 
     | 
    
         | 
    
        data/image_optim_pack.gemspec
    CHANGED
    
    | 
         @@ -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. 
     | 
| 
      
 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']
         
     | 
    
        data/spec/image_optim_spec.rb
    CHANGED
    
    | 
         @@ -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 =  
     | 
| 
      
 14 
     | 
    
         
            +
              images_dir = FSPath.new(image_optim_root) / 'spec/images'
         
     | 
| 
       81 
15 
     | 
    
         
             
              test_images = images_dir.glob('**/*.*')
         
     | 
| 
       82 
16 
     | 
    
         | 
| 
       83 
     | 
    
         
            -
               
     | 
| 
       84 
     | 
    
         
            -
               
     | 
| 
       85 
     | 
    
         
            -
                 
     | 
| 
      
 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 
     | 
    
         
            -
               
     | 
| 
       89 
     | 
    
         
            -
             
     | 
| 
       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 
     | 
    
         
            -
                 
     | 
| 
       99 
     | 
    
         
            -
                   
     | 
| 
      
 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 
     | 
    
         
            -
             
     | 
| 
       102 
     | 
    
         
            -
             
     | 
| 
       103 
     | 
    
         
            -
             
     | 
| 
       104 
     | 
    
         
            -
             
     | 
| 
      
 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 
     | 
    
         
            -
             
     | 
| 
       107 
     | 
    
         
            -
             
     | 
| 
      
 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
    
    
    
        data/vendor/darwin/i386/jhead
    CHANGED
    
    | 
         Binary file 
     | 
| 
         Binary file 
     | 
| 
         Binary file 
     | 
    
        data/vendor/darwin/i386/optipng
    CHANGED
    
    | 
         Binary file 
     | 
    
        data/vendor/darwin/i386/pngcrush
    CHANGED
    
    | 
         Binary file 
     | 
    
        data/vendor/darwin/i386/pngquant
    CHANGED
    
    | 
         Binary file 
     | 
    
        data/vendor/darwin/x86_64/jhead
    CHANGED
    
    | 
         Binary file 
     | 
| 
         Binary file 
     | 
| 
         Binary file 
     | 
| 
         Binary file 
     | 
| 
         Binary file 
     | 
| 
         Binary file 
     | 
    
        data/vendor/linux/i686/libpng.so
    CHANGED
    
    | 
         Binary file 
     | 
    
        data/vendor/linux/i686/optipng
    CHANGED
    
    | 
         Binary file 
     | 
    
        data/vendor/linux/i686/pngcrush
    CHANGED
    
    | 
         Binary file 
     | 
    
        data/vendor/linux/i686/pngquant
    CHANGED
    
    | 
         Binary file 
     | 
| 
         Binary file 
     | 
    
        data/vendor/linux/x86_64/optipng
    CHANGED
    
    | 
         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. 
     | 
| 
      
 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- 
     | 
| 
      
 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 
     | 
| 
      
 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,
         
     |