placebear 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -1
- data/lib/placebear/helpers.rb +4 -4
- data/lib/placebear/place_bear.rb +6 -6
- data/lib/placebear/version.rb +1 -1
- data/test/placebear_helpers_test.rb +4 -4
- data/test/placebear_test.rb +14 -5
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b8b6e75cabf45a0d5d08eeb4e90926c0e0974cde
|
4
|
+
data.tar.gz: b205788bb90f2a5c5e7b7ec9b3c7329e5553a130
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ea8856f5f9680663714ba9812f8c4eef94c0ba19c58e2b2ae078a6f2dd4c481f3e78d32b4aae01a719bfa7fe21988cfe7bc1f8a54ebaac73f4b43943d41e980e
|
7
|
+
data.tar.gz: 3bdd2a93668c83d5176cefc0afcf0f65fb941d6169d0108f0004597b12b8647d930563b1157eaa6ab78500ea6a72222d60747cc41c0bd48fe5f99f89b507007e
|
data/.gitignore
CHANGED
data/lib/placebear/helpers.rb
CHANGED
@@ -1,12 +1,12 @@
|
|
1
1
|
module PlaceBear::Helpers
|
2
2
|
# @see PlaceBear.image
|
3
|
-
def place_bear(width = nil, height = nil, grayscale = false)
|
4
|
-
PlaceBear.image(width, height, grayscale)
|
3
|
+
def place_bear(width = nil, height = nil, grayscale = false, img_class: nil)
|
4
|
+
PlaceBear.image(width, height, grayscale: grayscale, img_class: img_class)
|
5
5
|
end
|
6
6
|
|
7
7
|
# @see PlaceBear.grayscale
|
8
|
-
def place_bear_grayscale(width = nil, height = nil)
|
9
|
-
PlaceBear.grayscale(width, height)
|
8
|
+
def place_bear_grayscale(width = nil, height = nil, img_class: nil)
|
9
|
+
PlaceBear.grayscale(width, height, img_class: img_class)
|
10
10
|
end
|
11
11
|
alias place_bear_gray place_bear_grayscale
|
12
12
|
end
|
data/lib/placebear/place_bear.rb
CHANGED
@@ -11,7 +11,7 @@ class PlaceBear
|
|
11
11
|
# @param [Number] width the width of the placebear
|
12
12
|
# @param [Number] height the height of the placebear
|
13
13
|
# @param [Boolean] grayscale whether or not to make the placebear grayscale
|
14
|
-
def self.image(width = nil, height = nil, grayscale
|
14
|
+
def self.image(width = nil, height = nil, grayscale: false, img_class: nil )
|
15
15
|
if width.nil?
|
16
16
|
width = DEFAULT_WIDTH
|
17
17
|
height = DEFAULT_HEIGHT
|
@@ -19,10 +19,10 @@ class PlaceBear
|
|
19
19
|
height = width
|
20
20
|
end
|
21
21
|
|
22
|
-
if grayscale
|
23
|
-
"<img src='http://placebear.com/g/#{width}/#{height}'
|
22
|
+
if grayscale.present?
|
23
|
+
"<img src='http://placebear.com/g/#{width}/#{height}' #{"class='"+img_class+"'" if img_class.present?}>".html_safe
|
24
24
|
else
|
25
|
-
"<img src='http://placebear.com/#{width}/#{height}'
|
25
|
+
"<img src='http://placebear.com/#{width}/#{height}' #{"class='"+img_class+"'" if img_class.present?}>".html_safe
|
26
26
|
end
|
27
27
|
end
|
28
28
|
|
@@ -32,8 +32,8 @@ class PlaceBear
|
|
32
32
|
#
|
33
33
|
# @param [Number] width the width of the placebear
|
34
34
|
# @param [Number] height the height of the placebear
|
35
|
-
def self.grayscale(width = nil, height = nil)
|
36
|
-
self.image(width, height, true)
|
35
|
+
def self.grayscale(width = nil, height = nil, img_class: nil)
|
36
|
+
self.image(width, height, grayscale: true, img_class: img_class)
|
37
37
|
end
|
38
38
|
|
39
39
|
class << self
|
data/lib/placebear/version.rb
CHANGED
@@ -5,19 +5,19 @@ class PlaceBearHelpersTest < Minitest::Unit::TestCase
|
|
5
5
|
include PlaceBear::Helpers
|
6
6
|
|
7
7
|
def test_placebear_helper
|
8
|
-
assert_equal
|
8
|
+
assert_equal "<img src='http://placebear.com/300/300' >".html_safe, place_bear(300)
|
9
9
|
end
|
10
10
|
|
11
11
|
def test_placebear_grayscale_helper
|
12
|
-
assert_equal
|
12
|
+
assert_equal "<img src='http://placebear.com/g/300/300' >".html_safe, place_bear_grayscale(300)
|
13
13
|
end
|
14
14
|
|
15
15
|
def test_placebear_gray_alias
|
16
|
-
assert_equal
|
16
|
+
assert_equal "<img src='http://placebear.com/g/500/200' >".html_safe, place_bear_gray(500,200)
|
17
17
|
end
|
18
18
|
|
19
19
|
def test_placebear_gray_with_no_params
|
20
|
-
assert_equal
|
20
|
+
assert_equal "<img src='http://placebear.com/g/300/300' >".html_safe, place_bear_gray
|
21
21
|
end
|
22
22
|
|
23
23
|
end
|
data/test/placebear_test.rb
CHANGED
@@ -7,23 +7,32 @@ class PlaceBearTest < Minitest::Unit::TestCase
|
|
7
7
|
end
|
8
8
|
|
9
9
|
def test_grayscale
|
10
|
-
assert_equal
|
10
|
+
assert_equal "<img src='http://placebear.com/g/400/400' >".html_safe, PlaceBear.grayscale(400)
|
11
11
|
end
|
12
12
|
|
13
13
|
def test_placebear_without_params
|
14
|
-
assert_equal
|
14
|
+
assert_equal "<img src='http://placebear.com/300/300' >".html_safe, PlaceBear.image
|
15
15
|
end
|
16
16
|
|
17
17
|
def test_placebear
|
18
|
-
assert_equal
|
18
|
+
assert_equal "<img src='http://placebear.com/400/400' >".html_safe, PlaceBear.image(400)
|
19
19
|
end
|
20
20
|
|
21
21
|
def test_bear_alias
|
22
|
-
assert_equal
|
22
|
+
assert_equal "<img src='http://placebear.com/400/400' >".html_safe, PlaceBear.image(400)
|
23
23
|
end
|
24
24
|
|
25
25
|
def test_gray_alias
|
26
|
-
assert_equal
|
26
|
+
assert_equal "<img src='http://placebear.com/g/300/300' >".html_safe, PlaceBear.grayscale(300)
|
27
|
+
end
|
28
|
+
|
29
|
+
def test_adds_img_class
|
30
|
+
assert_equal "<img src='http://placebear.com/400/400' class='some_class'>".html_safe, PlaceBear.image(400, 400, img_class:'some_class')
|
31
|
+
end
|
32
|
+
|
33
|
+
def test_adds_img_class_to_grayscale
|
34
|
+
assert_equal "<img src='http://placebear.com/g/400/400' class='some_class'>".html_safe, PlaceBear.grayscale(400, 400, img_class:'some_class')
|
35
|
+
assert_equal "<img src='http://placebear.com/g/400/400' class='some_class'>".html_safe, PlaceBear.image(400, 400, img_class:'some_class', grayscale: true)
|
27
36
|
end
|
28
37
|
|
29
38
|
end
|