placeholdit 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +5 -5
- data/lib/placeholdit.rb +5 -2
- data/lib/placeholdit/version.rb +1 -1
- data/spec/placeholdit_spec.rb +4 -0
- metadata +10 -7
data/README.md
CHANGED
@@ -20,23 +20,23 @@ Or install it yourself as:
|
|
20
20
|
|
21
21
|
A basic 500x500 placeholder image:
|
22
22
|
|
23
|
-
|
23
|
+
<%= placeholdit_image_tag "500" %>
|
24
24
|
|
25
25
|
The same placeholder image with custom text:
|
26
26
|
|
27
|
-
|
27
|
+
<%= placeholdit_image_tag "500", text: "Buy me!" %>
|
28
28
|
|
29
29
|
The same placeholder image with a blue background:
|
30
30
|
|
31
|
-
|
31
|
+
<%= placeholdit_image_tag "500", text: "Buy me!", background_color: '#004eff' %>
|
32
32
|
|
33
33
|
The same placeholder image with a blue background and red text (not recommended):
|
34
34
|
|
35
|
-
|
35
|
+
<%= placeholdit_image_tag "500", text: "Buy me!", background_color: '#004eff', text_color: '#ff0000' %>
|
36
36
|
|
37
37
|
Alternatively, calling placeholdit will work as well:
|
38
38
|
|
39
|
-
|
39
|
+
<%= placeholdit "500" %>
|
40
40
|
|
41
41
|
|
42
42
|
## Contributing
|
data/lib/placeholdit.rb
CHANGED
@@ -11,7 +11,8 @@ module Placeholdit
|
|
11
11
|
:alt => (opts[:text] || "A placeholder image"),
|
12
12
|
:class => "placeholder",
|
13
13
|
:height => (size.split('x')[1] || size.split('x')[0]),
|
14
|
-
:width => size.split('x')[0]
|
14
|
+
:width => size.split('x')[0],
|
15
|
+
:title => opts[:title]
|
15
16
|
}.merge!(opts)
|
16
17
|
|
17
18
|
# Placehold.it preferences
|
@@ -25,7 +26,9 @@ module Placeholdit
|
|
25
26
|
src += "&text=#{config[:text]}"
|
26
27
|
end
|
27
28
|
|
28
|
-
image_tag = "<img src='#{src}' alt='#{config[:alt]}' class='#{config[:class]}' height='#{config[:height]}' width='#{config[:width]}'
|
29
|
+
image_tag = "<img src='#{src}' alt='#{config[:alt]}' class='#{config[:class]}' height='#{config[:height]}' width='#{config[:width]}'"
|
30
|
+
image_tag += " title='#{config[:title]}'" if config[:title]
|
31
|
+
image_tag += " />"
|
29
32
|
return image_tag.html_safe if defined?(Rails)
|
30
33
|
image_tag
|
31
34
|
end
|
data/lib/placeholdit/version.rb
CHANGED
data/spec/placeholdit_spec.rb
CHANGED
@@ -34,6 +34,10 @@ describe Placeholdit::ViewHelpers do
|
|
34
34
|
view.placeholdit_image_tag("500", text_color: 'ffffff', background_color: '#000000').should == "<img src='http://placehold.it/500/000000/ffffff' alt='A placeholder image' class='placeholder' height='500' width='500' />"
|
35
35
|
end
|
36
36
|
|
37
|
+
it "should accept title" do
|
38
|
+
view.placeholdit_image_tag("500", title: "Lorem ipsum").should == "<img src='http://placehold.it/500' alt='A placeholder image' class='placeholder' height='500' width='500' title='Lorem ipsum' />"
|
39
|
+
end
|
40
|
+
|
37
41
|
it "should alias to placeholdit" do
|
38
42
|
view.placeholdit("500", text_color: 'fff', background_color: '000').should == "<img src='http://placehold.it/500/000/fff' alt='A placeholder image' class='placeholder' height='500' width='500' />"
|
39
43
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: placeholdit
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,12 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
13
|
-
default_executable:
|
12
|
+
date: 2013-04-15 00:00:00.000000000 Z
|
14
13
|
dependencies:
|
15
14
|
- !ruby/object:Gem::Dependency
|
16
15
|
name: rspec
|
17
|
-
requirement:
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
18
17
|
none: false
|
19
18
|
requirements:
|
20
19
|
- - ! '>='
|
@@ -22,7 +21,12 @@ dependencies:
|
|
22
21
|
version: '0'
|
23
22
|
type: :development
|
24
23
|
prerelease: false
|
25
|
-
version_requirements:
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '0'
|
26
30
|
description: A Rails view helper for placeholder images via http://placehold.it
|
27
31
|
email:
|
28
32
|
- jeffmehlhoff@mac.com
|
@@ -41,7 +45,6 @@ files:
|
|
41
45
|
- placeholdit.gemspec
|
42
46
|
- spec/placeholdit_spec.rb
|
43
47
|
- spec/spec_helper.rb
|
44
|
-
has_rdoc: true
|
45
48
|
homepage: http://github.com/ohokay/placeholdit
|
46
49
|
licenses: []
|
47
50
|
post_install_message:
|
@@ -62,7 +65,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
62
65
|
version: '0'
|
63
66
|
requirements: []
|
64
67
|
rubyforge_project:
|
65
|
-
rubygems_version: 1.
|
68
|
+
rubygems_version: 1.8.25
|
66
69
|
signing_key:
|
67
70
|
specification_version: 3
|
68
71
|
summary: A Rails view helper for placeholder images via http://placehold.it
|