sprockets-webp 0.3.1 → 0.3.2

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: 90debf87e20a927b7b7d591e5b657780905d445b
4
- data.tar.gz: e51dd207b2f307b2d08d90a5f76090c72fdc1a6f
3
+ metadata.gz: 51ecae2261a9bde5d73f38b1425929dc7a5aa50a
4
+ data.tar.gz: 8857ccb03ec2a54b7036ffdad5d8f6c9dcf34293
5
5
  SHA512:
6
- metadata.gz: 8f42a8d8456773e035a6652599c24bac1a67cb64b8b5f6a28d0f4a3a724ea5efbd81e24cf81654110800c664d9070ef93620eb5c34c937b6eff3ff7a4e4a10d5
7
- data.tar.gz: d99bc35fd38b099fe23e9c4c341a042042881d076342598e04d51ffd64e6059d403193adb2d57ebf98c194fab1560a6b306b4f30ca31135df5560a2b305edcf3
6
+ metadata.gz: f9cf48a3ac796ae6de86cd0f7697eb866c99be7ae00133dfedf87766dd6ed39e7d2b2952c9f89f4c628fa688680658f9929b3616eeb1d4efac32e6c6ae8fcd68
7
+ data.tar.gz: 491d6cd24cf9db6f531d09acf5d6dc3bdf58eff9474c268940027f764c0171732f164172554116b023ceca183ecc68c454dd8c4496e87b2fac17fc112be424eb
data/README.md CHANGED
@@ -53,7 +53,7 @@ Minimal required version of Rails 3 is ```3.2.9```, because of Sprockets ```~> 2
53
53
 
54
54
  You can configure encode options for webp by using `encode_options` (in example default options):
55
55
 
56
- Sprockets::WebP.encode_options = { quality: 100, lossless: 1, method: 5, alpha_filtering: 1, alpha_compression: 0, alpha_quality: 100 }
56
+ Sprockets::WebP.encode_options = { quality: 100, lossless: 1, method: 6, alpha_filtering: 2, 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
 
@@ -8,13 +8,13 @@ module Sprockets
8
8
  module WebP
9
9
  # configure web encode options
10
10
  #
11
- # Sprockets::WebP.encode_options = { quality: 90, lossless: 1, method: 5, alpha_filtering: 2 }
11
+ # Sprockets::WebP.encode_options = { quality: 100, lossless: 1, method: 6, alpha_filtering: 2, alpha_compression: 0, alpha_quality: 100 }
12
12
  #
13
13
  class << self
14
14
  attr_writer :encode_options
15
15
 
16
16
  def encode_options
17
- @encode_options ||= { quality: 100, lossless: 1, method: 5, alpha_filtering: 1, alpha_compression: 0, alpha_quality: 100 }
17
+ @encode_options ||= { quality: 100, lossless: 1, method: 6, alpha_filtering: 2, alpha_compression: 0, alpha_quality: 100 }
18
18
  end
19
19
  end
20
20
  end
@@ -18,10 +18,7 @@ module Sprockets
18
18
  config = app.config.assets
19
19
 
20
20
  # If Application Assets Digests enabled - Add Digest
21
- digest = config.digest ? "-#{context.environment.digest.update(data).hexdigest}" : nil
22
- file_name = context.logical_path # Original File name w/o extension
23
- file_ext = context.pathname.extname # Original File extension
24
- webp_file = "#{file_name}#{digest}#{file_ext}.webp" # WebP File fullname
21
+ webp_file = webp_file_by_config(config, data)
25
22
 
26
23
  # WebP File Pathname
27
24
  webp_path = Pathname.new File.join(app.root, 'public', config.prefix, webp_file)
@@ -37,6 +34,13 @@ module Sprockets
37
34
 
38
35
  private
39
36
 
37
+ def webp_file_by_config(config, data)
38
+ digest = config.digest ? "-#{context.environment.digest.update(data).hexdigest}" : nil
39
+ file_name = context.logical_path # Original File name w/o extension
40
+ file_ext = context.pathname.extname # Original File extension
41
+ "#{file_name}#{digest}#{file_ext}.webp" # WebP File fullname
42
+ end
43
+
40
44
  def encode_to_webp(data, webp_path, webp_file = "")
41
45
  # Create Temp File with Original File binary data
42
46
  Tempfile.open('webp') do |file|
@@ -47,6 +51,7 @@ module Sprockets
47
51
  # Encode Original File Temp copy to WebP File Pathname
48
52
  begin
49
53
  ::WebP.encode(file.path, webp_path, Sprockets::WebP.encode_options)
54
+ logger.info "Webp converted image #{webp_path}"
50
55
  rescue => e
51
56
  logger.warn "Webp convertion error of image #{webp_file}. Error info: #{e.message}"
52
57
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Sprockets
4
4
  module WebP
5
- VERSION = '0.3.1'
5
+ VERSION = '0.3.2'
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.1
4
+ version: 0.3.2
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-04-02 00:00:00.000000000 Z
11
+ date: 2014-05-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sprockets
@@ -103,7 +103,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
103
103
  version: '0'
104
104
  requirements: []
105
105
  rubyforge_project:
106
- rubygems_version: 2.2.0
106
+ rubygems_version: 2.2.2
107
107
  signing_key:
108
108
  specification_version: 4
109
109
  summary: Sprockets converter of PNG and JPEG assets to WebP