placeholder 0.0.2 → 0.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/README.markdown CHANGED
@@ -10,6 +10,10 @@ How To Install
10
10
  --------------
11
11
  Install the gem: `[sudo] gem install placeholder`
12
12
 
13
+ If you're using Rails, add `config.gem 'placeholder'` to your `config/environment.rb`.
14
+
15
+ If you're using Sinatra, add `require 'placeholder'` to your main application file.
16
+
13
17
  Usage
14
18
  -----
15
19
  Placeholder requires a size as the first argument and can accept `:text`, `:fg_color` and `:bg_color` arguments.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.2
1
+ 0.0.3
data/lib/placeholder.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  class Placeholder
2
2
 
3
- attr_accessor :size, :height, :width, :bg_color, :fg_color, :text
3
+ attr_accessor :height, :width, :bg_color, :fg_color, :text
4
4
 
5
5
  def initialize(size, options = {})
6
6
  measure(size)
@@ -33,7 +33,14 @@ class Placeholder
33
33
  end
34
34
 
35
35
  def color_str
36
- (@bg_color != nil && @fg_color != nil) ? "/#{@bg_color}/#{@fg_color}" : ""
36
+ if @bg_color.nil? && @fg_color != nil
37
+ @text = "Set :bg_color when using :fg_color"
38
+ end
39
+
40
+ str = ""
41
+ str += "/#{@bg_color}" unless @bg_color.nil?
42
+ str += "/#{@fg_color}" unless @fg_color.nil?
43
+ str
37
44
  end
38
45
 
39
46
  end
data/placeholder.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{placeholder}
8
- s.version = "0.0.2"
8
+ s.version = "0.0.3"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Matt Darby"]
12
- s.date = %q{2010-08-11}
12
+ s.date = %q{2010-08-18}
13
13
  s.description = %q{Easy image placeholders via Placehold.it}
14
14
  s.email = %q{matt@protectedmethod.com}
15
15
  s.extra_rdoc_files = [
@@ -12,11 +12,21 @@ describe "Placeholder" do
12
12
  p.to_s.should == "<img src=\"http://placehold.it/200x300\" alt=\"placeholder\" />"
13
13
  end
14
14
 
15
- it "should know about a color" do
15
+ it "should know about a bg_color" do
16
+ p = Placeholder.new(400, :bg_color => "FFFFFF")
17
+ p.to_s.should == "<img src=\"http://placehold.it/400x400/FFFFFF\" alt=\"placeholder\" />"
18
+ end
19
+
20
+ it "should know about a fg_color" do
16
21
  p = Placeholder.new(400, :bg_color => "FFFFFF", :fg_color => "FE0000")
17
22
  p.to_s.should == "<img src=\"http://placehold.it/400x400/FFFFFF/FE0000\" alt=\"placeholder\" />"
18
23
  end
19
24
 
25
+ it "should alert the user if they set :fg_color and not :bg_color" do
26
+ p = Placeholder.new(400, :fg_color => "FE0000")
27
+ p.to_s.should == "<img src=\"http://placehold.it/400x400/FE0000&text=Set+:bg_color+when+using+:fg_color\" alt=\"placeholder\" />"
28
+ end
29
+
20
30
  it "should know about its text" do
21
31
  p = Placeholder.new(400, :text => "Sample Text")
22
32
  p.to_s.should == "<img src=\"http://placehold.it/400x400&text=Sample+Text\" alt=\"placeholder\" />"
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: placeholder
3
3
  version: !ruby/object:Gem::Version
4
- hash: 27
4
+ hash: 25
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 2
10
- version: 0.0.2
9
+ - 3
10
+ version: 0.0.3
11
11
  platform: ruby
12
12
  authors:
13
13
  - Matt Darby
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-08-11 00:00:00 -04:00
18
+ date: 2010-08-18 00:00:00 -04:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency