command_wrap 0.5.2 → 0.6
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of command_wrap might be problematic. Click here for more details.
- data/lib/command_wrap/image.rb +7 -1
- data/tests/unit/image_test.rb +14 -1
- metadata +4 -5
data/lib/command_wrap/image.rb
CHANGED
@@ -10,7 +10,13 @@ module CommandWrap
|
|
10
10
|
end
|
11
11
|
|
12
12
|
def self.scale (source, target, width, height = nil)
|
13
|
-
height
|
13
|
+
# if no height, we calculate it based on the width
|
14
|
+
unless height
|
15
|
+
dim = self.dimensions(source)
|
16
|
+
puts dim.inspect
|
17
|
+
height = (1.0 * width * dim[:height] / dim[:width]).floor
|
18
|
+
puts height
|
19
|
+
end
|
14
20
|
|
15
21
|
# Scale source
|
16
22
|
simg = Magick::Image.read(source)[0]
|
data/tests/unit/image_test.rb
CHANGED
@@ -21,7 +21,7 @@ class ImageTest < Test::Unit::TestCase
|
|
21
21
|
|
22
22
|
File.delete(target) if File.exists?(target)
|
23
23
|
|
24
|
-
CommandWrap::Image.scale(source, target, 100)
|
24
|
+
CommandWrap::Image.scale(source, target, 100, 100)
|
25
25
|
assert File.exists?(target)
|
26
26
|
assert_equal dim, CommandWrap::Image.dimensions(target)
|
27
27
|
end
|
@@ -49,5 +49,18 @@ class ImageTest < Test::Unit::TestCase
|
|
49
49
|
assert File.exists?(target)
|
50
50
|
assert_equal dim, CommandWrap::Image.dimensions(target)
|
51
51
|
end
|
52
|
+
|
53
|
+
def test_scale_no_width
|
54
|
+
dim = { :width => 75, :height => 100 }
|
55
|
+
|
56
|
+
source = File.dirname(__FILE__) + "/../helpers/img150x200.jpg"
|
57
|
+
target = File.dirname(__FILE__) + "/../../target4.png"
|
58
|
+
|
59
|
+
File.delete(target) if File.exists?(target)
|
60
|
+
|
61
|
+
CommandWrap::Image.scale(source, target, 75)
|
62
|
+
assert File.exists?(target)
|
63
|
+
assert_equal dim, CommandWrap::Image.dimensions(target)
|
64
|
+
end
|
52
65
|
|
53
66
|
end
|
metadata
CHANGED
@@ -1,13 +1,12 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: command_wrap
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 7
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
|
-
-
|
9
|
-
|
10
|
-
version: 0.5.2
|
8
|
+
- 6
|
9
|
+
version: "0.6"
|
11
10
|
platform: ruby
|
12
11
|
authors:
|
13
12
|
- Stefaan Colman
|
@@ -15,7 +14,7 @@ autorequire:
|
|
15
14
|
bindir: bin
|
16
15
|
cert_chain: []
|
17
16
|
|
18
|
-
date: 2011-
|
17
|
+
date: 2011-08-25 00:00:00 +02:00
|
19
18
|
default_executable:
|
20
19
|
dependencies:
|
21
20
|
- !ruby/object:Gem::Dependency
|