middleman-imageoptim 0.1.4 → 0.2.0

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.
@@ -1 +1 @@
1
- require "middleman-imageoptim"
1
+ require 'middleman-imageoptim'
@@ -1,28 +1,31 @@
1
1
  # -*- encoding: utf-8 -*-
2
- $:.push File.expand_path("../lib", __FILE__)
2
+ $LOAD_PATH.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
6
  gem.name = Middleman::Imageoptim::PACKAGE
7
7
  gem.version = Middleman::Imageoptim::VERSION
8
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.}
9
+ gem.authors = ['Justin Morris']
10
+ gem.email = ['desk@pixelbloom.com']
11
+ gem.homepage = 'https://github.com/plasticine/middleman-imageoptim'
12
+ gem.summary = 'Small images are small! Compress yours during middleman build.'
13
+ gem.description = 'Small images are small! Compress yours during middleman build.'
14
14
  gem.license = 'MIT'
15
15
  gem.files = `git ls-files`.split("\n")
16
- gem.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
17
- gem.require_paths = ["lib"]
16
+ gem.executables = `git ls-files -- bin/*`.split("\n").map { |f| File.basename(f) }
17
+ gem.require_paths = ['lib']
18
18
 
19
- gem.add_dependency "middleman-core", [">= 3.0"]
20
- gem.add_dependency "image_optim", "~> 0.9.1"
19
+ gem.add_dependency 'middleman-core', ['>= 3.0']
20
+ gem.add_dependency 'image_optim', '~> 0.20.2'
21
+ gem.add_dependency 'image_optim_pack', '~> 0.2.1'
21
22
 
22
- gem.add_development_dependency "rspec"
23
- gem.add_development_dependency "rake"
24
- gem.add_development_dependency "cucumber"
25
- gem.add_development_dependency "simplecov"
26
- gem.add_development_dependency "coveralls"
27
- gem.add_development_dependency "cane"
23
+ gem.add_development_dependency 'aruba'
24
+ gem.add_development_dependency 'cucumber'
25
+ gem.add_development_dependency 'pry'
26
+ gem.add_development_dependency 'rake'
27
+ gem.add_development_dependency 'rspec', '>= 3.0.0'
28
+ gem.add_development_dependency 'rspec-its'
29
+ gem.add_development_dependency 'rubocop'
30
+ gem.add_development_dependency 'simplecov'
28
31
  end
@@ -1,11 +1,26 @@
1
1
  #!/usr/bin/env bash
2
2
 
3
- export COVERAGE=true
3
+ set -eo pipefail
4
4
 
5
- bundle --binstubs | grep -v '^Using'
5
+ prepare() {
6
+ bundle --binstubs | grep -v '^Using'
7
+ rm -rf coverage
8
+ }
6
9
 
7
- rm -rf coverage
10
+ check_style() {
11
+ rubocop
12
+ }
8
13
 
9
- bin/rake
14
+ run_tests() {
15
+ bin/rake spec:unit
16
+ bin/rake spec:features
17
+ }
10
18
 
11
- script/quality
19
+ main() {
20
+ prepare
21
+ check_style
22
+ run_tests
23
+
24
+ }
25
+
26
+ main $@
@@ -1,11 +1,8 @@
1
- if ENV['COVERAGE']
2
- require_relative 'use_coveralls' if ENV['TRAVIS']
3
- require_relative 'use_simplecov'
4
- end
1
+ require 'rspec/its'
2
+ require 'simplecov'
3
+ require 'middleman-imageoptim'
5
4
 
6
5
  RSpec.configure do |config|
7
- config.treat_symbols_as_metadata_keys_with_true_values = true
8
- config.run_all_when_everything_filtered = true
9
- config.filter_run :focus
10
6
  config.order = 'random'
7
+ config.raise_errors_for_deprecations!
11
8
  end
@@ -1,77 +1,126 @@
1
- require_relative "../../lib/middleman-imageoptim/options"
1
+ require 'spec_helper'
2
+ require_relative '../../lib/middleman-imageoptim/options'
2
3
 
3
4
  describe Middleman::Imageoptim::Options do
4
- subject { Middleman::Imageoptim::Options.new(options_hash) }
5
5
  let(:options_hash) { {} }
6
+ let(:instance) { described_class.new(options_hash) }
7
+ subject { instance }
6
8
 
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} }
9
+ describe 'default options' do
10
+ its(:verbose) { should be_falsey }
11
+ its(:nice) { should be_truthy }
12
+ its(:threads) { should be_truthy }
13
+ its(:skip_missing_workers) { should be_truthy }
14
+ its(:allow_lossy) { should be_falsey }
15
+ its(:image_extensions) { should == ['.png', '.jpg', '.jpeg', '.gif', '.svg'] }
16
+ its(:pngcrush) { should == { chunks: ['alla'], fix: false, brute: false } }
17
+ its(:pngout) { should == { copy_chunks: false, strategy: 0 } }
18
+ its(:optipng) { should == { level: 6, interlace: false } }
19
+ its(:advpng) { should == { level: 4 } }
20
+ its(:jpegoptim) { should == { strip: ['all'], max_quality: 100 } }
21
+ its(:jpegtran) { should == { copy_chunks: false, progressive: true, jpegrescan: true } }
22
+ its(:gifsicle) { should == { interlace: false } }
23
+ its(:svgo) { should == {} }
19
24
  end
20
25
 
21
- describe "with user options" do
22
- describe "#verbose" do
23
- let(:options_hash) { {verbose: true} }
24
- subject { options.verbose().should be_true }
26
+ describe 'getting options for imageoptim' do
27
+ describe '#imageoptim_options' do
28
+ subject { instance.imageoptim_options }
29
+ let(:options_hash) do
30
+ { verbose: true, manifest: false, image_extensions: ['.gif'] }
31
+ end
32
+ it do
33
+ is_expected.to eql(
34
+ advpng: { level: 4 },
35
+ allow_lossy: false,
36
+ gifsicle: { interlace: false },
37
+ jpegoptim: { strip: ['all'], max_quality: 100 },
38
+ jpegtran: { copy_chunks: false, progressive: true, jpegrescan: true },
39
+ nice: true,
40
+ optipng: { level: 6, interlace: false },
41
+ pack: true,
42
+ pngcrush: { chunks: ['alla'], fix: false, brute: false },
43
+ pngout: { copy_chunks: false, strategy: 0 },
44
+ skip_missing_workers: true,
45
+ svgo: {},
46
+ threads: true,
47
+ verbose: true
48
+ )
49
+ end
50
+ end
51
+ end
52
+
53
+ describe 'with user options' do
54
+ describe '#verbose' do
55
+ subject { instance.verbose }
56
+ let(:options_hash) { { verbose: true } }
57
+ it { is_expected.to be_truthy }
58
+ end
59
+
60
+ describe '#nice' do
61
+ subject { instance.nice }
62
+ let(:options_hash) { { nice: false } }
63
+ it { is_expected.to be_falsey }
25
64
  end
26
65
 
27
- describe "#nice" do
28
- let(:options_hash) { {nice: false} }
29
- subject { options.nice().should be_false }
66
+ describe '#threads' do
67
+ subject { instance.threads }
68
+ let(:options_hash) { { threads: false } }
69
+ it { is_expected.to be_falsey }
30
70
  end
31
71
 
32
- describe "#threads" do
33
- let(:options_hash) { {threads: false} }
34
- subject { options.threads().should be_false }
72
+ describe '#image_extensions' do
73
+ subject { instance.image_extensions }
74
+ let(:options_hash) { { image_extensions: ['.gif'] } }
75
+ it { is_expected.to eq(['.gif']) }
35
76
  end
36
77
 
37
- describe "#image_extensions" do
38
- let(:options_hash) { {image_extensions: ['.gif']} }
39
- subject { options.image_extensions().should == ['.gif'] }
78
+ describe '#pngcrush_options' do
79
+ subject { instance.pngcrush }
80
+ let(:options_hash) { { pngcrush: { foo: 'bar' } } }
81
+ it { is_expected.to eq(foo: 'bar') }
40
82
  end
41
83
 
42
- describe "#pngcrush_options" do
43
- let(:options_hash) { {pngcrush_options: {foo: 'bar'}} }
44
- subject { options.pngcrush_options().should == {foo: 'bar'} }
84
+ describe '#pngout' do
85
+ subject { instance.pngout }
86
+ let(:options_hash) { { pngout: { foo: 'bar' } } }
87
+ it { is_expected.to eq(foo: 'bar') }
45
88
  end
46
89
 
47
- describe "#pngout_options" do
48
- let(:options_hash) { {pngout_options: {foo: 'bar'}} }
49
- subject { options.pngout_options().should == {foo: 'bar'} }
90
+ describe '#optipng' do
91
+ subject { instance.optipng }
92
+ let(:options_hash) { { optipng: { foo: 'bar' } } }
93
+ it { is_expected.to eq(foo: 'bar') }
50
94
  end
51
95
 
52
- describe "#optipng_options" do
53
- let(:options_hash) { {optipng_options: {foo: 'bar'}} }
54
- subject { options.optipng_options().should == {foo: 'bar'} }
96
+ describe '#advpng' do
97
+ subject { instance.advpng }
98
+ let(:options_hash) { { advpng: { foo: 'bar' } } }
99
+ it { is_expected.to eq(foo: 'bar') }
55
100
  end
56
101
 
57
- describe "#advpng_options" do
58
- let(:options_hash) { {advpng_options: {foo: 'bar'}} }
59
- subject { options.advpng_options().should == {foo: 'bar'} }
102
+ describe '#jpegoptim' do
103
+ subject { instance.jpegoptim }
104
+ let(:options_hash) { { jpegoptim: { foo: 'bar' } } }
105
+ it { is_expected.to eq(foo: 'bar') }
60
106
  end
61
107
 
62
- describe "#jpegoptim_options" do
63
- let(:options_hash) { {jpegoptim_options: {foo: 'bar'}} }
64
- subject { options.jpegoptim_options().should == {foo: 'bar'} }
108
+ describe '#jpegtran' do
109
+ subject { instance.jpegtran }
110
+ let(:options_hash) { { jpegtran: { foo: 'bar' } } }
111
+ it { is_expected.to eq(foo: 'bar') }
65
112
  end
66
113
 
67
- describe "#jpegtran_options" do
68
- let(:options_hash) { {jpegtran_options: {foo: 'bar'}} }
69
- subject { options.jpegtran_options().should == {foo: 'bar'} }
114
+ describe '#gifsicle' do
115
+ subject { instance.gifsicle }
116
+ let(:options_hash) { { gifsicle: { foo: 'bar' } } }
117
+ it { is_expected.to eq(foo: 'bar') }
70
118
  end
71
119
 
72
- describe "#gifsicle_options" do
73
- let(:options_hash) { {gifsicle_options: {foo: 'bar'}} }
74
- subject { options.gifsicle_options().should == {foo: 'bar'} }
120
+ describe '#svgo' do
121
+ subject { instance.svgo }
122
+ let(:options_hash) { { svgo: { foo: 'bar' } } }
123
+ it { is_expected.to eq(foo: 'bar') }
75
124
  end
76
125
  end
77
126
  end
@@ -0,0 +1,55 @@
1
+ require 'spec_helper'
2
+ require_relative '../../lib/middleman-imageoptim/utils'
3
+
4
+ describe Middleman::Imageoptim::Utils do
5
+ let(:size_src) { 1000 }
6
+ let(:size_dst) { 1000 }
7
+
8
+ describe '#size_change_word' do
9
+ subject { described_class.size_change_word(size_src, size_dst) }
10
+
11
+ context 'the destination file is the same size as the source file' do
12
+ it 'should be the same size' do
13
+ expect(subject).to eq('no change')
14
+ end
15
+ end
16
+
17
+ context 'the destination file is smaller' do
18
+ let(:size_dst) { 500 }
19
+ it 'should be smaller' do
20
+ expect(subject).to eq('smaller')
21
+ end
22
+ end
23
+
24
+ context 'the destination file is larger' do
25
+ let(:size_dst) { 1500 }
26
+ it 'should be larger' do
27
+ expect(subject).to eq('larger')
28
+ end
29
+ end
30
+ end
31
+
32
+ describe '#percentage_change' do
33
+ subject { described_class.percentage_change(size_src, size_dst) }
34
+
35
+ context 'the destination file is the same size as the source file' do
36
+ it 'should be the same size' do
37
+ expect(subject).to eq('0.00%')
38
+ end
39
+ end
40
+
41
+ context 'the destination file is smaller' do
42
+ let(:size_dst) { 500 }
43
+ it 'should be smaller' do
44
+ expect(subject).to eq('50.00%')
45
+ end
46
+ end
47
+
48
+ context 'the destination file is larger' do
49
+ let(:size_dst) { 1500 }
50
+ it 'should be larger' do
51
+ expect(subject).to eq('-50.00%')
52
+ end
53
+ end
54
+ end
55
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: middleman-imageoptim
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Justin Morris
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-01-16 00:00:00.000000000 Z
11
+ date: 2015-01-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: middleman-core
@@ -30,16 +30,30 @@ dependencies:
30
30
  requirements:
31
31
  - - ~>
32
32
  - !ruby/object:Gem::Version
33
- version: 0.9.1
33
+ version: 0.20.2
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: 0.9.1
40
+ version: 0.20.2
41
41
  - !ruby/object:Gem::Dependency
42
- name: rspec
42
+ name: image_optim_pack
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ~>
46
+ - !ruby/object:Gem::Version
47
+ version: 0.2.1
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ~>
53
+ - !ruby/object:Gem::Version
54
+ version: 0.2.1
55
+ - !ruby/object:Gem::Dependency
56
+ name: aruba
43
57
  requirement: !ruby/object:Gem::Requirement
44
58
  requirements:
45
59
  - - '>='
@@ -53,7 +67,7 @@ dependencies:
53
67
  - !ruby/object:Gem::Version
54
68
  version: '0'
55
69
  - !ruby/object:Gem::Dependency
56
- name: rake
70
+ name: cucumber
57
71
  requirement: !ruby/object:Gem::Requirement
58
72
  requirements:
59
73
  - - '>='
@@ -67,7 +81,7 @@ dependencies:
67
81
  - !ruby/object:Gem::Version
68
82
  version: '0'
69
83
  - !ruby/object:Gem::Dependency
70
- name: cucumber
84
+ name: pry
71
85
  requirement: !ruby/object:Gem::Requirement
72
86
  requirements:
73
87
  - - '>='
@@ -81,7 +95,7 @@ dependencies:
81
95
  - !ruby/object:Gem::Version
82
96
  version: '0'
83
97
  - !ruby/object:Gem::Dependency
84
- name: simplecov
98
+ name: rake
85
99
  requirement: !ruby/object:Gem::Requirement
86
100
  requirements:
87
101
  - - '>='
@@ -95,7 +109,21 @@ dependencies:
95
109
  - !ruby/object:Gem::Version
96
110
  version: '0'
97
111
  - !ruby/object:Gem::Dependency
98
- name: coveralls
112
+ name: rspec
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - '>='
116
+ - !ruby/object:Gem::Version
117
+ version: 3.0.0
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - '>='
123
+ - !ruby/object:Gem::Version
124
+ version: 3.0.0
125
+ - !ruby/object:Gem::Dependency
126
+ name: rspec-its
99
127
  requirement: !ruby/object:Gem::Requirement
100
128
  requirements:
101
129
  - - '>='
@@ -109,7 +137,21 @@ dependencies:
109
137
  - !ruby/object:Gem::Version
110
138
  version: '0'
111
139
  - !ruby/object:Gem::Dependency
112
- name: cane
140
+ name: rubocop
141
+ requirement: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - '>='
144
+ - !ruby/object:Gem::Version
145
+ version: '0'
146
+ type: :development
147
+ prerelease: false
148
+ version_requirements: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - '>='
151
+ - !ruby/object:Gem::Version
152
+ version: '0'
153
+ - !ruby/object:Gem::Dependency
154
+ name: simplecov
113
155
  requirement: !ruby/object:Gem::Requirement
114
156
  requirements:
115
157
  - - '>='
@@ -129,28 +171,41 @@ executables: []
129
171
  extensions: []
130
172
  extra_rdoc_files: []
131
173
  files:
132
- - .cane
133
174
  - .gitignore
134
175
  - .rspec
176
+ - .rubocop.yml
177
+ - .rubocop_todo.yml
178
+ - .simplecov
135
179
  - .travis.yml
136
180
  - Gemfile
137
181
  - LICENSE
138
182
  - README.md
139
183
  - Rakefile
184
+ - features/manifest.feature
185
+ - features/optimization.feature
186
+ - features/permissions.feature
187
+ - features/support/env.rb
188
+ - features/support/step_definitions.rb
189
+ - fixtures/basic-app/config-disabled-manifest.rb
190
+ - fixtures/basic-app/config.rb
191
+ - fixtures/basic-app/source/images/oh_my_glob.gif
192
+ - fixtures/basic-app/source/images/table.jpg
140
193
  - lib/middleman-imageoptim.rb
141
194
  - lib/middleman-imageoptim/extension.rb
195
+ - lib/middleman-imageoptim/manifest.rb
196
+ - lib/middleman-imageoptim/manifest_resource.rb
142
197
  - lib/middleman-imageoptim/optimizer.rb
143
198
  - lib/middleman-imageoptim/options.rb
199
+ - lib/middleman-imageoptim/resource_list.rb
200
+ - lib/middleman-imageoptim/utils.rb
144
201
  - lib/middleman-imageoptim/version.rb
145
202
  - lib/middleman_extension.rb
146
203
  - middleman-imageoptim.gemspec
147
204
  - script/quality
148
205
  - script/spec
149
206
  - spec/spec_helper.rb
150
- - spec/unit/optimizer_spec.rb
151
207
  - spec/unit/options_spec.rb
152
- - spec/use_coveralls.rb
153
- - spec/use_simplecov.rb
208
+ - spec/unit/utils_spec.rb
154
209
  homepage: https://github.com/plasticine/middleman-imageoptim
155
210
  licenses:
156
211
  - MIT
@@ -171,9 +226,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
171
226
  version: '0'
172
227
  requirements: []
173
228
  rubyforge_project:
174
- rubygems_version: 2.1.11
229
+ rubygems_version: 2.0.14
175
230
  signing_key:
176
231
  specification_version: 4
177
232
  summary: Small images are small! Compress yours during middleman build.
178
233
  test_files: []
179
- has_rdoc: