rack-thumb-proxy 0.0.8 → 0.0.9
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/rack-thumb-proxy.rb +18 -29
- data/lib/rack-thumb-proxy/version.rb +1 -1
- metadata +46 -15
data/lib/rack-thumb-proxy.rb
CHANGED
@@ -56,15 +56,10 @@ module Rack
|
|
56
56
|
end
|
57
57
|
|
58
58
|
def retreive_upstream!
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
tempfile.flush
|
64
|
-
end
|
65
|
-
rescue
|
66
|
-
write_error_to_response!
|
67
|
-
return false
|
59
|
+
open(request_url, 'rb') do |f|
|
60
|
+
tempfile.binmode
|
61
|
+
tempfile.write(f.read)
|
62
|
+
tempfile.flush
|
68
63
|
end
|
69
64
|
return true
|
70
65
|
end
|
@@ -94,33 +89,27 @@ module Rack
|
|
94
89
|
|
95
90
|
return true unless should_resize?
|
96
91
|
|
97
|
-
|
98
|
-
require 'mapel'
|
92
|
+
require 'mapel'
|
99
93
|
|
100
|
-
|
101
|
-
|
94
|
+
width, height = dimensions_from_request_options
|
95
|
+
owidth, oheight = dimensions_from_tempfile
|
102
96
|
|
103
|
-
|
104
|
-
|
97
|
+
width = [width, owidth].min if width
|
98
|
+
height = [height, oheight].min if height
|
105
99
|
|
106
|
-
|
100
|
+
cmd = Mapel(tempfile_path)
|
107
101
|
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
end
|
114
|
-
|
115
|
-
cmd.to(tempfile_path).run
|
116
|
-
|
117
|
-
rescue
|
118
|
-
puts $!, $@
|
119
|
-
write_error_to_response!
|
120
|
-
return false
|
102
|
+
if width && height
|
103
|
+
cmd.gravity(request_gravity)
|
104
|
+
cmd.resize!(width, height)
|
105
|
+
else
|
106
|
+
cmd.resize(width, height, 0, 0, '>')
|
121
107
|
end
|
122
108
|
|
109
|
+
cmd.to(tempfile_path).run
|
110
|
+
|
123
111
|
true
|
112
|
+
|
124
113
|
end
|
125
114
|
|
126
115
|
def should_resize?
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rack-thumb-proxy
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.9
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-08-26 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rack
|
16
|
-
requirement:
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,15 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements:
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '0'
|
25
30
|
- !ruby/object:Gem::Dependency
|
26
31
|
name: minitest
|
27
|
-
requirement:
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
28
33
|
none: false
|
29
34
|
requirements:
|
30
35
|
- - ~>
|
@@ -32,10 +37,15 @@ dependencies:
|
|
32
37
|
version: '2.11'
|
33
38
|
type: :development
|
34
39
|
prerelease: false
|
35
|
-
version_requirements:
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ~>
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '2.11'
|
36
46
|
- !ruby/object:Gem::Dependency
|
37
47
|
name: webmock
|
38
|
-
requirement:
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
39
49
|
none: false
|
40
50
|
requirements:
|
41
51
|
- - ~>
|
@@ -43,10 +53,15 @@ dependencies:
|
|
43
53
|
version: 1.8.0
|
44
54
|
type: :development
|
45
55
|
prerelease: false
|
46
|
-
version_requirements:
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ~>
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 1.8.0
|
47
62
|
- !ruby/object:Gem::Dependency
|
48
63
|
name: rack-test
|
49
|
-
requirement:
|
64
|
+
requirement: !ruby/object:Gem::Requirement
|
50
65
|
none: false
|
51
66
|
requirements:
|
52
67
|
- - ~>
|
@@ -54,10 +69,15 @@ dependencies:
|
|
54
69
|
version: 0.6.1
|
55
70
|
type: :development
|
56
71
|
prerelease: false
|
57
|
-
version_requirements:
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - ~>
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: 0.6.1
|
58
78
|
- !ruby/object:Gem::Dependency
|
59
79
|
name: mapel
|
60
|
-
requirement:
|
80
|
+
requirement: !ruby/object:Gem::Requirement
|
61
81
|
none: false
|
62
82
|
requirements:
|
63
83
|
- - ! '>='
|
@@ -65,10 +85,15 @@ dependencies:
|
|
65
85
|
version: '0'
|
66
86
|
type: :development
|
67
87
|
prerelease: false
|
68
|
-
version_requirements:
|
88
|
+
version_requirements: !ruby/object:Gem::Requirement
|
89
|
+
none: false
|
90
|
+
requirements:
|
91
|
+
- - ! '>='
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
version: '0'
|
69
94
|
- !ruby/object:Gem::Dependency
|
70
95
|
name: dimensions
|
71
|
-
requirement:
|
96
|
+
requirement: !ruby/object:Gem::Requirement
|
72
97
|
none: false
|
73
98
|
requirements:
|
74
99
|
- - ! '>='
|
@@ -76,7 +101,12 @@ dependencies:
|
|
76
101
|
version: '0'
|
77
102
|
type: :development
|
78
103
|
prerelease: false
|
79
|
-
version_requirements:
|
104
|
+
version_requirements: !ruby/object:Gem::Requirement
|
105
|
+
none: false
|
106
|
+
requirements:
|
107
|
+
- - ! '>='
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: '0'
|
80
110
|
description: ! ' Rack middleware for resizing proxied requests for images which don''t
|
81
111
|
reside on your own servers. '
|
82
112
|
email:
|
@@ -123,7 +153,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
123
153
|
version: '0'
|
124
154
|
requirements: []
|
125
155
|
rubyforge_project:
|
126
|
-
rubygems_version: 1.8.
|
156
|
+
rubygems_version: 1.8.23
|
127
157
|
signing_key:
|
128
158
|
specification_version: 3
|
129
159
|
summary: For more information see https://github.com/leehambley/rack-thumb-proxy
|
@@ -134,3 +164,4 @@ test_files:
|
|
134
164
|
- test/test_helper.rb
|
135
165
|
- test/test_rack_thumb_proxy.rb
|
136
166
|
- test/test_view_helpers.rb
|
167
|
+
has_rdoc:
|