smusher 0.4.6 → 0.4.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/Gemfile ADDED
@@ -0,0 +1,11 @@
1
+ source :rubygems
2
+
3
+ gem 'rake'
4
+ gem 'json'
5
+ gem 'httpclient'
6
+
7
+ group :dev do
8
+ gem 'rake'
9
+ gem 'rspec', '~>2'
10
+ gem 'jeweler'
11
+ end
@@ -0,0 +1,30 @@
1
+ GEM
2
+ remote: http://rubygems.org/
3
+ specs:
4
+ diff-lcs (1.1.2)
5
+ git (1.2.5)
6
+ httpclient (2.1.5.2)
7
+ jeweler (1.5.2)
8
+ bundler (~> 1.0.0)
9
+ git (>= 1.2.5)
10
+ rake
11
+ json (1.4.6)
12
+ rake (0.8.7)
13
+ rspec (2.4.0)
14
+ rspec-core (~> 2.4.0)
15
+ rspec-expectations (~> 2.4.0)
16
+ rspec-mocks (~> 2.4.0)
17
+ rspec-core (2.4.0)
18
+ rspec-expectations (2.4.0)
19
+ diff-lcs (~> 1.1.2)
20
+ rspec-mocks (2.4.0)
21
+
22
+ PLATFORMS
23
+ ruby
24
+
25
+ DEPENDENCIES
26
+ httpclient
27
+ jeweler
28
+ json
29
+ rake
30
+ rspec (~> 2)
data/Rakefile CHANGED
@@ -1,20 +1,18 @@
1
- task :default => :spec
2
- require 'spec/rake/spectask'
3
- Spec::Rake::SpecTask.new {|t| t.spec_opts = ['--color']}
1
+ task :default do
2
+ sh "rspec spec/"
3
+ end
4
4
 
5
5
  begin
6
6
  require 'jeweler'
7
- project_name = 'smusher'
8
7
  Jeweler::Tasks.new do |gem|
9
- gem.name = project_name
8
+ gem.name = 'smusher'
10
9
  gem.summary = "Automatic Lossless Reduction Of All Your Images"
11
- gem.email = "grosser.michael@gmail.com"
12
- gem.homepage = "http://github.com/grosser/#{project_name}"
10
+ gem.email = "michael@grosser.it"
11
+ gem.homepage = "http://github.com/grosser/#{gem.name}"
13
12
  gem.authors = ["Michael Grosser"]
14
- %w[rake json httpclient].each{|d| gem.add_dependency d}
15
13
  end
16
14
 
17
15
  Jeweler::GemcutterTasks.new
18
16
  rescue LoadError
19
17
  puts "Jeweler, or one of its dependencies, is not available. Install it with: sudo gem install technicalpickles-jeweler -s http://gems.github.com"
20
- end
18
+ end
data/Readme.md CHANGED
@@ -1,7 +1,7 @@
1
1
  *LOSSLESS* image size reduction for jpg, png and gif in the cloud
2
2
 
3
3
  - no image libraries needed, everything done in the interwebs
4
- - less size (up 97% saving) = faster downloads = less bandwidth + happy users
4
+ - less size (up 97% saving) = faster downloads = less bandwidth + happy users
5
5
 
6
6
  Install
7
7
  =======
@@ -58,11 +58,11 @@ reduce images and minify css + js -> try [reduce](http://github.com/grosser/redu
58
58
 
59
59
  Authors
60
60
  ======
61
- ###Contributors
61
+ ### [Contributors](http://github.com/grosser/smusher/contributors)
62
62
  - [ahaller](http://ahax.de/)
63
63
  - [retr0h](http://geminstallthat.wordpress.com/)
64
64
  - [Nate Pickens](http://github.com/npickens)
65
65
 
66
- [Michael Grosser](http://pragmatig.wordpress.com)
67
- grosser.michael@gmail.com
66
+ [Michael Grosser](http://grosser.it)<br/>
67
+ michael@grosser.it<br/>
68
68
  Hereby placed under public domain, do what you want, just do not hold me accountable...
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.4.6
1
+ 0.4.7
@@ -1,6 +1,8 @@
1
1
  #!/usr/bin/env ruby
2
2
  require 'rubygems'
3
3
  require 'optparse'
4
+
5
+ $LOAD_PATH << File.join(File.dirname(__FILE__), '..', 'lib')
4
6
  require 'smusher'
5
7
 
6
8
  options = {}
@@ -25,7 +25,7 @@ module Smusher
25
25
  check_options(options)
26
26
  puts "THIS FILE IS EMPTY!!! #{file}" and return if size(file).zero?
27
27
 
28
- with_logging(file,options[:quiet]) do
28
+ with_logging(file, options[:quiet]) do
29
29
  write_optimized_data(file, service)
30
30
  end
31
31
  end
@@ -43,7 +43,7 @@ module Smusher
43
43
 
44
44
  def check_options(options)
45
45
  known_options = [:convert_gifs, :quiet, :service]
46
- if options.detect{|k,v| not known_options.include?(k)}
46
+ if options.detect{|k,_| not known_options.include?(k)}
47
47
  raise "Known options: #{known_options*' '}"
48
48
  end
49
49
  end
@@ -55,22 +55,26 @@ module Smusher
55
55
  raise "Error: empty file downloaded" if optimized.size < MINIMUM_IMAGE_SIZE
56
56
  raise "cannot be optimized further" if size(file) == optimized.size
57
57
 
58
- File.open(file,'wb') {|f| f.write optimized}
58
+ File.open(file,'wb') {|f| f.write optimized }
59
59
 
60
60
  if service.converts_gif_to_png? && File.extname(file) == ".gif" && optimized[0..2] != "GIF"
61
- `mv #{file} #{file.sub(/.gif$/, '.png')}`
61
+ result_file = file.sub(/\.gif$/, '.png')
62
+ `mv #{file} #{result_file}`
63
+ result_file
64
+ else
65
+ file
62
66
  end
63
67
  end
64
68
 
65
69
  def sanitize_folder(folder)
66
- folder.sub(%r[/$],'')#remove tailing slash
70
+ folder.sub(%r[/$],'') # remove tailing slash
67
71
  end
68
72
 
69
- def images_in_folder(folder,with_gifs=false)
73
+ def images_in_folder(folder, with_gifs=false)
70
74
  folder = sanitize_folder(folder)
71
75
  images = %w[png jpg jpeg JPG]
72
76
  images << 'gif' if with_gifs
73
- images.map! {|ext| "#{folder}/**/*.#{ext}"}
77
+ images.map! {|ext| "#{folder}/**/*.#{ext}" }
74
78
  FileList[*images]
75
79
  end
76
80
 
@@ -78,17 +82,27 @@ module Smusher
78
82
  File.exist?(file) ? File.size(file) : 0
79
83
  end
80
84
 
81
- def with_logging(file,quiet)
82
- puts "smushing #{file}" unless quiet
83
-
84
- before = size(file)
85
- begin; yield; rescue; puts $! unless quiet; end
86
- after = size(file)
85
+ def with_logging(file, quiet)
86
+ if quiet
87
+ yield rescue nil
88
+ else
89
+ puts "smushing #{file}"
90
+
91
+ before = size(file)
92
+
93
+ # notify user about changed file
94
+ begin
95
+ result_file = yield
96
+ puts "--> #{result_file}" if file != result_file
97
+ file = result_file
98
+ rescue
99
+ puts $!
100
+ end
87
101
 
88
- unless quiet
102
+ after = size(file)
89
103
  result = "#{(100*after)/before}%"
90
104
  puts "#{before} -> #{after}".ljust(40) + " = #{result}"
91
105
  puts ''
92
106
  end
93
107
  end
94
- end
108
+ end
@@ -1,63 +1,62 @@
1
1
  # Generated by jeweler
2
2
  # DO NOT EDIT THIS FILE DIRECTLY
3
- # Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
4
  # -*- encoding: utf-8 -*-
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{smusher}
8
- s.version = "0.4.6"
8
+ s.version = "0.4.7"
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-09-10}
12
+ s.date = %q{2011-03-15}
13
13
  s.default_executable = %q{smusher}
14
- s.email = %q{grosser.michael@gmail.com}
14
+ s.email = %q{michael@grosser.it}
15
15
  s.executables = ["smusher"]
16
16
  s.files = [
17
- ".gitignore",
18
- "Rakefile",
19
- "Readme.md",
20
- "VERSION",
21
- "bin/smusher",
22
- "lib/smusher.rb",
23
- "lib/smusher/puny_png.rb",
24
- "lib/smusher/smush_it.rb",
25
- "smusher.gemspec",
26
- "spec/empty/.gitignore",
27
- "spec/images/ad.gif",
28
- "spec/images/add.png",
29
- "spec/images/drink_empty.png",
30
- "spec/images/logo.gif",
31
- "spec/images/people.jpg",
32
- "spec/images/water.JPG",
33
- "spec/images/woman.jpeg",
34
- "spec/out/ad.gif",
35
- "spec/out/people.jpg",
36
- "spec/reduced/add.png",
37
- "spec/reduced/add_puny.png",
38
- "spec/reduced/fam.png",
39
- "spec/smusher/puny_png_spec.rb",
40
- "spec/smusher/smush_it_spec.rb",
41
- "spec/smusher_spec.rb",
42
- "spec/spec_helper.rb"
17
+ "Gemfile",
18
+ "Gemfile.lock",
19
+ "Rakefile",
20
+ "Readme.md",
21
+ "VERSION",
22
+ "bin/smusher",
23
+ "lib/smusher.rb",
24
+ "lib/smusher/puny_png.rb",
25
+ "lib/smusher/smush_it.rb",
26
+ "smusher.gemspec",
27
+ "spec/empty/.gitignore",
28
+ "spec/images/ad.gif",
29
+ "spec/images/add.png",
30
+ "spec/images/drink_empty.png",
31
+ "spec/images/logo.gif",
32
+ "spec/images/people.jpg",
33
+ "spec/images/water.JPG",
34
+ "spec/images/woman.jpeg",
35
+ "spec/out/ad.gif",
36
+ "spec/out/people.jpg",
37
+ "spec/reduced/add.png",
38
+ "spec/reduced/add_puny.png",
39
+ "spec/reduced/fam.png",
40
+ "spec/smusher/puny_png_spec.rb",
41
+ "spec/smusher/smush_it_spec.rb",
42
+ "spec/smusher_spec.rb",
43
+ "spec/spec_helper.rb"
43
44
  ]
44
45
  s.homepage = %q{http://github.com/grosser/smusher}
45
- s.rdoc_options = ["--charset=UTF-8"]
46
46
  s.require_paths = ["lib"]
47
- s.rubygems_version = %q{1.3.6}
47
+ s.rubygems_version = %q{1.4.2}
48
48
  s.summary = %q{Automatic Lossless Reduction Of All Your Images}
49
49
  s.test_files = [
50
50
  "spec/smusher/puny_png_spec.rb",
51
- "spec/smusher/smush_it_spec.rb",
52
- "spec/smusher_spec.rb",
53
- "spec/spec_helper.rb"
51
+ "spec/smusher/smush_it_spec.rb",
52
+ "spec/smusher_spec.rb",
53
+ "spec/spec_helper.rb"
54
54
  ]
55
55
 
56
56
  if s.respond_to? :specification_version then
57
- current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
58
57
  s.specification_version = 3
59
58
 
60
- if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
59
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
61
60
  s.add_runtime_dependency(%q<rake>, [">= 0"])
62
61
  s.add_runtime_dependency(%q<json>, [">= 0"])
63
62
  s.add_runtime_dependency(%q<httpclient>, [">= 0"])
@@ -170,7 +170,7 @@ describe :smusher do
170
170
  describe :logging do
171
171
  it "yields" do
172
172
  val = 0
173
- Smusher.send(:with_logging,@file,false) {val = 1}
173
+ Smusher.send(:with_logging, @file, false) {val = 1; @file}
174
174
  val.should == 1
175
175
  end
176
176
  end
@@ -178,4 +178,4 @@ describe :smusher do
178
178
  it "has a VERSION" do
179
179
  Smusher::VERSION.should =~ /^\d+\.\d+\.\d+$/
180
180
  end
181
- end
181
+ end
metadata CHANGED
@@ -1,12 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: smusher
3
3
  version: !ruby/object:Gem::Version
4
- prerelease: false
4
+ hash: 1
5
+ prerelease:
5
6
  segments:
6
7
  - 0
7
8
  - 4
8
- - 6
9
- version: 0.4.6
9
+ - 7
10
+ version: 0.4.7
10
11
  platform: ruby
11
12
  authors:
12
13
  - Michael Grosser
@@ -14,47 +15,53 @@ autorequire:
14
15
  bindir: bin
15
16
  cert_chain: []
16
17
 
17
- date: 2010-09-10 00:00:00 +02:00
18
+ date: 2011-03-15 00:00:00 +01:00
18
19
  default_executable: smusher
19
20
  dependencies:
20
21
  - !ruby/object:Gem::Dependency
21
- name: rake
22
- prerelease: false
23
22
  requirement: &id001 !ruby/object:Gem::Requirement
23
+ none: false
24
24
  requirements:
25
25
  - - ">="
26
26
  - !ruby/object:Gem::Version
27
+ hash: 3
27
28
  segments:
28
29
  - 0
29
30
  version: "0"
30
- type: :runtime
31
+ prerelease: false
31
32
  version_requirements: *id001
33
+ type: :runtime
34
+ name: rake
32
35
  - !ruby/object:Gem::Dependency
33
- name: json
34
- prerelease: false
35
36
  requirement: &id002 !ruby/object:Gem::Requirement
37
+ none: false
36
38
  requirements:
37
39
  - - ">="
38
40
  - !ruby/object:Gem::Version
41
+ hash: 3
39
42
  segments:
40
43
  - 0
41
44
  version: "0"
42
- type: :runtime
45
+ prerelease: false
43
46
  version_requirements: *id002
47
+ type: :runtime
48
+ name: json
44
49
  - !ruby/object:Gem::Dependency
45
- name: httpclient
46
- prerelease: false
47
50
  requirement: &id003 !ruby/object:Gem::Requirement
51
+ none: false
48
52
  requirements:
49
53
  - - ">="
50
54
  - !ruby/object:Gem::Version
55
+ hash: 3
51
56
  segments:
52
57
  - 0
53
58
  version: "0"
54
- type: :runtime
59
+ prerelease: false
55
60
  version_requirements: *id003
61
+ type: :runtime
62
+ name: httpclient
56
63
  description:
57
- email: grosser.michael@gmail.com
64
+ email: michael@grosser.it
58
65
  executables:
59
66
  - smusher
60
67
  extensions: []
@@ -62,7 +69,8 @@ extensions: []
62
69
  extra_rdoc_files: []
63
70
 
64
71
  files:
65
- - .gitignore
72
+ - Gemfile
73
+ - Gemfile.lock
66
74
  - Rakefile
67
75
  - Readme.md
68
76
  - VERSION
@@ -93,28 +101,32 @@ homepage: http://github.com/grosser/smusher
93
101
  licenses: []
94
102
 
95
103
  post_install_message:
96
- rdoc_options:
97
- - --charset=UTF-8
104
+ rdoc_options: []
105
+
98
106
  require_paths:
99
107
  - lib
100
108
  required_ruby_version: !ruby/object:Gem::Requirement
109
+ none: false
101
110
  requirements:
102
111
  - - ">="
103
112
  - !ruby/object:Gem::Version
113
+ hash: 3
104
114
  segments:
105
115
  - 0
106
116
  version: "0"
107
117
  required_rubygems_version: !ruby/object:Gem::Requirement
118
+ none: false
108
119
  requirements:
109
120
  - - ">="
110
121
  - !ruby/object:Gem::Version
122
+ hash: 3
111
123
  segments:
112
124
  - 0
113
125
  version: "0"
114
126
  requirements: []
115
127
 
116
128
  rubyforge_project:
117
- rubygems_version: 1.3.6
129
+ rubygems_version: 1.4.2
118
130
  signing_key:
119
131
  specification_version: 3
120
132
  summary: Automatic Lossless Reduction Of All Your Images
data/.gitignore DELETED
@@ -1,2 +0,0 @@
1
- Manifest
2
- pkg