middleman-webp 0.2.6 → 0.2.7
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 +4 -4
- data/.travis.yml +2 -1
- data/Gemfile +1 -1
- data/README.md +14 -0
- data/lib/middleman-webp/converter.rb +3 -1
- data/lib/middleman-webp/extension.rb +1 -0
- data/lib/middleman-webp/options.rb +2 -1
- data/lib/middleman-webp/version.rb +1 -1
- data/spec/unit/options_spec.rb +12 -0
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2a85d2700cf9364e534f055579f87d593237b34a
|
4
|
+
data.tar.gz: 320a9b9b2b14031104370981d41445e8a879c336
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: adccb7efe24726cbf0eec77d8c59ffec2304758ef36b3a79b0dede10312a6f28a81a20af58b7ee2161809c1193cc2e88e7015b3c8a15ff9a41c12ac39546b1ca
|
7
|
+
data.tar.gz: 46470f901990a55d8e69f9b6403c9ee9158c7c23de98660f626c25a7b01fb48529c6fa229c4d095fe096fa398224380c3b1d6f0814760db1681d97f776089aa6
|
data/.travis.yml
CHANGED
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -91,6 +91,19 @@ activate :webp do |webp|
|
|
91
91
|
end
|
92
92
|
```
|
93
93
|
|
94
|
+
### Forcing generation of .webp files even if they are larger
|
95
|
+
|
96
|
+
By default Middleman::WebP will only keep .webp versions if they are smaller
|
97
|
+
than original ones.
|
98
|
+
|
99
|
+
If you want avoid this behavior and always save .webp version even if they are
|
100
|
+
larger, disable allow_skip option.
|
101
|
+
|
102
|
+
``` ruby
|
103
|
+
activate :webp do |webp|
|
104
|
+
webp.allow_skip = false
|
105
|
+
end
|
106
|
+
```
|
94
107
|
|
95
108
|
## Configuring your site to provide WebP alternatives
|
96
109
|
|
@@ -112,3 +125,4 @@ Look for [this example how to do it in .htaccess][htaccess].
|
|
112
125
|
## Contributors
|
113
126
|
|
114
127
|
- [Johannes Schleifenbaum](https://github.com/jojosch)
|
128
|
+
- [Ryan Townsend](https://github.com/ryantownsend)
|
@@ -15,7 +15,9 @@ module Middleman
|
|
15
15
|
@original_size = 0
|
16
16
|
@converted_size = 0
|
17
17
|
convert_images(image_files) do |src, dst|
|
18
|
-
|
18
|
+
if !!@options.allow_skip && dst.size >= src.size
|
19
|
+
next reject_file(dst)
|
20
|
+
end
|
19
21
|
|
20
22
|
@original_size += src.size
|
21
23
|
@converted_size += dst.size
|
@@ -12,6 +12,7 @@ module Middleman
|
|
12
12
|
option(:ignore, [], 'Ignores files with matching paths')
|
13
13
|
option(:verbose, false, 'Display all external command which are executed '\
|
14
14
|
'to help debugging.')
|
15
|
+
option(:allow_skip, true, 'Skip saving .webp files which are larger than their source')
|
15
16
|
|
16
17
|
def initialize(app, options_hash = {}, &block)
|
17
18
|
super
|
@@ -3,7 +3,7 @@ require 'middleman-webp/pathname_matcher'
|
|
3
3
|
module Middleman
|
4
4
|
module WebP
|
5
5
|
class Options
|
6
|
-
attr_reader :ignore, :verbose, :append_extension
|
6
|
+
attr_reader :ignore, :verbose, :append_extension, :allow_skip
|
7
7
|
|
8
8
|
def initialize(options = {})
|
9
9
|
@ignore = options[:ignore] || []
|
@@ -20,6 +20,7 @@ module Middleman
|
|
20
20
|
@verbose = options[:verbose] || false
|
21
21
|
|
22
22
|
@append_extension = options[:append_extension] || false
|
23
|
+
@allow_skip = !(false == options[:allow_skip])
|
23
24
|
end
|
24
25
|
|
25
26
|
# Internal: Generate command line args for cwebp or gif2webp command
|
data/spec/unit/options_spec.rb
CHANGED
@@ -3,6 +3,18 @@ require 'pathname'
|
|
3
3
|
require_relative '../../lib/middleman-webp/options'
|
4
4
|
|
5
5
|
describe Middleman::WebP::Options do
|
6
|
+
describe '#allow_skip' do
|
7
|
+
it "should default to true" do
|
8
|
+
options = Middleman::WebP::Options.new
|
9
|
+
options.allow_skip.must_equal(true)
|
10
|
+
end
|
11
|
+
|
12
|
+
it "should allow setting to true" do
|
13
|
+
options = Middleman::WebP::Options.new(allow_skip: false)
|
14
|
+
options.allow_skip.must_equal(false)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
6
18
|
describe '#for' do
|
7
19
|
it 'returns cwebp args when given file matches option file pattern glob' do
|
8
20
|
path = Pathname.new('test_image.jpg')
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: middleman-webp
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Juhamatti Niemelä
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2015-04-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: middleman-core
|
@@ -120,7 +120,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
120
120
|
version: '0'
|
121
121
|
requirements: []
|
122
122
|
rubyforge_project:
|
123
|
-
rubygems_version: 2.
|
123
|
+
rubygems_version: 2.4.5
|
124
124
|
signing_key:
|
125
125
|
specification_version: 4
|
126
126
|
summary: WebP image conversion for Middleman
|