image_optim_rails 0.1.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.
- checksums.yaml +7 -0
- data/.gitignore +14 -0
- data/.rubocop.yml +75 -0
- data/.travis.yml +43 -0
- data/Gemfile +12 -0
- data/LICENSE.txt +20 -0
- data/README.markdown +45 -0
- data/image_optim_rails.gemspec +27 -0
- data/lib/image_optim/railtie.rb +66 -0
- data/lib/image_optim_rails.rb +1 -0
- data/spec/image_optim/railtie_spec.rb +149 -0
- data/spec/spec_helper.rb +70 -0
- metadata +146 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 0a27fab3ec29968a0f1461aa69f5d1f3238d2a05
|
4
|
+
data.tar.gz: 14e3da57b4023c649e9ed3a4874ab5621174c545
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: ff3b6c95266bbb357df1faab872a7427af1eea240f5d29eeedfd99b8f9b0fbcea8efd01049643c266b6a7822b3c6898ca8c1c8cb97007bd463cee098e4b6b6fe
|
7
|
+
data.tar.gz: 5a0cc79969ee1ea39c78246e6a9b7f66b6846985749f6e7ffb39a275ed8fc8cd1f14469abee011dd841221e04c33b9b824b4067ddd7d184ef1fe0d5a5d80670e
|
data/.gitignore
ADDED
data/.rubocop.yml
ADDED
@@ -0,0 +1,75 @@
|
|
1
|
+
AllCops:
|
2
|
+
Exclude:
|
3
|
+
- '*.gemspec'
|
4
|
+
- 'vendor/**/*'
|
5
|
+
|
6
|
+
Lint/EndAlignment:
|
7
|
+
AlignWith: variable
|
8
|
+
|
9
|
+
Metrics/AbcSize:
|
10
|
+
Max: 30
|
11
|
+
|
12
|
+
Metrics/MethodLength:
|
13
|
+
Max: 25
|
14
|
+
|
15
|
+
Style/AccessModifierIndentation:
|
16
|
+
EnforcedStyle: outdent
|
17
|
+
|
18
|
+
Style/Alias:
|
19
|
+
EnforcedStyle: prefer_alias_method
|
20
|
+
|
21
|
+
Style/CaseIndentation:
|
22
|
+
IndentWhenRelativeTo: end
|
23
|
+
|
24
|
+
Style/DotPosition:
|
25
|
+
EnforcedStyle: trailing
|
26
|
+
|
27
|
+
Style/DoubleNegation:
|
28
|
+
Enabled: false
|
29
|
+
|
30
|
+
Style/EmptyCaseCondition:
|
31
|
+
Enabled: false
|
32
|
+
|
33
|
+
Style/Encoding:
|
34
|
+
EnforcedStyle: when_needed
|
35
|
+
|
36
|
+
Style/HashSyntax:
|
37
|
+
EnforcedStyle: hash_rockets
|
38
|
+
|
39
|
+
Style/IfUnlessModifier:
|
40
|
+
MaxLineLength: 40
|
41
|
+
|
42
|
+
Style/IndentArray:
|
43
|
+
EnforcedStyle: consistent
|
44
|
+
|
45
|
+
Style/IndentAssignment:
|
46
|
+
Enabled: false
|
47
|
+
|
48
|
+
Style/IndentHash:
|
49
|
+
EnforcedStyle: consistent
|
50
|
+
|
51
|
+
Style/ParallelAssignment:
|
52
|
+
Enabled: false
|
53
|
+
|
54
|
+
Style/PercentLiteralDelimiters:
|
55
|
+
PreferredDelimiters:
|
56
|
+
'%w': '[]'
|
57
|
+
'%W': '[]'
|
58
|
+
|
59
|
+
Style/Semicolon:
|
60
|
+
AllowAsExpressionSeparator: true
|
61
|
+
|
62
|
+
Style/SignalException:
|
63
|
+
EnforcedStyle: semantic
|
64
|
+
|
65
|
+
Style/SpaceBeforeBlockBraces:
|
66
|
+
EnforcedStyle: no_space
|
67
|
+
|
68
|
+
Style/SpaceInsideHashLiteralBraces:
|
69
|
+
EnforcedStyle: no_space
|
70
|
+
|
71
|
+
Style/TrailingCommaInArguments:
|
72
|
+
EnforcedStyleForMultiline: no_comma
|
73
|
+
|
74
|
+
Style/TrailingCommaInLiteral:
|
75
|
+
EnforcedStyleForMultiline: comma
|
data/.travis.yml
ADDED
@@ -0,0 +1,43 @@
|
|
1
|
+
sudo: false
|
2
|
+
language: ruby
|
3
|
+
cache:
|
4
|
+
bundler: true
|
5
|
+
directories:
|
6
|
+
- $(npm root)
|
7
|
+
- ~/bin
|
8
|
+
script: |
|
9
|
+
(
|
10
|
+
set -ex
|
11
|
+
if [ -n "$RUBOCOP" ]; then
|
12
|
+
bundle exec rubocop
|
13
|
+
else
|
14
|
+
bundle exec image_optim --info
|
15
|
+
bundle exec rspec
|
16
|
+
fi
|
17
|
+
)
|
18
|
+
before_install: |
|
19
|
+
(
|
20
|
+
set -ex
|
21
|
+
if [ -z "$RUBOCOP" ]; then
|
22
|
+
command -v svgo || npm install svgo
|
23
|
+
command -v pngout || {
|
24
|
+
mkdir -p ~/bin
|
25
|
+
curl -L "http://static.jonof.id.au/dl/kenutils/pngout-20130221-linux.tar.gz" | tar -xz -C ~/bin --strip-components 2 --wildcards '*/x86_64/pngout'
|
26
|
+
}
|
27
|
+
fi
|
28
|
+
)
|
29
|
+
matrix:
|
30
|
+
fast_finish: true
|
31
|
+
include:
|
32
|
+
- env: RAILS_VERSION='~> 3.2'
|
33
|
+
rvm: default
|
34
|
+
- env: RAILS_VERSION='~> 4.0' SPROCKETS_RAILS_VERSION='~> 2.0'
|
35
|
+
rvm: '2'
|
36
|
+
- env: RAILS_VERSION='~> 4.0'
|
37
|
+
rvm: '2'
|
38
|
+
- env: RAILS_VERSION='~> 5.0' SPROCKETS_RAILS_VERSION='~> 2.0'
|
39
|
+
rvm: '2.2.2'
|
40
|
+
- env: RAILS_VERSION='~> 5.0'
|
41
|
+
rvm: '2.2.2'
|
42
|
+
- env: RUBOCOP=true
|
43
|
+
rvm: '2.2.2'
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2013-2016 Ivan Kuchin
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.markdown
ADDED
@@ -0,0 +1,45 @@
|
|
1
|
+
[](https://rubygems.org/gems/image_optim_rails)
|
2
|
+
[](https://travis-ci.org/toy/image_optim_rails)
|
3
|
+
[](https://codeclimate.com/github/toy/image_optim_rails)
|
4
|
+
[](https://gemnasium.com/toy/image_optim_rails)
|
5
|
+
[](https://inch-ci.org/github/toy/image_optim_rails)
|
6
|
+
|
7
|
+
# image\_optim\_rails
|
8
|
+
|
9
|
+
Optimize rails image assets using image_optim gem.
|
10
|
+
|
11
|
+
Options and instructions for getting binaries can be found in [image_optim readme](https://github.com/toy/image_optim).
|
12
|
+
|
13
|
+
## Installation
|
14
|
+
|
15
|
+
Add to your `Gemfile`:
|
16
|
+
|
17
|
+
```ruby
|
18
|
+
gem 'image_optim'
|
19
|
+
```
|
20
|
+
|
21
|
+
With [`image_optim_pack`](https://github.com/toy/image_optim_pack):
|
22
|
+
|
23
|
+
```ruby
|
24
|
+
gem 'image_optim'
|
25
|
+
gem 'image_optim_pack'
|
26
|
+
```
|
27
|
+
|
28
|
+
## Usage
|
29
|
+
|
30
|
+
`ImageOptim::Railtie` will automatically register sprockets preprocessor unless you set `config.assets.image_optim = false` or `config.assets.compress = false` (later for partial rails 3 compatibility).
|
31
|
+
|
32
|
+
You can provide options for image_optim used for preprocessor through config:
|
33
|
+
|
34
|
+
```ruby
|
35
|
+
config.assets.image_optim.nice = 20
|
36
|
+
config.assets.image_optim.svgo = false
|
37
|
+
```
|
38
|
+
|
39
|
+
Check available options in [options section of image_optim](https://github.com/toy/image_optim#options).
|
40
|
+
|
41
|
+
Image optimization can be time consuming, so depending on your deployment process you may prefer to optimize original asset files.
|
42
|
+
|
43
|
+
## Copyright
|
44
|
+
|
45
|
+
Copyright (c) 2013-2016 Ivan Kuchin. See [LICENSE.txt](LICENSE.txt) for details.
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
|
3
|
+
Gem::Specification.new do |s|
|
4
|
+
s.name = 'image_optim_rails'
|
5
|
+
s.version = '0.1.0'
|
6
|
+
s.summary = %q{Optimize image assets using image_optim}
|
7
|
+
s.homepage = "http://github.com/toy/#{s.name}"
|
8
|
+
s.authors = ['Ivan Kuchin']
|
9
|
+
s.license = 'MIT'
|
10
|
+
|
11
|
+
s.rubyforge_project = s.name
|
12
|
+
|
13
|
+
s.files = `git ls-files`.split("\n")
|
14
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
15
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
16
|
+
s.require_paths = %w[lib]
|
17
|
+
|
18
|
+
s.add_dependency 'image_optim', '~> 0.24.0'
|
19
|
+
s.add_dependency 'rails'
|
20
|
+
s.add_dependency 'sprockets'
|
21
|
+
|
22
|
+
s.add_development_dependency 'image_optim_pack', '~> 0.2', '>= 0.2.2'
|
23
|
+
s.add_development_dependency 'rspec', '~> 3.0'
|
24
|
+
if RUBY_VERSION >= '2.0'
|
25
|
+
s.add_development_dependency 'rubocop', '~> 0.37'
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,66 @@
|
|
1
|
+
require 'image_optim'
|
2
|
+
|
3
|
+
class ImageOptim
|
4
|
+
# Adds image_optim as preprocessor for gif, jpeg, png and svg images
|
5
|
+
class Railtie < Rails::Railtie
|
6
|
+
MIME_TYPES = %w[
|
7
|
+
image/gif
|
8
|
+
image/jpeg
|
9
|
+
image/png
|
10
|
+
image/svg+xml
|
11
|
+
].freeze
|
12
|
+
|
13
|
+
config.before_configuration do |app|
|
14
|
+
worker_names = ImageOptim::Worker.klasses.map(&:bin_sym)
|
15
|
+
app.config.assets.image_optim =
|
16
|
+
ActiveSupport::OrderedOptions.new do |hash, key|
|
17
|
+
if worker_names.include?(key.to_sym)
|
18
|
+
hash[key] = ActiveSupport::OrderedOptions.new
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
initializer 'image_optim.initializer' do |app|
|
24
|
+
next if app.config.assets.compress == false
|
25
|
+
next if app.config.assets.image_optim == false
|
26
|
+
|
27
|
+
@image_optim = ImageOptim.new(options(app))
|
28
|
+
|
29
|
+
register_preprocessor(app) do |*args|
|
30
|
+
if args[1] # context and data arguments in sprockets 2
|
31
|
+
optimize_image_data(args[1])
|
32
|
+
else
|
33
|
+
input = args[0]
|
34
|
+
{
|
35
|
+
:data => optimize_image_data(input[:data]),
|
36
|
+
:charset => nil, # no gzipped version with rails/sprockets#228
|
37
|
+
}
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
def options(app)
|
43
|
+
if app.config.assets.image_optim == true
|
44
|
+
{}
|
45
|
+
else
|
46
|
+
app.config.assets.image_optim || {}
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
def optimize_image_data(data)
|
51
|
+
@image_optim.optimize_image_data(data) || data
|
52
|
+
end
|
53
|
+
|
54
|
+
def register_preprocessor(app, &processor)
|
55
|
+
MIME_TYPES.each do |mime_type|
|
56
|
+
if app.assets
|
57
|
+
app.assets.register_preprocessor mime_type, :image_optim, &processor
|
58
|
+
else
|
59
|
+
app.config.assets.configure do |env|
|
60
|
+
env.register_preprocessor mime_type, :image_optim, &processor
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
require 'image_optim/railtie'
|
@@ -0,0 +1,149 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'rails/all'
|
3
|
+
require 'image_optim/railtie'
|
4
|
+
|
5
|
+
describe 'ImageOptim::Railtie' do
|
6
|
+
def init_rails_app
|
7
|
+
Class.new(Rails::Application) do
|
8
|
+
# Rails 4 requires application class to have name
|
9
|
+
define_singleton_method :name do
|
10
|
+
'Dummy'
|
11
|
+
end
|
12
|
+
|
13
|
+
config.active_support.deprecation = :stderr
|
14
|
+
config.eager_load = false
|
15
|
+
|
16
|
+
config.logger = Logger.new('/dev/null')
|
17
|
+
|
18
|
+
config.assets.tap do |assets|
|
19
|
+
assets.enabled = true
|
20
|
+
assets.version = '1.0'
|
21
|
+
assets.cache_store = :null_store
|
22
|
+
|
23
|
+
# grab images from image_optim gem
|
24
|
+
image_optim_root = Gem.loaded_specs['image_optim'].gem_dir
|
25
|
+
assets.paths = [FSPath.new(image_optim_root) / 'spec/images']
|
26
|
+
|
27
|
+
assets.delete(:compress)
|
28
|
+
end
|
29
|
+
|
30
|
+
yield config if block_given?
|
31
|
+
end.initialize!
|
32
|
+
end
|
33
|
+
|
34
|
+
after do
|
35
|
+
Rails.application = nil
|
36
|
+
end
|
37
|
+
|
38
|
+
describe 'initialization' do
|
39
|
+
it 'initializes by default' do
|
40
|
+
expect(ImageOptim).to receive(:new)
|
41
|
+
init_rails_app
|
42
|
+
end
|
43
|
+
|
44
|
+
it 'initializes if config.assets.image_optim is nil' do
|
45
|
+
expect(ImageOptim).to receive(:new)
|
46
|
+
init_rails_app do |config|
|
47
|
+
config.assets.image_optim = nil
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
it 'does not initialize if config.assets.image_optim is false' do
|
52
|
+
expect(ImageOptim).not_to receive(:new)
|
53
|
+
init_rails_app do |config|
|
54
|
+
config.assets.image_optim = false
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
it 'does not initialize if config.assets.compress is false' do
|
59
|
+
expect(ImageOptim).not_to receive(:new)
|
60
|
+
init_rails_app do |config|
|
61
|
+
config.assets.compress = false
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
describe 'options' do
|
66
|
+
it 'initializes with empty hash by default' do
|
67
|
+
expect(ImageOptim).to receive(:new).with({})
|
68
|
+
init_rails_app
|
69
|
+
end
|
70
|
+
|
71
|
+
it 'initializes with empty hash if config.assets.image_optim is true' do
|
72
|
+
expect(ImageOptim).to receive(:new).with({})
|
73
|
+
init_rails_app do |config|
|
74
|
+
config.assets.image_optim = true
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
it 'initializes with empty hash if config.assets.image_optim is nil' do
|
79
|
+
expect(ImageOptim).to receive(:new).with({})
|
80
|
+
init_rails_app do |config|
|
81
|
+
config.assets.image_optim = nil
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
it 'initializes with hash assigned to config.assets.image_optim' do
|
86
|
+
hash = double
|
87
|
+
expect(ImageOptim).to receive(:new).with(hash)
|
88
|
+
init_rails_app do |config|
|
89
|
+
config.assets.image_optim = hash
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
93
|
+
it 'is possible to set individual options' do
|
94
|
+
hash = {:config_paths => 'config/image_optim.yml'}
|
95
|
+
expect(ImageOptim).to receive(:new).with(hash)
|
96
|
+
init_rails_app do |config|
|
97
|
+
config.assets.image_optim.config_paths = 'config/image_optim.yml'
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
101
|
+
it 'is possible to set individual worker options' do
|
102
|
+
hash = {:advpng => {:level => 3}}
|
103
|
+
expect(ImageOptim).to receive(:new).with(hash)
|
104
|
+
init_rails_app do |config|
|
105
|
+
expect(config.assets.image_optim.advpng).to eq({})
|
106
|
+
config.assets.image_optim.advpng.level = 3
|
107
|
+
end
|
108
|
+
end
|
109
|
+
|
110
|
+
it 'is not possible to set unknown worker options' do
|
111
|
+
expect(ImageOptim).to receive(:new).with({})
|
112
|
+
init_rails_app do |config|
|
113
|
+
expect(config.assets.image_optim.unknown).to eq(nil)
|
114
|
+
expect do
|
115
|
+
config.assets.image_optim.unknown.level = 3
|
116
|
+
end.to raise_error(NoMethodError)
|
117
|
+
end
|
118
|
+
end
|
119
|
+
end
|
120
|
+
end
|
121
|
+
|
122
|
+
describe 'optimizing assets' do
|
123
|
+
before do
|
124
|
+
stub_const('Path', ImageOptim::Path)
|
125
|
+
end
|
126
|
+
|
127
|
+
%w[
|
128
|
+
icecream.gif
|
129
|
+
lena.jpg
|
130
|
+
rails.png
|
131
|
+
test.svg
|
132
|
+
].each do |asset_name|
|
133
|
+
it "optimizes #{asset_name}" do
|
134
|
+
asset = init_rails_app.assets.find_asset(asset_name)
|
135
|
+
|
136
|
+
asset_data = asset.source
|
137
|
+
original = Path.convert(asset.pathname)
|
138
|
+
|
139
|
+
expect(asset_data).to be_smaller_than(original)
|
140
|
+
|
141
|
+
Path.temp_file_path %W[spec .#{original.image_format}] do |temp|
|
142
|
+
temp.binwrite(asset_data)
|
143
|
+
|
144
|
+
expect(temp).to be_similar_to(original, 0)
|
145
|
+
end
|
146
|
+
end
|
147
|
+
end
|
148
|
+
end
|
149
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,70 @@
|
|
1
|
+
require 'image_optim/pack'
|
2
|
+
require 'image_optim/path'
|
3
|
+
|
4
|
+
ENV['PATH'] = [
|
5
|
+
ImageOptim::Pack.path,
|
6
|
+
ENV['PATH'],
|
7
|
+
].compact.join File::PATH_SEPARATOR
|
8
|
+
|
9
|
+
RSpec.configure do |c|
|
10
|
+
c.before do
|
11
|
+
stub_const('ImageOptim::Config::GLOBAL_PATH', ImageOptim::Path::NULL)
|
12
|
+
stub_const('ImageOptim::Config::LOCAL_PATH', ImageOptim::Path::NULL)
|
13
|
+
ImageOptim.class_eval{ def pack; end }
|
14
|
+
end
|
15
|
+
|
16
|
+
c.order = :random
|
17
|
+
end
|
18
|
+
|
19
|
+
def flatten_animation(image)
|
20
|
+
if image.image_format == :gif
|
21
|
+
flattened = image.temp_path
|
22
|
+
command = %W[
|
23
|
+
convert
|
24
|
+
#{image.to_s.shellescape}
|
25
|
+
-coalesce
|
26
|
+
-append
|
27
|
+
#{flattened.to_s.shellescape}
|
28
|
+
].join(' ')
|
29
|
+
expect(ImageOptim::Cmd.run(command)).to be_truthy
|
30
|
+
flattened
|
31
|
+
else
|
32
|
+
image
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
def mepp(image_a, image_b)
|
37
|
+
coalesce_a = flatten_animation(image_a)
|
38
|
+
coalesce_b = flatten_animation(image_b)
|
39
|
+
command = %W[
|
40
|
+
compare
|
41
|
+
-metric MEPP
|
42
|
+
-alpha Background
|
43
|
+
#{coalesce_a.to_s.shellescape}
|
44
|
+
#{coalesce_b.to_s.shellescape}
|
45
|
+
#{ImageOptim::Path::NULL}
|
46
|
+
2>&1
|
47
|
+
].join(' ')
|
48
|
+
output = ImageOptim::Cmd.capture(command)
|
49
|
+
if [0, 1].include?($CHILD_STATUS.exitstatus)
|
50
|
+
num_r = '\d+(?:\.\d+(?:[eE][-+]?\d+)?)?'
|
51
|
+
output[/\((#{num_r}), #{num_r}\)/, 1].to_f
|
52
|
+
else
|
53
|
+
fail "compare #{image_a} with #{image_b} failed with `#{output}`"
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
RSpec::Matchers.define :be_smaller_than do |expected|
|
58
|
+
match{ |actual| actual.size < expected.size }
|
59
|
+
end
|
60
|
+
|
61
|
+
RSpec::Matchers.define :be_similar_to do |expected, max_difference|
|
62
|
+
match do |actual|
|
63
|
+
@diff = mepp(actual, expected)
|
64
|
+
@diff <= max_difference
|
65
|
+
end
|
66
|
+
failure_message do |actual|
|
67
|
+
"expected #{actual} to have at most #{max_difference} difference from "\
|
68
|
+
"#{expected}, got normalized root-mean-square error of #{@diff}"
|
69
|
+
end
|
70
|
+
end
|
metadata
ADDED
@@ -0,0 +1,146 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: image_optim_rails
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Ivan Kuchin
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-08-14 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: image_optim
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 0.24.0
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 0.24.0
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rails
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: sprockets
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: image_optim_pack
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0.2'
|
62
|
+
- - ">="
|
63
|
+
- !ruby/object:Gem::Version
|
64
|
+
version: 0.2.2
|
65
|
+
type: :development
|
66
|
+
prerelease: false
|
67
|
+
version_requirements: !ruby/object:Gem::Requirement
|
68
|
+
requirements:
|
69
|
+
- - "~>"
|
70
|
+
- !ruby/object:Gem::Version
|
71
|
+
version: '0.2'
|
72
|
+
- - ">="
|
73
|
+
- !ruby/object:Gem::Version
|
74
|
+
version: 0.2.2
|
75
|
+
- !ruby/object:Gem::Dependency
|
76
|
+
name: rspec
|
77
|
+
requirement: !ruby/object:Gem::Requirement
|
78
|
+
requirements:
|
79
|
+
- - "~>"
|
80
|
+
- !ruby/object:Gem::Version
|
81
|
+
version: '3.0'
|
82
|
+
type: :development
|
83
|
+
prerelease: false
|
84
|
+
version_requirements: !ruby/object:Gem::Requirement
|
85
|
+
requirements:
|
86
|
+
- - "~>"
|
87
|
+
- !ruby/object:Gem::Version
|
88
|
+
version: '3.0'
|
89
|
+
- !ruby/object:Gem::Dependency
|
90
|
+
name: rubocop
|
91
|
+
requirement: !ruby/object:Gem::Requirement
|
92
|
+
requirements:
|
93
|
+
- - "~>"
|
94
|
+
- !ruby/object:Gem::Version
|
95
|
+
version: '0.37'
|
96
|
+
type: :development
|
97
|
+
prerelease: false
|
98
|
+
version_requirements: !ruby/object:Gem::Requirement
|
99
|
+
requirements:
|
100
|
+
- - "~>"
|
101
|
+
- !ruby/object:Gem::Version
|
102
|
+
version: '0.37'
|
103
|
+
description:
|
104
|
+
email:
|
105
|
+
executables: []
|
106
|
+
extensions: []
|
107
|
+
extra_rdoc_files: []
|
108
|
+
files:
|
109
|
+
- ".gitignore"
|
110
|
+
- ".rubocop.yml"
|
111
|
+
- ".travis.yml"
|
112
|
+
- Gemfile
|
113
|
+
- LICENSE.txt
|
114
|
+
- README.markdown
|
115
|
+
- image_optim_rails.gemspec
|
116
|
+
- lib/image_optim/railtie.rb
|
117
|
+
- lib/image_optim_rails.rb
|
118
|
+
- spec/image_optim/railtie_spec.rb
|
119
|
+
- spec/spec_helper.rb
|
120
|
+
homepage: http://github.com/toy/image_optim_rails
|
121
|
+
licenses:
|
122
|
+
- MIT
|
123
|
+
metadata: {}
|
124
|
+
post_install_message:
|
125
|
+
rdoc_options: []
|
126
|
+
require_paths:
|
127
|
+
- lib
|
128
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
129
|
+
requirements:
|
130
|
+
- - ">="
|
131
|
+
- !ruby/object:Gem::Version
|
132
|
+
version: '0'
|
133
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
134
|
+
requirements:
|
135
|
+
- - ">="
|
136
|
+
- !ruby/object:Gem::Version
|
137
|
+
version: '0'
|
138
|
+
requirements: []
|
139
|
+
rubyforge_project: image_optim_rails
|
140
|
+
rubygems_version: 2.6.4
|
141
|
+
signing_key:
|
142
|
+
specification_version: 4
|
143
|
+
summary: Optimize image assets using image_optim
|
144
|
+
test_files:
|
145
|
+
- spec/image_optim/railtie_spec.rb
|
146
|
+
- spec/spec_helper.rb
|