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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8c45e44970dae37264f8244f397f56e2ba72ae21
4
- data.tar.gz: 5d8a38713757555a840d6fd9f4f98292da12cf5c
3
+ metadata.gz: b8b6e75cabf45a0d5d08eeb4e90926c0e0974cde
4
+ data.tar.gz: b205788bb90f2a5c5e7b7ec9b3c7329e5553a130
5
5
  SHA512:
6
- metadata.gz: a1253c70fd08f6d22938254721725054165960483e58245855743804073dff9ecaf055df5b88aec5fcbb33e491ae102f5dccb7708b2efd0e72773c8a490b788a
7
- data.tar.gz: 2c2c571b46810e67c6fb0964406a8d6ed9d026abd80c3c2bd4a4d69fbdca3b197e28e66990576b3e36a149b115236e11b72bcb50fb40a4f9fc6299693c97f477
6
+ metadata.gz: ea8856f5f9680663714ba9812f8c4eef94c0ba19c58e2b2ae078a6f2dd4c481f3e78d32b4aae01a719bfa7fe21988cfe7bc1f8a54ebaac73f4b43943d41e980e
7
+ data.tar.gz: 3bdd2a93668c83d5176cefc0afcf0f65fb941d6169d0108f0004597b12b8647d930563b1157eaa6ab78500ea6a72222d60747cc41c0bd48fe5f99f89b507007e
data/.gitignore CHANGED
@@ -12,6 +12,6 @@
12
12
  *.o
13
13
  *.a
14
14
  mkmf.log
15
- placebear-0.0.1.gem
15
+ placebear-*.gem
16
16
  .rvmrc
17
17
  .DS_Store
@@ -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
@@ -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 = false)
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}' />".html_safe
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}' />".html_safe
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
@@ -1,3 +1,3 @@
1
1
  module Placebear
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
@@ -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 place_bear(300), "<img src='http://placebear.com/300/300' />"
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 place_bear_grayscale(300), "<img src='http://placebear.com/g/300/300' />"
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 place_bear_gray(500,200), "<img src='http://placebear.com/g/500/200' />"
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 place_bear_gray, "<img src='http://placebear.com/g/300/300' />"
20
+ assert_equal "<img src='http://placebear.com/g/300/300' >".html_safe, place_bear_gray
21
21
  end
22
22
 
23
23
  end
@@ -7,23 +7,32 @@ class PlaceBearTest < Minitest::Unit::TestCase
7
7
  end
8
8
 
9
9
  def test_grayscale
10
- assert_equal PlaceBear.grayscale(400), "<img src='http://placebear.com/g/400/400' />"
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 PlaceBear.image, "<img src='http://placebear.com/300/300' />"
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 PlaceBear.image(400), "<img src='http://placebear.com/400/400' />"
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 PlaceBear.image(400), "<img src='http://placebear.com/400/400' />"
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 PlaceBear.grayscale(300), "<img src='http://placebear.com/g/300/300' />"
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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: placebear
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - dannysperry