attachment_magick 0.2.0 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile.lock +1 -1
- data/lib/attachment_magick.rb +4 -1
- data/lib/attachment_magick/dsl.rb +2 -2
- data/lib/attachment_magick/version.rb +1 -1
- data/test/attachment_magick/units/artist_test.rb +1 -1
- data/test/attachment_magick/units/attachment_magick_test.rb +4 -2
- data/test/dummy/app/models/artist.rb +2 -2
- metadata +2 -2
data/Gemfile.lock
CHANGED
data/lib/attachment_magick.rb
CHANGED
@@ -67,8 +67,11 @@ module AttachmentMagick
|
|
67
67
|
def grid_methods
|
68
68
|
self.attachment_magick_default_options[:styles].each do |key, value|
|
69
69
|
self.send :define_singleton_method, "style_#{key.to_s}" do
|
70
|
+
value[:width] = value[:width] == 0 ? nil : value[:width]
|
71
|
+
value[:height] = value[:height] == 0 ? nil : value[:height]
|
72
|
+
|
70
73
|
metric = "#{value[:width]}x#{value[:height]}"
|
71
|
-
metric = "#{metric}#
|
74
|
+
metric = "#{metric}#{value[:ajust]}" if value[:ajust]
|
72
75
|
|
73
76
|
return metric
|
74
77
|
end
|
@@ -7,7 +7,6 @@ module AttachmentMagick
|
|
7
7
|
@set = set
|
8
8
|
@styles = {}
|
9
9
|
@default_grids = default_grids
|
10
|
-
@default_options = {:crop => true}
|
11
10
|
end
|
12
11
|
|
13
12
|
def method_missing(name, *params, &blk)
|
@@ -21,13 +20,14 @@ module AttachmentMagick
|
|
21
20
|
options = {}
|
22
21
|
options.merge!(:width => values.first.to_i) if values.first
|
23
22
|
options.merge!(:height => values.last.to_i) if values.second
|
23
|
+
options.merge!(:ajust => values.second.match(/\W/).to_s) unless values.second.match(/\W/).to_s.blank? if values.second
|
24
24
|
|
25
25
|
options = @default_grids[name.to_sym].merge(options)
|
26
26
|
elsif options.is_a?(Hash)
|
27
27
|
options = @default_grids[name.to_sym].merge(options)
|
28
28
|
end
|
29
29
|
|
30
|
-
@styles.merge!(name.to_sym =>
|
30
|
+
@styles.merge!(name.to_sym => options)
|
31
31
|
end
|
32
32
|
|
33
33
|
def styles
|
@@ -5,7 +5,7 @@ class ArtistTest < ActiveSupport::TestCase
|
|
5
5
|
assert_equal "36x36", Artist.style_thumb
|
6
6
|
assert_equal "54x", Artist.style_grid_1
|
7
7
|
assert_equal "150x", Artist.style_grid_10
|
8
|
-
assert_equal "200x300
|
8
|
+
assert_equal "200x300", Artist.style_grid_15
|
9
9
|
assert_equal "909x230#", Artist.style_grid_16
|
10
10
|
end
|
11
11
|
end
|
@@ -22,12 +22,14 @@ class AttachmentMagickTest < ActiveSupport::TestCase
|
|
22
22
|
|
23
23
|
attachment_magick do
|
24
24
|
grid_1 "300x150"
|
25
|
+
grid_7 "x560>"
|
25
26
|
end
|
26
27
|
end
|
27
28
|
|
28
29
|
test "deveria manter o valor do grid original" do
|
29
|
-
assert_equal "300x150
|
30
|
-
assert_equal "
|
30
|
+
assert_equal "300x150", Cat.style_grid_1
|
31
|
+
assert_equal "x560>", Cat.style_grid_7
|
32
|
+
assert_equal "54x", Dog.style_grid_1
|
31
33
|
end
|
32
34
|
|
33
35
|
def test_has_attachment_magick
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: attachment_magick
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.2.
|
5
|
+
version: 0.2.1
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- "Marco Ant\xC3\xB4nio Singer"
|
@@ -11,7 +11,7 @@ autorequire:
|
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
13
|
|
14
|
-
date: 2011-04-
|
14
|
+
date: 2011-04-09 00:00:00 -03:00
|
15
15
|
default_executable:
|
16
16
|
dependencies:
|
17
17
|
- !ruby/object:Gem::Dependency
|