sprockets-webp 0.3.0 → 0.3.1

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: fb75dccba1ce27877e4f94b528e42d5d112127f3
4
- data.tar.gz: 7feb113e4861e0b0af0aa8916c937654ad12fc1d
3
+ metadata.gz: 90debf87e20a927b7b7d591e5b657780905d445b
4
+ data.tar.gz: e51dd207b2f307b2d08d90a5f76090c72fdc1a6f
5
5
  SHA512:
6
- metadata.gz: b7734379b8f8f239302d684f420f2456a5948606421540ead672c409a5a135b1256a373d4b51d2b58d7f2b6752e613bf0bc6f627f11e816bfd4ee5a7200e7291
7
- data.tar.gz: 97231c8f497b8a496292b8285778c1e2d020974c8ba300614a8e5beae2916c555d1b42215540a685aa041639392a3056f12ecbff8619d3bfe0468bd3e98cf8ff
6
+ metadata.gz: 8f42a8d8456773e035a6652599c24bac1a67cb64b8b5f6a28d0f4a3a724ea5efbd81e24cf81654110800c664d9070ef93620eb5c34c937b6eff3ff7a4e4a10d5
7
+ data.tar.gz: d99bc35fd38b099fe23e9c4c341a042042881d076342598e04d51ffd64e6059d403193adb2d57ebf98c194fab1560a6b306b4f30ca31135df5560a2b305edcf3
data/README.md CHANGED
@@ -51,12 +51,47 @@ Minimal required version of Rails 3 is ```3.2.9```, because of Sprockets ```~> 2
51
51
 
52
52
  ## Configuration
53
53
 
54
- You can configure encode options for webp by using encode_options:
54
+ You can configure encode options for webp by using `encode_options` (in example default options):
55
55
 
56
- Sprockets::WebP.encode_options = { quality: 90, lossless: 1, method: 5, alpha_filtering: 2 }
56
+ Sprockets::WebP.encode_options = { quality: 100, lossless: 1, method: 5, alpha_filtering: 1, alpha_compression: 0, alpha_quality: 100 }
57
57
 
58
58
  More options you can find in [web-ffi readme](https://github.com/le0pard/webp-ffi#encode-webp-image).
59
59
 
60
+ ## Capistrano deploy
61
+
62
+ If you deploy your rails app by capistrano gem, you should update mtime for your webp images, because it will not present in manifest.json and will be cleanup automatically. To solve this problem you can use this capistrano task:
63
+
64
+ ```ruby
65
+ after "deploy:update", "deploy:webp:touch"
66
+
67
+ load do
68
+
69
+ namespace :deploy do
70
+
71
+ namespace :webp do
72
+
73
+ desc <<-DESC
74
+ [internal] Updates mtime for webp images
75
+ DESC
76
+ task :touch, :roles => :app, :except => { :no_release => true } do
77
+ run <<-CMD.compact
78
+ cd -- #{shared_path.shellescape}/#{shared_assets_prefix}/ &&
79
+ for asset in $(
80
+ find . -regex ".*\.webp$" -type f | LC_COLLATE=C sort
81
+ ); do
82
+ echo "Update webp asset: $asset";
83
+ touch -c -- "$asset";
84
+ done
85
+ CMD
86
+ end
87
+
88
+ end
89
+
90
+ end
91
+
92
+ end
93
+ ```
94
+
60
95
  ## Contributing
61
96
 
62
97
  1. Fork it
@@ -2,7 +2,7 @@
2
2
 
3
3
  require 'sprockets/webp/version'
4
4
  require 'sprockets/webp/converter'
5
- require 'sprockets/webp/railtie' if defined?(Rails::Engine)
5
+ require 'sprockets/webp/railtie' if defined?(Rails)
6
6
 
7
7
  module Sprockets
8
8
  module WebP
@@ -14,7 +14,7 @@ module Sprockets
14
14
  attr_writer :encode_options
15
15
 
16
16
  def encode_options
17
- @encode_options ||= { quality: 90, lossless: 1, method: 5, alpha_filtering: 2 }
17
+ @encode_options ||= { quality: 100, lossless: 1, method: 5, alpha_filtering: 1, alpha_compression: 0, alpha_quality: 100 }
18
18
  end
19
19
  end
20
20
  end
@@ -2,12 +2,14 @@
2
2
 
3
3
  module Sprockets
4
4
  module WebP
5
- class Railtie < ::Rails::Engine
5
+ class Railtie < (::Rails::VERSION::MAJOR < 4 ? ::Rails::Engine : ::Rails::Railtie)
6
6
  initializer :webp do |app|
7
+ app.assets.register_mime_type 'image/jpeg', '.jpg'
7
8
  app.assets.register_postprocessor 'image/jpeg', :jpeg_webp do |context, data|
8
9
  Converter.process(app, context, data)
9
10
  end
10
11
 
12
+ app.assets.register_mime_type 'image/png', '.png'
11
13
  app.assets.register_postprocessor 'image/png', :png_webp do |context, data|
12
14
  Converter.process(app, context, data)
13
15
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Sprockets
4
4
  module WebP
5
- VERSION = '0.3.0'
5
+ VERSION = '0.3.1'
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sprockets-webp
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Max Riveiro
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-01-20 00:00:00.000000000 Z
11
+ date: 2014-04-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sprockets