middleman-imageoptim 0.0.4 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore CHANGED
@@ -1,3 +1,5 @@
1
1
  # Ignore bundler lock file
2
2
  Gemfile.lock
3
3
  pkg
4
+ .bundle
5
+ bin
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --format progress
data/Gemfile CHANGED
@@ -6,14 +6,7 @@ source 'http://rubygems.org'
6
6
  gemspec
7
7
 
8
8
  group :development do
9
- gem "rake", "~> 0.9.2"
10
- gem "rdoc", "~> 3.9"
11
- gem "yard", "~> 0.8.0"
9
+ gem "rake", "~> 0.9.2"
10
+ gem "rdoc", "~> 3.9"
11
+ gem "yard", "~> 0.8.0"
12
12
  end
13
-
14
- group :test do
15
- gem "cucumber", "~> 1.2.0"
16
- gem "fivemat"
17
- gem "aruba", "~> 0.4.11"
18
- gem "rspec", "~> 2.7"
19
- end
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2013 Justin Morris
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of
6
+ this software and associated documentation files (the "Software"), to deal in
7
+ the Software without restriction, including without limitation the rights to
8
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9
+ the Software, and to permit persons to whom the Software is furnished to do so,
10
+ subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
17
+ FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18
+ COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19
+ IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20
+ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md CHANGED
@@ -4,43 +4,54 @@
4
4
 
5
5
  Serving big images is fo numb-skulls! Compress and optimise your imagery during `middleman build` by running [image_optim](https://github.com/toy/image_optim) over it. Yay-hooray!
6
6
 
7
+ ![](http://cl.ly/image/0h0b330F2p3C/Terminal%20%E2%80%94%20zsh%20%E2%80%94%20109%C3%9712.png)
8
+
7
9
  ## Installation
8
10
 
9
11
  Go set up the [image_optim](https://github.com/toy/image_optim) external utilities, then;
10
12
 
11
13
  ```ruby
12
- gem "middleman-imageoptim", "~> 0.0.3"
14
+ gem "middleman-imageoptim", "~> 0.1.0"
13
15
  ```
14
16
 
15
17
  ## Usage
16
18
 
17
19
  ```ruby
18
- activate :image_optim
20
+ activate :imageoptim
19
21
  ```
20
22
 
21
23
  You can also configure the extension in the usual fashion, by passing a block to `:activate`
22
24
  Below is the default configuration showing all available options;
23
25
 
24
26
  ```ruby
25
- activate :image_optim do |image_optim|
27
+ activate :imageoptim do |options|
26
28
  # print out skipped images
27
- image_optim.verbose = false
29
+ options.verbose = false
28
30
 
29
- # Setting these to true or nil will let image_optim determine them (recommended)
30
- image_optim.nice = true
31
- image_optim.threads = true
31
+ # Setting these to true or nil will let options determine them (recommended)
32
+ options.nice = true
33
+ options.threads = true
32
34
 
33
35
  # Image extensions to attempt to compress
34
- image_optim.image_extensions = %w(.png .jpg .gif)
36
+ options.image_extensions = %w(.png .jpg .gif)
35
37
 
36
38
  # compressor worker options, individual optimisers can be disabled by passing
37
39
  # false instead of a hash
38
- image_optim.pngcrush_options = {:chunks => ['alla'], :fix => false, :brute => false}
39
- image_optim.pngout_options = {:copy_chunks => false, :strategy => 0}
40
- image_optim.optipng_options = {:level => 6, :interlace => false}
41
- image_optim.advpng_options = {:level => 4}
42
- image_optim.jpegoptim_options = {:strip => ['all'], :max_quality => 100}
43
- image_optim.jpegtran_options = {:copy_chunks => false, :progressive => true, :jpegrescan => true}
44
- image_optim.gifsicle_options = {:interlace => false}
40
+ options.pngcrush_options = {:chunks => ['alla'], :fix => false, :brute => false}
41
+ options.pngout_options = {:copy_chunks => false, :strategy => 0}
42
+ options.optipng_options = {:level => 6, :interlace => false}
43
+ options.advpng_options = {:level => 4}
44
+ options.jpegoptim_options = {:strip => ['all'], :max_quality => 100}
45
+ options.jpegtran_options = {:copy_chunks => false, :progressive => true, :jpegrescan => true}
46
+ options.gifsicle_options = {:interlace => false}
45
47
  end
46
48
  ```
49
+
50
+ ***
51
+
52
+ ## Changelog
53
+
54
+ ##### `0.1.0`
55
+ - complete refactor and clean-up
56
+ - introduced an options class. options now work (lol, yay!), thanks @andrew-aladev for your help there
57
+ - change of extension activation name from `:image_optim to `:imageoptim` for consistency with internal naming
data/Rakefile CHANGED
@@ -1,4 +1,32 @@
1
+ #!/usr/bin/env rake
2
+
1
3
  require 'bundler'
2
4
  Bundler::GemHelper.install_tasks
3
5
 
4
6
  require 'rake/clean'
7
+ require 'rspec/core/rake_task'
8
+
9
+ namespace :spec do
10
+ begin
11
+ require 'cane/rake_task'
12
+ desc "Run cane to check quality metrics"
13
+ Cane::RakeTask.new(:quality) do |cane|
14
+ cane.abc_max = 10
15
+ cane.add_threshold 'coverage/covered_percent', :>=, 100
16
+ cane.no_style = true
17
+ end
18
+
19
+ task :default => :quality
20
+ rescue LoadError
21
+ warn "cane not available, quality task not provided."
22
+ end
23
+
24
+ desc 'Run unit specs'
25
+ RSpec::Core::RakeTask.new(:unit) do |spec|
26
+ spec.pattern = "spec/unit/*_spec.rb"
27
+ spec.rspec_opts = "--require spec_helper"
28
+ end
29
+ end
30
+
31
+ desc 'Default: run unit tests.'
32
+ task :default => ['spec:unit']
@@ -1,68 +1,15 @@
1
1
  require "middleman-core"
2
- require "image_optim"
3
- require "fileutils"
2
+ require "middleman-imageoptim/optimizer"
3
+ require "middleman-imageoptim/options"
4
4
 
5
- module MiddlemanImageoptim
6
- class << self
7
- def registered(app, options={})
8
- app.set :verbose, false
9
- app.set :nice, true
10
- app.set :threads, true
11
- app.set :image_extensions, %w(.png .jpg .gif)
12
- app.set :pngcrush_options, {:chunks => ['alla'], :fix => false, :brute => false}
13
- app.set :pngout_options, {:copy_chunks => false, :strategy => 0}
14
- app.set :optipng_options, {:level => 6, :interlace => false}
15
- app.set :advpng_options, {:level => 4}
16
- app.set :jpegoptim_options, {:strip => ['all'], :max_quality => 100}
17
- app.set :jpegtran_options, {:copy_chunks => false, :progressive => true, :jpegrescan => true}
18
- app.set :gifsicle_options, {:interlace => false}
19
-
20
- app.after_build do |builder|
21
- image_optim = ImageOptim.new(
22
- :nice => nice,
23
- :threads => threads,
24
- :pngcrush => pngcrush_options,
25
- :pngout => pngout_options,
26
- :optipng => optipng_options,
27
- :advpng => advpng_options,
28
- :jpegoptim => jpegoptim_options,
29
- :jpegtran => jpegtran_options,
30
- :gifsicle => gifsicle_options
31
- )
32
- optimizable_paths = []
33
- paths = ::Middleman::Util.all_files_under(self.class.inst.build_dir)
34
-
35
- # iterate over all the paths in the middleman build directory
36
- paths.each do |path|
37
-
38
- # reject non-image extension paths
39
- next unless image_extensions.include? path.extname
40
-
41
- # check that we can handle this image
42
- if image_optim.optimizable?(path.to_s)
43
- optimizable_paths << path
44
- else
45
- builder.say_status :img_optim, "skipping #{path} as it is not an image or there is no optimizer for it"
46
- end
47
- end
48
-
49
- # start compressing image assets
50
- image_optim.optimize_images(optimizable_paths) do |src, dst|
51
- if dst
52
- size_change_word = (src.size - dst.size) > 0 ? 'smaller' : 'larger'
53
- percent_change = '%.2f%%' % [100 - 100.0 * dst.size / src.size]
54
- builder.say_status :img_optimise, "#{src} (#{percent_change} / #{number_to_human_size((src.size - dst.size).abs)} #{size_change_word})"
55
- FileUtils.mv(dst, src)
56
- elsif verbose
57
- builder.say_status :img_optimise, "#{src} (skipped)"
58
- end
59
- end
60
- end
61
- end
62
- alias :included :registered
63
- end
5
+ ::Middleman::Extensions.register(:imageoptim) do
6
+ require "middleman-imageoptim/extension"
7
+ ::Middleman::Imageoptim
64
8
  end
65
9
 
66
10
  ::Middleman::Extensions.register(:image_optim) do
67
- ::MiddlemanImageoptim
11
+ warn ":image_optim is deprecated. Please use `:imageoptim` instead."
12
+
13
+ require "middleman-imageoptim/extension"
14
+ ::Middleman::Imageoptim
68
15
  end
@@ -0,0 +1,17 @@
1
+ require "middleman-core"
2
+
3
+ module Middleman
4
+ module Imageoptim
5
+ class << self
6
+ def registered(app, options_hash = {}, &block)
7
+ options = Middleman::Imageoptim::Options.new(options_hash)
8
+ yield options.user_options if block_given?
9
+
10
+ app.after_build {|builder|
11
+ Middleman::Imageoptim::Optimizer.new(app, builder, options).optimize!
12
+ }
13
+ end
14
+ alias :included :registered
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,89 @@
1
+ module Middleman
2
+ module Imageoptim
3
+ require "image_optim"
4
+ require "fileutils"
5
+ require "padrino-helpers"
6
+
7
+ class Optimizer
8
+ include ::Padrino::Helpers::NumberHelpers
9
+
10
+ def initialize(app, builder, options)
11
+ @app = app
12
+ @builder = builder
13
+ @options = options
14
+ @total_savings = 0
15
+ end
16
+
17
+ def optimize!
18
+ images_to_optimize = filter_file_paths(file_paths())
19
+ optimizer.optimize_images(images_to_optimize) {|src_file, dst_file|
20
+ if dst_file
21
+ @total_savings += (src_file.size - dst_file.size)
22
+ say_status "#{src_file} (#{percentage_change(src_file.size, dst_file.size)} / #{format_size((src_file.size - dst_file.size))} #{size_change_word(src_file.size, dst_file.size)})"
23
+ FileUtils.mv dst_file, src_file
24
+ elsif @options.verbose
25
+ say_status "[skipped] #{src_file}"
26
+ end
27
+ }
28
+ say_status "Total image savings: #{format_size(@total_savings)}"
29
+ end
30
+
31
+ def say_status(status)
32
+ if @builder
33
+ @builder.say_status :image_optim, status
34
+ end
35
+ end
36
+
37
+ def file_paths
38
+ ::Middleman::Util.all_files_under(@app.inst.build_dir)
39
+ end
40
+
41
+ def filter_file_paths(paths)
42
+ paths.select {|path|
43
+ is_image_extension(path.extname) && image_is_optimizable(path)
44
+ }
45
+ end
46
+
47
+ def is_image_extension(extension)
48
+ @options.image_extensions.include?(extension)
49
+ end
50
+
51
+ def image_is_optimizable(path)
52
+ optimizer.optimizable?(path)
53
+ end
54
+
55
+ def format_size(bytes)
56
+ number_to_human_size(bytes)
57
+ end
58
+
59
+ def size_change_word(size_src, size_dst)
60
+ size_difference = (size_src - size_dst)
61
+ if size_difference > 0
62
+ 'smaller'
63
+ elsif size_difference < 0
64
+ 'larger'
65
+ else
66
+ 'no change'
67
+ end
68
+ end
69
+
70
+ def percentage_change(size_src, size_dst)
71
+ '%.2f%%' % [100 - 100.0 * size_dst / size_src]
72
+ end
73
+
74
+ def optimizer
75
+ @optimizer ||= ImageOptim.new(
76
+ :nice => @options.nice,
77
+ :threads => @options.threads,
78
+ :pngcrush => @options.pngcrush_options,
79
+ :pngout => @options.pngout_options,
80
+ :optipng => @options.optipng_options,
81
+ :advpng => @options.advpng_options,
82
+ :jpegoptim => @options.jpegoptim_options,
83
+ :jpegtran => @options.jpegtran_options,
84
+ :gifsicle => @options.gifsicle_options
85
+ )
86
+ end
87
+ end
88
+ end
89
+ end
@@ -0,0 +1,62 @@
1
+ module Middleman
2
+ module Imageoptim
3
+ class Options
4
+ attr_accessor :user_options
5
+ attr_reader :verbose, :nice, :threads, :image_extensions,
6
+ :pngcrush_options, :pngout_options, :optipng_options, :advpng_options,
7
+ :jpegoptim_options, :jpegtran_options, :gifsicle_options
8
+
9
+ UserOptions = Struct.new(:verbose, :nice, :threads, :image_extensions,
10
+ :pngcrush_options, :pngout_options, :optipng_options, :advpng_options,
11
+ :jpegoptim_options, :jpegtran_options, :gifsicle_options)
12
+
13
+ def initialize(options_hash = {})
14
+ @user_options = UserOptions.new(*options_hash)
15
+ end
16
+
17
+ def verbose
18
+ !@user_options.verbose.nil? ? @user_options.verbose : false
19
+ end
20
+
21
+ def nice
22
+ !@user_options.nice.nil? ? @user_options.nice : true
23
+ end
24
+
25
+ def threads
26
+ !@user_options.threads.nil? ? @user_options.threads : true
27
+ end
28
+
29
+ def image_extensions
30
+ !@user_options.image_extensions.nil? ? @user_options.image_extensions : %w(.png .jpg .gif)
31
+ end
32
+
33
+ def pngcrush_options
34
+ !@user_options.pngcrush_options.nil? ? @user_options.pngcrush_options : {:chunks => ['alla'], :fix => false, :brute => false}
35
+ end
36
+
37
+ def pngout_options
38
+ !@user_options.pngout_options.nil? ? @user_options.pngout_options : {:copy_chunks => false, :strategy => 0}
39
+ end
40
+
41
+ def optipng_options
42
+ !@user_options.optipng_options.nil? ? @user_options.optipng_options : {:level => 6, :interlace => false}
43
+ end
44
+
45
+ def advpng_options
46
+ !@user_options.advpng_options.nil? ? @user_options.advpng_options : {:level => 4}
47
+ end
48
+
49
+ def jpegoptim_options
50
+ !@user_options.jpegoptim_options.nil? ? @user_options.jpegoptim_options : {:strip => ['all'], :max_quality => 100}
51
+ end
52
+
53
+ def jpegtran_options
54
+ !@user_options.jpegtran_options.nil? ? @user_options.jpegtran_options : {:copy_chunks => false, :progressive => true, :jpegrescan => true}
55
+ end
56
+
57
+ def gifsicle_options
58
+ !@user_options.gifsicle_options.nil? ? @user_options.gifsicle_options : {:interlace => false}
59
+ end
60
+ end
61
+ end
62
+ end
@@ -1,3 +1,6 @@
1
- module MiddlemanImageoptim
2
- VERSION = "0.0.4"
1
+ module Middleman
2
+ module Imageoptim
3
+ PACKAGE = 'middleman-imageoptim'
4
+ VERSION = "0.1.0"
5
+ end
3
6
  end
@@ -3,20 +3,26 @@ $:.push File.expand_path("../lib", __FILE__)
3
3
  require File.expand_path('../lib/middleman-imageoptim/version', __FILE__)
4
4
 
5
5
  Gem::Specification.new do |gem|
6
- gem.name = "middleman-imageoptim"
7
- gem.version = MiddlemanImageoptim::VERSION
8
- gem.platform = Gem::Platform::RUBY
9
- gem.authors = ["Justin Morris"]
10
- gem.email = ["desk@pixelbloom.com"]
11
- gem.homepage = "https://github.com/plasticine/middleman-imageoptim"
12
- gem.summary = %q{Small images are small! Compress yours during middleman build.}
13
- gem.description = %q{Small images are small! Compress yours during middleman build.}
6
+ gem.name = Middleman::Imageoptim::PACKAGE
7
+ gem.version = Middleman::Imageoptim::VERSION
8
+ gem.platform = Gem::Platform::RUBY
9
+ gem.authors = ["Justin Morris"]
10
+ gem.email = ["desk@pixelbloom.com"]
11
+ gem.homepage = "https://github.com/plasticine/middleman-imageoptim"
12
+ gem.summary = %q{Small images are small! Compress yours during middleman build.}
13
+ gem.description = %q{Small images are small! Compress yours during middleman build.}
14
14
 
15
15
  gem.files = `git ls-files`.split("\n")
16
- gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
17
16
  gem.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
18
17
  gem.require_paths = ["lib"]
19
18
 
20
- gem.add_runtime_dependency("middleman-core", [">= 3.0"])
21
- gem.add_runtime_dependency("image_optim", "~> 0.8.0")
19
+ gem.add_dependency "middleman-core", [">= 3.0"]
20
+ gem.add_dependency "image_optim", "~> 0.9.1"
21
+
22
+ gem.add_development_dependency "padrino-helpers"
23
+ gem.add_development_dependency "rspec"
24
+ gem.add_development_dependency "rake"
25
+ gem.add_development_dependency "cucumber"
26
+ gem.add_development_dependency "simplecov"
27
+ gem.add_development_dependency "cane"
22
28
  end
@@ -0,0 +1,10 @@
1
+ if ENV['COVERAGE']
2
+ require_relative 'use_simplecov'
3
+ end
4
+
5
+ RSpec.configure do |config|
6
+ config.treat_symbols_as_metadata_keys_with_true_values = true
7
+ config.run_all_when_everything_filtered = true
8
+ config.filter_run :focus
9
+ config.order = 'random'
10
+ end
@@ -0,0 +1,58 @@
1
+ require_relative "../../lib/middleman-imageoptim/optimizer"
2
+
3
+ describe Middleman::Imageoptim::Optimizer do
4
+ subject(:optimizer) { Middleman::Imageoptim::Optimizer.new(app, builder, options) }
5
+ let(:options) { Middleman::Imageoptim::Options.new() }
6
+ let(:app) { double }
7
+ let(:builder) { double }
8
+ let(:size_src) { 1000 }
9
+ let(:size_dst) { 1000 }
10
+
11
+ describe "#size_change_word" do
12
+ subject { optimizer.size_change_word(size_src, size_dst) }
13
+
14
+ context "the destination file is the same size as the source file" do
15
+ it "should be the same size" do
16
+ subject.should == 'no change'
17
+ end
18
+ end
19
+
20
+ context "the destination file is smaller" do
21
+ let(:size_dst) { 500 }
22
+ it "should be smaller" do
23
+ subject.should == 'smaller'
24
+ end
25
+ end
26
+
27
+ context "the destination file is larger" do
28
+ let(:size_dst) { 1500 }
29
+ it "should be larger" do
30
+ subject.should == 'larger'
31
+ end
32
+ end
33
+ end
34
+
35
+ describe "#percentage_change" do
36
+ subject { optimizer.percentage_change(size_src, size_dst) }
37
+
38
+ context "the destination file is the same size as the source file" do
39
+ it "should be the same size" do
40
+ subject.should == "0.00%"
41
+ end
42
+ end
43
+
44
+ context "the destination file is smaller" do
45
+ let(:size_dst) { 500 }
46
+ it "should be smaller" do
47
+ subject.should == "50.00%"
48
+ end
49
+ end
50
+
51
+ context "the destination file is larger" do
52
+ let(:size_dst) { 1500 }
53
+ it "should be larger" do
54
+ subject.should == '-50.00%'
55
+ end
56
+ end
57
+ end
58
+ end
@@ -0,0 +1,77 @@
1
+ require_relative "../../lib/middleman-imageoptim/options"
2
+
3
+ describe Middleman::Imageoptim::Options do
4
+ subject { Middleman::Imageoptim::Options.new(options_hash) }
5
+ let(:options_hash) { {} }
6
+
7
+ describe "default options" do
8
+ its(:verbose) { should be_false }
9
+ its(:nice) { should be_true }
10
+ its(:threads) { should be_true }
11
+ its(:image_extensions) { should == ['.png', '.jpg', '.gif'] }
12
+ its(:pngcrush_options) { should == {:chunks => ['alla'], :fix => false, :brute => false} }
13
+ its(:pngout_options) { should == {:copy_chunks => false, :strategy => 0} }
14
+ its(:optipng_options) { should == {:level => 6, :interlace => false} }
15
+ its(:advpng_options) { should == {:level => 4} }
16
+ its(:jpegoptim_options) { should == {:strip => ['all'], :max_quality => 100} }
17
+ its(:jpegtran_options) { should == {:copy_chunks => false, :progressive => true, :jpegrescan => true} }
18
+ its(:gifsicle_options) { should == {:interlace => false} }
19
+ end
20
+
21
+ describe "with user options" do
22
+ describe "#verbose" do
23
+ let(:options_hash) { {verbose: true} }
24
+ subject { options.verbose().should be_true }
25
+ end
26
+
27
+ describe "#nice" do
28
+ let(:options_hash) { {nice: false} }
29
+ subject { options.nice().should be_false }
30
+ end
31
+
32
+ describe "#threads" do
33
+ let(:options_hash) { {threads: false} }
34
+ subject { options.threads().should be_false }
35
+ end
36
+
37
+ describe "#image_extensions" do
38
+ let(:options_hash) { {image_extensions: ['.gif']} }
39
+ subject { options.image_extensions().should == ['.gif'] }
40
+ end
41
+
42
+ describe "#pngcrush_options" do
43
+ let(:options_hash) { {pngcrush_options: {foo: 'bar'}} }
44
+ subject { options.pngcrush_options().should == {foo: 'bar'} }
45
+ end
46
+
47
+ describe "#pngout_options" do
48
+ let(:options_hash) { {pngout_options: {foo: 'bar'}} }
49
+ subject { options.pngout_options().should == {foo: 'bar'} }
50
+ end
51
+
52
+ describe "#optipng_options" do
53
+ let(:options_hash) { {optipng_options: {foo: 'bar'}} }
54
+ subject { options.optipng_options().should == {foo: 'bar'} }
55
+ end
56
+
57
+ describe "#advpng_options" do
58
+ let(:options_hash) { {advpng_options: {foo: 'bar'}} }
59
+ subject { options.advpng_options().should == {foo: 'bar'} }
60
+ end
61
+
62
+ describe "#jpegoptim_options" do
63
+ let(:options_hash) { {jpegoptim_options: {foo: 'bar'}} }
64
+ subject { options.jpegoptim_options().should == {foo: 'bar'} }
65
+ end
66
+
67
+ describe "#jpegtran_options" do
68
+ let(:options_hash) { {jpegtran_options: {foo: 'bar'}} }
69
+ subject { options.jpegtran_options().should == {foo: 'bar'} }
70
+ end
71
+
72
+ describe "#gifsicle_options" do
73
+ let(:options_hash) { {gifsicle_options: {foo: 'bar'}} }
74
+ subject { options.gifsicle_options().should == {foo: 'bar'} }
75
+ end
76
+ end
77
+ end
@@ -0,0 +1,15 @@
1
+ puts "[Simplecov] enabled"
2
+ require 'simplecov'
3
+
4
+ class SimpleCov::Formatter::QualityFormatter
5
+ def format(result)
6
+ SimpleCov::Formatter::HTMLFormatter.new.format(result)
7
+ File.open("coverage/covered_percent", "w") do |f|
8
+ f.puts result.source_files.covered_percent.to_f
9
+ end
10
+ end
11
+ end
12
+
13
+ SimpleCov.formatter = SimpleCov::Formatter::QualityFormatter
14
+
15
+ SimpleCov.start 'rails'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: middleman-imageoptim
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.1.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-04-11 00:00:00.000000000 Z
12
+ date: 2013-10-28 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: middleman-core
@@ -34,7 +34,7 @@ dependencies:
34
34
  requirements:
35
35
  - - ~>
36
36
  - !ruby/object:Gem::Version
37
- version: 0.8.0
37
+ version: 0.9.1
38
38
  type: :runtime
39
39
  prerelease: false
40
40
  version_requirements: !ruby/object:Gem::Requirement
@@ -42,7 +42,103 @@ dependencies:
42
42
  requirements:
43
43
  - - ~>
44
44
  - !ruby/object:Gem::Version
45
- version: 0.8.0
45
+ version: 0.9.1
46
+ - !ruby/object:Gem::Dependency
47
+ name: padrino-helpers
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ! '>='
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
54
+ type: :development
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ - !ruby/object:Gem::Dependency
63
+ name: rspec
64
+ requirement: !ruby/object:Gem::Requirement
65
+ none: false
66
+ requirements:
67
+ - - ! '>='
68
+ - !ruby/object:Gem::Version
69
+ version: '0'
70
+ type: :development
71
+ prerelease: false
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ! '>='
76
+ - !ruby/object:Gem::Version
77
+ version: '0'
78
+ - !ruby/object:Gem::Dependency
79
+ name: rake
80
+ requirement: !ruby/object:Gem::Requirement
81
+ none: false
82
+ requirements:
83
+ - - ! '>='
84
+ - !ruby/object:Gem::Version
85
+ version: '0'
86
+ type: :development
87
+ prerelease: false
88
+ version_requirements: !ruby/object:Gem::Requirement
89
+ none: false
90
+ requirements:
91
+ - - ! '>='
92
+ - !ruby/object:Gem::Version
93
+ version: '0'
94
+ - !ruby/object:Gem::Dependency
95
+ name: cucumber
96
+ requirement: !ruby/object:Gem::Requirement
97
+ none: false
98
+ requirements:
99
+ - - ! '>='
100
+ - !ruby/object:Gem::Version
101
+ version: '0'
102
+ type: :development
103
+ prerelease: false
104
+ version_requirements: !ruby/object:Gem::Requirement
105
+ none: false
106
+ requirements:
107
+ - - ! '>='
108
+ - !ruby/object:Gem::Version
109
+ version: '0'
110
+ - !ruby/object:Gem::Dependency
111
+ name: simplecov
112
+ requirement: !ruby/object:Gem::Requirement
113
+ none: false
114
+ requirements:
115
+ - - ! '>='
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ none: false
122
+ requirements:
123
+ - - ! '>='
124
+ - !ruby/object:Gem::Version
125
+ version: '0'
126
+ - !ruby/object:Gem::Dependency
127
+ name: cane
128
+ requirement: !ruby/object:Gem::Requirement
129
+ none: false
130
+ requirements:
131
+ - - ! '>='
132
+ - !ruby/object:Gem::Version
133
+ version: '0'
134
+ type: :development
135
+ prerelease: false
136
+ version_requirements: !ruby/object:Gem::Requirement
137
+ none: false
138
+ requirements:
139
+ - - ! '>='
140
+ - !ruby/object:Gem::Version
141
+ version: '0'
46
142
  description: Small images are small! Compress yours during middleman build.
47
143
  email:
48
144
  - desk@pixelbloom.com
@@ -51,14 +147,22 @@ extensions: []
51
147
  extra_rdoc_files: []
52
148
  files:
53
149
  - .gitignore
150
+ - .rspec
54
151
  - Gemfile
152
+ - LICENSE
55
153
  - README.md
56
154
  - Rakefile
57
- - features/support/env.rb
58
155
  - lib/middleman-imageoptim.rb
156
+ - lib/middleman-imageoptim/extension.rb
157
+ - lib/middleman-imageoptim/optimizer.rb
158
+ - lib/middleman-imageoptim/options.rb
59
159
  - lib/middleman-imageoptim/version.rb
60
160
  - lib/middleman_extension.rb
61
161
  - middleman-imageoptim.gemspec
162
+ - spec/spec_helper.rb
163
+ - spec/unit/optimizer_spec.rb
164
+ - spec/unit/options_spec.rb
165
+ - spec/use_simplecov.rb
62
166
  homepage: https://github.com/plasticine/middleman-imageoptim
63
167
  licenses: []
64
168
  post_install_message:
@@ -71,17 +175,23 @@ required_ruby_version: !ruby/object:Gem::Requirement
71
175
  - - ! '>='
72
176
  - !ruby/object:Gem::Version
73
177
  version: '0'
178
+ segments:
179
+ - 0
180
+ hash: -1391481925218508789
74
181
  required_rubygems_version: !ruby/object:Gem::Requirement
75
182
  none: false
76
183
  requirements:
77
184
  - - ! '>='
78
185
  - !ruby/object:Gem::Version
79
186
  version: '0'
187
+ segments:
188
+ - 0
189
+ hash: -1391481925218508789
80
190
  requirements: []
81
191
  rubyforge_project:
82
192
  rubygems_version: 1.8.23
83
193
  signing_key:
84
194
  specification_version: 3
85
195
  summary: Small images are small! Compress yours during middleman build.
86
- test_files:
87
- - features/support/env.rb
196
+ test_files: []
197
+ has_rdoc:
@@ -1,4 +0,0 @@
1
- PROJECT_ROOT_PATH = File.dirname(File.dirname(File.dirname(__FILE__)))
2
- require "middleman-core"
3
- require "middleman-core/step_definitions"
4
- require File.join(PROJECT_ROOT_PATH, 'lib', 'middleman-imageoptim')