scale_down 0.2.3.2 → 0.2.9
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGES +3 -0
- data/lib/scale_down/version.rb +1 -1
- data/test/scale_down/image_test.rb +29 -29
- data/test/scale_down_test.rb +3 -3
- data/test/test_helper.rb +2 -2
- metadata +3 -43
data/CHANGES
CHANGED
data/lib/scale_down/version.rb
CHANGED
@@ -10,23 +10,23 @@ class ScaleDown::Image::Test < Test::Unit::TestCase
|
|
10
10
|
end
|
11
11
|
|
12
12
|
teardown do
|
13
|
-
FileUtils.rm_r(
|
13
|
+
FileUtils.rm_r(fixture_path("scaled_test")) if File.directory?(fixture_path('scaled_test'))
|
14
14
|
end
|
15
15
|
|
16
16
|
context "scaling a valid image" do
|
17
17
|
setup do
|
18
18
|
@subject = create \
|
19
|
-
|
20
|
-
|
19
|
+
fixture_path("files/graphic.png"),
|
20
|
+
fixture_path("scaled_test/graphic_scaled.png"),
|
21
21
|
{ :width => 100, :height => 180}
|
22
22
|
end
|
23
23
|
|
24
24
|
should "save the file (and generate the path)" do
|
25
|
-
assert File.exists?(
|
25
|
+
assert File.exists?(fixture_path('scaled_test/graphic_scaled.png'))
|
26
26
|
end
|
27
27
|
|
28
28
|
should "scale the image" do
|
29
|
-
image = Magick::Image.read(
|
29
|
+
image = Magick::Image.read(fixture_path("scaled_test/graphic_scaled.png")).first
|
30
30
|
assert_equal 90, image.columns
|
31
31
|
assert_equal 180, image.rows
|
32
32
|
end
|
@@ -45,11 +45,11 @@ class ScaleDown::Image::Test < Test::Unit::TestCase
|
|
45
45
|
|
46
46
|
should "auto scale any one dimensions" do
|
47
47
|
assert create \
|
48
|
-
|
49
|
-
|
48
|
+
fixture_path("files/graphic.png"),
|
49
|
+
fixture_path("scaled_test/graphic_scaled.png"),
|
50
50
|
{ :width => "auto", :height => 150 }
|
51
51
|
|
52
|
-
image = Magick::Image.read(
|
52
|
+
image = Magick::Image.read(fixture_path("scaled_test/graphic_scaled.png")).first
|
53
53
|
assert_equal 150, image.rows
|
54
54
|
assert_equal 75, image.columns
|
55
55
|
end
|
@@ -76,8 +76,8 @@ class ScaleDown::Image::Test < Test::Unit::TestCase
|
|
76
76
|
context "an invalid file" do
|
77
77
|
setup do
|
78
78
|
@subject = create \
|
79
|
-
|
80
|
-
|
79
|
+
fixture_path("files/invalid_jpeg.jpg"),
|
80
|
+
fixture_path("scaled_test/graphic_scaled.jpg"),
|
81
81
|
{ :width => 100, :height => 105 }
|
82
82
|
end
|
83
83
|
|
@@ -86,20 +86,20 @@ class ScaleDown::Image::Test < Test::Unit::TestCase
|
|
86
86
|
end
|
87
87
|
|
88
88
|
should "not create a scaled image" do
|
89
|
-
assert !File.exists?(
|
89
|
+
assert !File.exists?(fixture_path("scaled_test/graphic_scaled.jpg"))
|
90
90
|
end
|
91
91
|
end
|
92
92
|
|
93
93
|
context "a file larger than the MAX_SIZE" do
|
94
94
|
setup do
|
95
|
-
File.expects(:size).with(
|
95
|
+
File.expects(:size).with(fixture_path("files/graphic.png")).at_least_once.returns(50 * 1_048_576)
|
96
96
|
end
|
97
97
|
|
98
98
|
should "raise an exception" do
|
99
99
|
assert_raises ScaleDown::FileSizeTooLarge do
|
100
100
|
@subject = create \
|
101
|
-
|
102
|
-
|
101
|
+
fixture_path("files/graphic.png"),
|
102
|
+
fixture_path("scaled_test/graphic_scaled.png"),
|
103
103
|
{ :width => 100, :height => 105 }
|
104
104
|
end
|
105
105
|
end
|
@@ -108,13 +108,13 @@ class ScaleDown::Image::Test < Test::Unit::TestCase
|
|
108
108
|
context "cropping" do
|
109
109
|
setup do
|
110
110
|
@subject = create \
|
111
|
-
|
112
|
-
|
111
|
+
fixture_path("files/graphic.png"),
|
112
|
+
fixture_path("scaled_test/graphic_scaled.png"),
|
113
113
|
{ :width => 25, :height => 25, :crop => true }
|
114
114
|
end
|
115
115
|
|
116
116
|
should "crop the image to the dimensions" do
|
117
|
-
image = Magick::Image.read(
|
117
|
+
image = Magick::Image.read(fixture_path("scaled_test/graphic_scaled.png")).first
|
118
118
|
assert_equal 25, image.columns
|
119
119
|
assert_equal 25, image.rows
|
120
120
|
end
|
@@ -123,24 +123,24 @@ class ScaleDown::Image::Test < Test::Unit::TestCase
|
|
123
123
|
context "orientation" do
|
124
124
|
setup do
|
125
125
|
@subject = create \
|
126
|
-
|
127
|
-
|
126
|
+
fixture_path("files/orient.jpg"),
|
127
|
+
fixture_path("scaled_test/graphic_scaled.jpg"),
|
128
128
|
{ :width => "auto", :height => 800}
|
129
129
|
end
|
130
130
|
|
131
131
|
should "be automatic" do
|
132
|
-
image = Magick::Image.read(
|
132
|
+
image = Magick::Image.read(fixture_path("scaled_test/graphic_scaled.jpg")).first
|
133
133
|
assert_equal 600, image.columns
|
134
134
|
assert_equal 800, image.rows
|
135
135
|
end
|
136
136
|
|
137
137
|
should "ignore files without orientation EXIF" do
|
138
138
|
@subject = create \
|
139
|
-
|
140
|
-
|
139
|
+
fixture_path("files/no_orient.tif"),
|
140
|
+
fixture_path("scaled_test/graphic_scaled.jpg"),
|
141
141
|
{ :width => "auto", :height => 424}
|
142
142
|
|
143
|
-
image = Magick::Image.read(
|
143
|
+
image = Magick::Image.read(fixture_path("scaled_test/graphic_scaled.jpg")).first
|
144
144
|
assert_equal 330, image.columns
|
145
145
|
assert_equal 424, image.rows
|
146
146
|
end
|
@@ -149,21 +149,21 @@ class ScaleDown::Image::Test < Test::Unit::TestCase
|
|
149
149
|
context "CMYK images" do
|
150
150
|
should "be converted to RGB" do
|
151
151
|
create \
|
152
|
-
|
153
|
-
|
152
|
+
fixture_path("files/cmyk.tif"),
|
153
|
+
fixture_path("scaled_test/graphic_scaled.jpg"),
|
154
154
|
{ :width => "auto", :height => 200}
|
155
155
|
|
156
|
-
image = Magick::Image.read(
|
156
|
+
image = Magick::Image.read(fixture_path("scaled_test/graphic_scaled.jpg")).first
|
157
157
|
assert_equal Magick::RGBColorspace, image.colorspace
|
158
158
|
end
|
159
159
|
|
160
160
|
should "convert JPGs to RGB JPEGS" do
|
161
161
|
create \
|
162
|
-
|
163
|
-
|
162
|
+
fixture_path("files/cmyk_gray.jpg"),
|
163
|
+
fixture_path("scaled_test/graphic_scaled_2.jpg"),
|
164
164
|
{ :width => "auto", :height => 200}
|
165
165
|
|
166
|
-
image = Magick::Image.read(
|
166
|
+
image = Magick::Image.read(fixture_path("scaled_test/graphic_scaled_2.jpg")).first
|
167
167
|
assert_equal Magick::RGBColorspace, image.colorspace
|
168
168
|
end
|
169
169
|
end
|
data/test/scale_down_test.rb
CHANGED
@@ -43,9 +43,9 @@ class ScaleDown::Test < Test::Unit::TestCase
|
|
43
43
|
context "integration test" do
|
44
44
|
setup do
|
45
45
|
FileUtils.mkdir_p("/tmp/scale_down/test_images/example_1")
|
46
|
-
FileUtils.cp
|
46
|
+
FileUtils.cp fixture_path("files/graphic.png"), "/tmp/scale_down/test_images/example_1/graphic.png"
|
47
47
|
FileUtils.mkdir_p("/tmp/scale_down/test_images/example_2")
|
48
|
-
FileUtils.cp
|
48
|
+
FileUtils.cp fixture_path("files/invalid_jpeg.jpg"), "/tmp/scale_down/test_images/example_2/invalid_jpeg.jpg"
|
49
49
|
end
|
50
50
|
|
51
51
|
teardown do
|
@@ -53,7 +53,7 @@ class ScaleDown::Test < Test::Unit::TestCase
|
|
53
53
|
end
|
54
54
|
|
55
55
|
should "get image info" do
|
56
|
-
FileUtils.cp
|
56
|
+
FileUtils.cp fixture_path("files/cmyk.tif"), "/tmp/scale_down/test_images/example_1/long name .tiff"
|
57
57
|
get "/test_images/example_1/#{CGI.escape 'long name .tiff'}/info"
|
58
58
|
assert_equal "300x500", last_response.body
|
59
59
|
end
|
data/test/test_helper.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
require '
|
1
|
+
require 'scale_down'
|
2
2
|
require 'rack/test'
|
3
3
|
require 'contest'
|
4
4
|
require 'mocha'
|
@@ -14,7 +14,7 @@ class Test::Unit::TestCase
|
|
14
14
|
hmac = HMAC::SHA1.new(secret).update(path).to_s
|
15
15
|
end
|
16
16
|
|
17
|
-
def
|
17
|
+
def fixture_path(append)
|
18
18
|
File.join(File.expand_path(File.dirname(__FILE__)), append)
|
19
19
|
end
|
20
20
|
|
metadata
CHANGED
@@ -1,14 +1,8 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: scale_down
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash: 87
|
5
4
|
prerelease:
|
6
|
-
|
7
|
-
- 0
|
8
|
-
- 2
|
9
|
-
- 3
|
10
|
-
- 2
|
11
|
-
version: 0.2.3.2
|
5
|
+
version: 0.2.9
|
12
6
|
platform: ruby
|
13
7
|
authors:
|
14
8
|
- John Weir
|
@@ -16,7 +10,7 @@ autorequire:
|
|
16
10
|
bindir: bin
|
17
11
|
cert_chain: []
|
18
12
|
|
19
|
-
date: 2011-
|
13
|
+
date: 2011-08-13 00:00:00 -04:00
|
20
14
|
default_executable:
|
21
15
|
dependencies:
|
22
16
|
- !ruby/object:Gem::Dependency
|
@@ -27,10 +21,6 @@ dependencies:
|
|
27
21
|
requirements:
|
28
22
|
- - ">="
|
29
23
|
- !ruby/object:Gem::Version
|
30
|
-
hash: 1
|
31
|
-
segments:
|
32
|
-
- 2
|
33
|
-
- 1
|
34
24
|
version: "2.1"
|
35
25
|
type: :runtime
|
36
26
|
version_requirements: *id001
|
@@ -42,10 +32,6 @@ dependencies:
|
|
42
32
|
requirements:
|
43
33
|
- - ">="
|
44
34
|
- !ruby/object:Gem::Version
|
45
|
-
hash: 15
|
46
|
-
segments:
|
47
|
-
- 1
|
48
|
-
- 0
|
49
35
|
version: "1.0"
|
50
36
|
type: :runtime
|
51
37
|
version_requirements: *id002
|
@@ -57,11 +43,6 @@ dependencies:
|
|
57
43
|
requirements:
|
58
44
|
- - ">="
|
59
45
|
- !ruby/object:Gem::Version
|
60
|
-
hash: 15
|
61
|
-
segments:
|
62
|
-
- 0
|
63
|
-
- 4
|
64
|
-
- 0
|
65
46
|
version: 0.4.0
|
66
47
|
type: :runtime
|
67
48
|
version_requirements: *id003
|
@@ -73,11 +54,6 @@ dependencies:
|
|
73
54
|
requirements:
|
74
55
|
- - ">="
|
75
56
|
- !ruby/object:Gem::Version
|
76
|
-
hash: 31
|
77
|
-
segments:
|
78
|
-
- 0
|
79
|
-
- 1
|
80
|
-
- 2
|
81
57
|
version: 0.1.2
|
82
58
|
type: :development
|
83
59
|
version_requirements: *id004
|
@@ -89,11 +65,6 @@ dependencies:
|
|
89
65
|
requirements:
|
90
66
|
- - "="
|
91
67
|
- !ruby/object:Gem::Version
|
92
|
-
hash: 43
|
93
|
-
segments:
|
94
|
-
- 0
|
95
|
-
- 9
|
96
|
-
- 8
|
97
68
|
version: 0.9.8
|
98
69
|
type: :development
|
99
70
|
version_requirements: *id005
|
@@ -105,11 +76,6 @@ dependencies:
|
|
105
76
|
requirements:
|
106
77
|
- - "="
|
107
78
|
- !ruby/object:Gem::Version
|
108
|
-
hash: 7
|
109
|
-
segments:
|
110
|
-
- 0
|
111
|
-
- 5
|
112
|
-
- 6
|
113
79
|
version: 0.5.6
|
114
80
|
type: :development
|
115
81
|
version_requirements: *id006
|
@@ -166,23 +132,17 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
166
132
|
requirements:
|
167
133
|
- - ">="
|
168
134
|
- !ruby/object:Gem::Version
|
169
|
-
hash: 3
|
170
|
-
segments:
|
171
|
-
- 0
|
172
135
|
version: "0"
|
173
136
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
174
137
|
none: false
|
175
138
|
requirements:
|
176
139
|
- - ">="
|
177
140
|
- !ruby/object:Gem::Version
|
178
|
-
hash: 3
|
179
|
-
segments:
|
180
|
-
- 0
|
181
141
|
version: "0"
|
182
142
|
requirements: []
|
183
143
|
|
184
144
|
rubyforge_project: scale_down
|
185
|
-
rubygems_version: 1.
|
145
|
+
rubygems_version: 1.5.2
|
186
146
|
signing_key:
|
187
147
|
specification_version: 3
|
188
148
|
summary: A Sinatra based server for quickly scaling and serving images. Nothing more.
|