middleman-webp 0.2.6 → 0.2.7

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8edf6cefbf5002fdad1decc34a8478c36b84046f
4
- data.tar.gz: 34d574375a04fcda5e7aa035288a9039aa0c414b
3
+ metadata.gz: 2a85d2700cf9364e534f055579f87d593237b34a
4
+ data.tar.gz: 320a9b9b2b14031104370981d41445e8a879c336
5
5
  SHA512:
6
- metadata.gz: 9b78739e99e432f9d6fd2c01bf9d3db6bbe52534147d6511b109eba7eb4813386160c779d37e73eaa06d598c6a4add837916d7bde870720e1515ca580cdb3c88
7
- data.tar.gz: 7a43165a4724e126b44b14e8937f1c2ac247d003e36d7040a1a4c1c5342f0fb8088db5015f1b61b77066b6b9e4afc498009e9f344744d40a4dc42585dd53a20e
6
+ metadata.gz: adccb7efe24726cbf0eec77d8c59ffec2304758ef36b3a79b0dede10312a6f28a81a20af58b7ee2161809c1193cc2e88e7015b3c8a15ff9a41c12ac39546b1ca
7
+ data.tar.gz: 46470f901990a55d8e69f9b6403c9ee9158c7c23de98660f626c25a7b01fb48529c6fa229c4d095fe096fa398224380c3b1d6f0814760db1681d97f776089aa6
data/.travis.yml CHANGED
@@ -2,7 +2,8 @@ language: ruby
2
2
  rvm:
3
3
  - 1.9.3
4
4
  - 2.0.0
5
- - 2.1.0
5
+ - 2.1.5
6
+ - 2.2.1
6
7
  script: bundle exec rake test
7
8
  before_install:
8
9
  - sudo apt-get update -qq
data/Gemfile CHANGED
@@ -4,4 +4,4 @@ source 'https://rubygems.org'
4
4
  gemspec
5
5
 
6
6
  gem 'coveralls', require: false, group: :test
7
- gem 'simplecov', '~> 0.7.1', require: false, group: :test
7
+ gem 'simplecov', '~> 0.9.1', require: false, group: :test
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
- next reject_file(dst) if dst.size >= src.size
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
@@ -1,5 +1,5 @@
1
1
  module Middleman
2
2
  module Webp
3
- VERSION = '0.2.6'
3
+ VERSION = '0.2.7'
4
4
  end
5
5
  end
@@ -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.6
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: 2014-09-07 00:00:00.000000000 Z
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.2.2
123
+ rubygems_version: 2.4.5
124
124
  signing_key:
125
125
  specification_version: 4
126
126
  summary: WebP image conversion for Middleman