sprockets-image_compressor 0.2.2 → 0.2.3

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: b7aadb950895a7d44df279f0f3509bd26bab0a36
4
- data.tar.gz: 7a61daf7f0f622c67bffee7062cf98256e8074e5
3
+ metadata.gz: e2a326a020efcd3e6690d8ea8aa955eedbe6d335
4
+ data.tar.gz: 722575c0af1fed23263fdc86f381ec899508d18b
5
5
  SHA512:
6
- metadata.gz: 39478d5ec0f7ab524b3fb134bfe4195dee2ee84e747cad9f194d3a6a2087a4cc82e5982fb65e654d9489ab8997966a661b1eb2f4561bf1cec0a88986c5386e68
7
- data.tar.gz: e8cdc0042c6d0a360c607440c8a41d3b3d7e9d427e933e515058099532229e4dedb745e17629e588ac1be396a33357936af162a9f0a4ef76aaf3c11e2fd5b3c2
6
+ metadata.gz: 983994d84c2ba670d7290be7244ed236d714f9bd0e4d2f7df8ba8dae2201e70fccbbfe6244935fdae509f87a6dc3b461ccf47ca5eb21c051dd0eac5d68144736
7
+ data.tar.gz: e02729f65fdfc1ee12f523442140443b6543233c649a2caf4cf29d3034e59c1c1b5c4ebbe8ad67454f8c8680969b56cc4139680847553821388a9bdb977bea45
data/.gitignore CHANGED
@@ -2,5 +2,6 @@
2
2
  .ruby-version
3
3
  .ruby-gemset
4
4
  .rvmrc
5
+ .bundle
5
6
  Gemfile.lock
6
7
  pkg/*
@@ -1,3 +1,7 @@
1
+ 0.2.3 (04/10/2014)
2
+ -------------------------
3
+ * Bugfix: Return original file and warn if compression fails. Thanks, @tomchentw!
4
+
1
5
  0.2.2 (09/20/2013)
2
6
  -------------------------
3
7
 
@@ -1,3 +1,5 @@
1
+ require "tempfile"
2
+
1
3
  module Sprockets
2
4
  module ImageCompressor
3
5
  GEM_ROOT = File.expand_path File.join(File.dirname(__FILE__), "../../../")
@@ -14,8 +14,8 @@ module Sprockets
14
14
  out_file_path = in_file.path + ".optimized.png"
15
15
  in_file.write content
16
16
  in_file.close
17
+
17
18
  out = `#{binary_path} #{in_file.path} #{out_file_path} 2>&1`
18
- in_file.delete
19
19
 
20
20
  File.open out_file_path, "rb" do |out_file|
21
21
  compressed_png_data = out_file.read
@@ -23,6 +23,12 @@ module Sprockets
23
23
  File.unlink out_file_path
24
24
  end
25
25
  compressed_png_data
26
+
27
+ rescue Errno::ENOENT => e
28
+ # error during compression so out_file not found
29
+ # return original content as a fallback
30
+ warn "sprockets-image_compressor: PNG compression failed... returning original."
31
+ content
26
32
  end
27
33
  end
28
34
  end
@@ -1,5 +1,5 @@
1
1
  module Sprockets
2
2
  module Imagecompressor
3
- VERSION = "0.2.2"
3
+ VERSION = "0.2.3"
4
4
  end
5
5
  end
@@ -37,4 +37,11 @@ describe Sprockets::ImageCompressor::PngCompressor do
37
37
  end
38
38
  end
39
39
  end
40
+
41
+ describe "#compress" do
42
+ it "returns uncompressable content as-is with a warning" do
43
+ compressor.should_receive(:warn)
44
+ compressor.compress("asdf").should == "asdf"
45
+ end
46
+ end
40
47
  end
@@ -23,4 +23,5 @@ Gem::Specification.new do |s|
23
23
 
24
24
  s.add_development_dependency "rspec"
25
25
  s.add_development_dependency "rack-test"
26
+ s.add_development_dependency "byebug"
26
27
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sprockets-image_compressor
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Micah Geisel
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-09-20 00:00:00.000000000 Z
11
+ date: 2014-04-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sprockets
@@ -52,6 +52,20 @@ dependencies:
52
52
  - - '>='
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: byebug
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - '>='
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
55
69
  description: Losslessly compress images in the Rails asset pipeline
56
70
  email:
57
71
  - micah@botandrose.com
@@ -109,7 +123,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
109
123
  version: '0'
110
124
  requirements: []
111
125
  rubyforge_project: sprockets-image_compressor
112
- rubygems_version: 2.0.3
126
+ rubygems_version: 2.2.0
113
127
  signing_key:
114
128
  specification_version: 4
115
129
  summary: Losslessly compress images in the Rails asset pipeline