smusher 0.4.2 → 0.4.4
Sign up to get free protection for your applications and to get access to all the features.
- data/README.markdown +8 -0
- data/VERSION +1 -1
- data/lib/smusher.rb +1 -1
- data/lib/smusher/puny_png.rb +17 -2
- data/smusher.gemspec +3 -3
- data/spec/spec_helper.rb +3 -2
- metadata +30 -17
data/README.markdown
CHANGED
@@ -36,6 +36,13 @@ Example
|
|
36
36
|
reverted!
|
37
37
|
...
|
38
38
|
|
39
|
+
### PunyPng - usage limit
|
40
|
+
The default `Smusher::PunyPng.api_key` is used by all users and
|
41
|
+
could already be full when you try to smush some images.
|
42
|
+
|
43
|
+
Create a .puny_png_api_key in your home directory with your own
|
44
|
+
api key from [PunyPng](http://www.gracepointafterfive.com/punypng).
|
45
|
+
|
39
46
|
Protection
|
40
47
|
==========
|
41
48
|
Any image that returns a failure code, is larger than before,
|
@@ -52,6 +59,7 @@ reduce images and minify css + js -> try [reduce](http://github.com/grosser/redu
|
|
52
59
|
Authors
|
53
60
|
======
|
54
61
|
###Contributors
|
62
|
+
- [ahaller](http://ahax.de/)
|
55
63
|
- [retr0h](http://geminstallthat.wordpress.com/)
|
56
64
|
|
57
65
|
[Michael Grosser](http://pragmatig.wordpress.com)
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.4.
|
1
|
+
0.4.4
|
data/lib/smusher.rb
CHANGED
data/lib/smusher/puny_png.rb
CHANGED
@@ -1,17 +1,32 @@
|
|
1
1
|
module Smusher
|
2
2
|
class PunyPng
|
3
|
+
DEFAULT_API_KEY = '97b8b70fc59768979e2a0bdaf19df4dfa5536ed4'
|
4
|
+
|
5
|
+
@@api_key = nil
|
6
|
+
def self.api_key=(x); @@api_key = x; end
|
7
|
+
def self.api_key
|
8
|
+
@@api_key ||= (personal_key || DEFAULT_API_KEY)
|
9
|
+
end
|
10
|
+
|
3
11
|
def self.converts_gif_to_png?
|
4
12
|
false
|
5
13
|
end
|
6
14
|
|
7
15
|
def self.optimized_image_data_for(file)
|
8
|
-
url = 'http://www.gracepointafterfive.com/
|
9
|
-
response = HTTPClient.post url, { 'img' => File.new(file), 'key' =>
|
16
|
+
url = 'http://www.gracepointafterfive.com/punypng/api/optimize'
|
17
|
+
response = HTTPClient.post url, { 'img' => File.new(file), 'key' => api_key}
|
10
18
|
response = JSON.parse(response.body.content)
|
11
19
|
raise "puny_png: #{response['error']}" if response['error']
|
12
20
|
image_url = response['optimized_url']
|
13
21
|
raise "no optimized_url found" unless image_url
|
14
22
|
open(image_url) { |source| source.read() }
|
15
23
|
end
|
24
|
+
|
25
|
+
private
|
26
|
+
|
27
|
+
def self.personal_key
|
28
|
+
key = `cat ~/.puny_png_api_key`.strip
|
29
|
+
key.empty? ? nil : key
|
30
|
+
end
|
16
31
|
end
|
17
32
|
end
|
data/smusher.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{smusher}
|
8
|
-
s.version = "0.4.
|
8
|
+
s.version = "0.4.4"
|
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{
|
12
|
+
s.date = %q{2010-03-23}
|
13
13
|
s.default_executable = %q{smusher}
|
14
14
|
s.email = %q{grosser.michael@gmail.com}
|
15
15
|
s.executables = ["smusher"]
|
@@ -47,7 +47,7 @@ Gem::Specification.new do |s|
|
|
47
47
|
s.homepage = %q{http://github.com/grosser/smusher}
|
48
48
|
s.rdoc_options = ["--charset=UTF-8"]
|
49
49
|
s.require_paths = ["lib"]
|
50
|
-
s.rubygems_version = %q{1.3.
|
50
|
+
s.rubygems_version = %q{1.3.6}
|
51
51
|
s.summary = %q{Automatic Lossless Reduction Of All Your Images}
|
52
52
|
s.test_files = [
|
53
53
|
"spec/spec_helper.rb",
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,12 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: smusher
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
|
4
|
+
prerelease: false
|
5
|
+
segments:
|
6
|
+
- 0
|
7
|
+
- 4
|
8
|
+
- 4
|
9
|
+
version: 0.4.4
|
5
10
|
platform: ruby
|
6
11
|
authors:
|
7
12
|
- Michael Grosser
|
@@ -9,39 +14,45 @@ autorequire:
|
|
9
14
|
bindir: bin
|
10
15
|
cert_chain: []
|
11
16
|
|
12
|
-
date:
|
17
|
+
date: 2010-03-23 00:00:00 +01:00
|
13
18
|
default_executable: smusher
|
14
19
|
dependencies:
|
15
20
|
- !ruby/object:Gem::Dependency
|
16
21
|
name: rake
|
17
|
-
|
18
|
-
|
19
|
-
version_requirements: !ruby/object:Gem::Requirement
|
22
|
+
prerelease: false
|
23
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
20
24
|
requirements:
|
21
25
|
- - ">="
|
22
26
|
- !ruby/object:Gem::Version
|
27
|
+
segments:
|
28
|
+
- 0
|
23
29
|
version: "0"
|
24
|
-
|
30
|
+
type: :runtime
|
31
|
+
version_requirements: *id001
|
25
32
|
- !ruby/object:Gem::Dependency
|
26
33
|
name: json
|
27
|
-
|
28
|
-
|
29
|
-
version_requirements: !ruby/object:Gem::Requirement
|
34
|
+
prerelease: false
|
35
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
30
36
|
requirements:
|
31
37
|
- - ">="
|
32
38
|
- !ruby/object:Gem::Version
|
39
|
+
segments:
|
40
|
+
- 0
|
33
41
|
version: "0"
|
34
|
-
|
42
|
+
type: :runtime
|
43
|
+
version_requirements: *id002
|
35
44
|
- !ruby/object:Gem::Dependency
|
36
45
|
name: httpclient
|
37
|
-
|
38
|
-
|
39
|
-
version_requirements: !ruby/object:Gem::Requirement
|
46
|
+
prerelease: false
|
47
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
40
48
|
requirements:
|
41
49
|
- - ">="
|
42
50
|
- !ruby/object:Gem::Version
|
51
|
+
segments:
|
52
|
+
- 0
|
43
53
|
version: "0"
|
44
|
-
|
54
|
+
type: :runtime
|
55
|
+
version_requirements: *id003
|
45
56
|
description:
|
46
57
|
email: grosser.michael@gmail.com
|
47
58
|
executables:
|
@@ -90,18 +101,20 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
90
101
|
requirements:
|
91
102
|
- - ">="
|
92
103
|
- !ruby/object:Gem::Version
|
104
|
+
segments:
|
105
|
+
- 0
|
93
106
|
version: "0"
|
94
|
-
version:
|
95
107
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
96
108
|
requirements:
|
97
109
|
- - ">="
|
98
110
|
- !ruby/object:Gem::Version
|
111
|
+
segments:
|
112
|
+
- 0
|
99
113
|
version: "0"
|
100
|
-
version:
|
101
114
|
requirements: []
|
102
115
|
|
103
116
|
rubyforge_project:
|
104
|
-
rubygems_version: 1.3.
|
117
|
+
rubygems_version: 1.3.6
|
105
118
|
signing_key:
|
106
119
|
specification_version: 3
|
107
120
|
summary: Automatic Lossless Reduction Of All Your Images
|