smusher 0.4.5 → 0.4.6

Sign up to get free protection for your applications and to get access to all the features.
@@ -61,7 +61,8 @@ Authors
61
61
  ###Contributors
62
62
  - [ahaller](http://ahax.de/)
63
63
  - [retr0h](http://geminstallthat.wordpress.com/)
64
+ - [Nate Pickens](http://github.com/npickens)
64
65
 
65
66
  [Michael Grosser](http://pragmatig.wordpress.com)
66
67
  grosser.michael@gmail.com
67
- Hereby placed under public domain, do what you want, just do not hold me accountable...
68
+ Hereby placed under public domain, do what you want, just do not hold me accountable...
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.4.5
1
+ 0.4.6
@@ -24,16 +24,9 @@ module Smusher
24
24
  Array(files).each do |file|
25
25
  check_options(options)
26
26
  puts "THIS FILE IS EMPTY!!! #{file}" and return if size(file).zero?
27
- success = false
28
27
 
29
28
  with_logging(file,options[:quiet]) do
30
29
  write_optimized_data(file, service)
31
- success = true
32
- end
33
-
34
- if success and service.converts_gif_to_png?
35
- gif = /\.gif$/
36
- `mv #{file} #{file.sub(gif,'.png')}` if file =~ gif
37
30
  end
38
31
  end
39
32
  end
@@ -62,7 +55,11 @@ module Smusher
62
55
  raise "Error: empty file downloaded" if optimized.size < MINIMUM_IMAGE_SIZE
63
56
  raise "cannot be optimized further" if size(file) == optimized.size
64
57
 
65
- File.open(file,'w') {|f| f.write optimized}
58
+ File.open(file,'wb') {|f| f.write optimized}
59
+
60
+ if service.converts_gif_to_png? && File.extname(file) == ".gif" && optimized[0..2] != "GIF"
61
+ `mv #{file} #{file.sub(/.gif$/, '.png')}`
62
+ end
66
63
  end
67
64
 
68
65
  def sanitize_folder(folder)
@@ -5,21 +5,18 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{smusher}
8
- s.version = "0.4.5"
8
+ s.version = "0.4.6"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Michael Grosser"]
12
- s.date = %q{2010-08-20}
12
+ s.date = %q{2010-09-10}
13
13
  s.default_executable = %q{smusher}
14
14
  s.email = %q{grosser.michael@gmail.com}
15
15
  s.executables = ["smusher"]
16
- s.extra_rdoc_files = [
17
- "README.markdown"
18
- ]
19
16
  s.files = [
20
17
  ".gitignore",
21
- "README.markdown",
22
18
  "Rakefile",
19
+ "Readme.md",
23
20
  "VERSION",
24
21
  "bin/smusher",
25
22
  "lib/smusher.rb",
@@ -1,10 +1,10 @@
1
- require 'spec/spec_helper'
1
+ require 'spec_helper'
2
2
 
3
3
  describe Smusher::PunyPng do
4
4
  describe :optimized_image_data_for do
5
5
  it "loads the reduced image" do
6
6
  original = File.join(ROOT,'images','add.png')
7
- reduced = File.read(File.join(ROOT, 'reduced', 'add_puny.png'))
7
+ reduced = File.open(File.join(ROOT, 'reduced', 'add_puny.png'), 'rb').read
8
8
  received = Smusher::PunyPng.optimized_image_data_for(original)
9
9
  received.should == reduced
10
10
  end
@@ -1,10 +1,10 @@
1
- require 'spec/spec_helper'
1
+ require 'spec_helper'
2
2
 
3
3
  describe Smusher::SmushIt do
4
4
  describe :optimized_image_data_for do
5
5
  it "loads the reduced image" do
6
6
  original = File.join(ROOT,'images','add.png')
7
- reduced = File.open(File.join(ROOT,'reduced','add.png')).read
7
+ reduced = File.open(File.join(ROOT,'reduced','add.png'), 'rb').read
8
8
  received = Smusher::SmushIt.optimized_image_data_for(original)
9
9
  received.should == reduced
10
10
  end
@@ -1,4 +1,4 @@
1
- require 'spec/spec_helper'
1
+ require 'spec_helper'
2
2
 
3
3
  describe :smusher do
4
4
  def copy(image_name)
@@ -32,7 +32,7 @@ describe :smusher do
32
32
  file = File.join(@out, 'add.png')
33
33
  Smusher.optimize_image file
34
34
  # pure File.read() will omit trailing \n
35
- File.readlines(file).last.split('').last.should_not == "\n"
35
+ File.readlines(file).last[-1].should_not == "\n"
36
36
  end
37
37
 
38
38
  it "can be called with an array of files" do
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 4
8
- - 5
9
- version: 0.4.5
8
+ - 6
9
+ version: 0.4.6
10
10
  platform: ruby
11
11
  authors:
12
12
  - Michael Grosser
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-08-20 00:00:00 +02:00
17
+ date: 2010-09-10 00:00:00 +02:00
18
18
  default_executable: smusher
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
@@ -59,12 +59,12 @@ executables:
59
59
  - smusher
60
60
  extensions: []
61
61
 
62
- extra_rdoc_files:
63
- - README.markdown
62
+ extra_rdoc_files: []
63
+
64
64
  files:
65
65
  - .gitignore
66
- - README.markdown
67
66
  - Rakefile
67
+ - Readme.md
68
68
  - VERSION
69
69
  - bin/smusher
70
70
  - lib/smusher.rb