placeholder_image 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. data/README.md +8 -4
  2. data/lib/placeholder_image.rb +4 -3
  3. metadata +22 -9
data/README.md CHANGED
@@ -7,7 +7,7 @@ SYNOPSIS
7
7
  ========
8
8
 
9
9
  In a view:
10
- <%= placeholder_image_tag :width => 200, :height => 100, :color => :navy, :text_color => :orange %>
10
+ <%= placeholder_image_tag :width => 200, :height => 100, :color => :navy, :text_color => :orange, :text => 'some text instead of the default' %>
11
11
 
12
12
  or for the simplest cases:
13
13
  <%= placeholder_image_tag "200x100" # widthxheight %>
@@ -17,26 +17,30 @@ REQUIREMENTS
17
17
 
18
18
  rmagick - `sudo gem install rmagick`
19
19
 
20
+ HTML-safe strings, which means either using Rails 3, or the [rails_xss](https://github.com/rails/rails_xss) plugin if you're on Rails 2.
21
+
20
22
  INSTALLATION
21
23
  ============
22
24
 
23
25
  sudo gem install placeholder_image
24
26
 
25
27
  then in your environment.rb:
26
- config.gem 'placeholder_image', :source => 'http://gemcutter.org'
28
+ config.gem 'placeholder_image', :source => 'http://rubygems.org'
29
+
30
+ Or if you're using bundler, add the following line to your Gemfile:
31
+ gem 'placeholder_image'
27
32
 
28
33
  TODO
29
34
  ====
30
35
 
31
36
  IE support - If I wait long enough, IE will support me instead. Until then, there's no IE support.
32
37
 
33
-
34
38
  LICENSE
35
39
  =======
36
40
 
37
41
  (The MIT License)
38
42
 
39
- Copyright (c) 2010 Michael Dungan
43
+ Copyright (c) 2011 Michael Dungan
40
44
 
41
45
  Permission is hereby granted, free of charge, to any person obtaining
42
46
  a copy of this software and associated documentation files (the
@@ -3,13 +3,13 @@ require 'rvg/rvg'
3
3
 
4
4
  module PlaceholderImage
5
5
  def placeholder_image_tag(*args)
6
- "<img src='#{placeholder_image_url(*args)}' />"
6
+ "<img src='#{placeholder_image_url(*args)}' />".html_safe
7
7
  end
8
8
 
9
9
  private
10
10
 
11
11
  def placeholder_image_url(*args)
12
- "data:image/png;base64,#{placeholder_image_data(*args)}"
12
+ "data:image/png;base64,#{placeholder_image_data(*args)}".html_safe
13
13
  end
14
14
 
15
15
  def placeholder_image_data(*args)
@@ -22,6 +22,7 @@ module PlaceholderImage
22
22
  width ||= options[:width].to_i
23
23
  height ||= options[:height].to_i
24
24
  color = options.key?(:color) ? options[:color].to_s : "grey69"
25
+ text = options[:text] || "#{width} x #{height}"
25
26
  text_color = options.key?(:text_color) ? options[:text_color].to_s : "black"
26
27
 
27
28
  rvg = Magick::RVG.new(width, height).viewbox(0, 0, width, height) do |canvas|
@@ -36,7 +37,7 @@ module PlaceholderImage
36
37
  drawable.pointsize = width / 10
37
38
  drawable.fill = text_color
38
39
  drawable.gravity = Magick::CenterGravity
39
- drawable.annotate(img, 0, 0, 0, 0, "#{width} x #{height}")
40
+ drawable.annotate(img, 0, 0, 0, 0, text)
40
41
 
41
42
  [img.to_blob].pack("m")
42
43
  end
metadata CHANGED
@@ -1,7 +1,12 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: placeholder_image
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ prerelease: false
5
+ segments:
6
+ - 0
7
+ - 1
8
+ - 1
9
+ version: 0.1.1
5
10
  platform: ruby
6
11
  authors:
7
12
  - Michael Dungan
@@ -9,19 +14,23 @@ autorequire:
9
14
  bindir: bin
10
15
  cert_chain: []
11
16
 
12
- date: 2010-01-26 00:00:00 -08:00
17
+ date: 2010-02-02 00:00:00 -08:00
13
18
  default_executable:
14
19
  dependencies:
15
20
  - !ruby/object:Gem::Dependency
16
21
  name: rmagick
17
- type: :runtime
18
- version_requirement:
19
- version_requirements: !ruby/object:Gem::Requirement
22
+ prerelease: false
23
+ requirement: &id001 !ruby/object:Gem::Requirement
24
+ none: false
20
25
  requirements:
21
26
  - - ">="
22
27
  - !ruby/object:Gem::Version
28
+ segments:
29
+ - 2
30
+ - 0
23
31
  version: "2.0"
24
- version:
32
+ type: :runtime
33
+ version_requirements: *id001
25
34
  description: Generate placeholder images of various sizes, colors, and text colors.
26
35
  email: mpd@jesters-court.net
27
36
  executables: []
@@ -43,21 +52,25 @@ rdoc_options:
43
52
  require_paths:
44
53
  - lib
45
54
  required_ruby_version: !ruby/object:Gem::Requirement
55
+ none: false
46
56
  requirements:
47
57
  - - ">="
48
58
  - !ruby/object:Gem::Version
59
+ segments:
60
+ - 0
49
61
  version: "0"
50
- version:
51
62
  required_rubygems_version: !ruby/object:Gem::Requirement
63
+ none: false
52
64
  requirements:
53
65
  - - ">="
54
66
  - !ruby/object:Gem::Version
67
+ segments:
68
+ - 0
55
69
  version: "0"
56
- version:
57
70
  requirements: []
58
71
 
59
72
  rubyforge_project:
60
- rubygems_version: 1.3.5
73
+ rubygems_version: 1.3.7
61
74
  signing_key:
62
75
  specification_version: 3
63
76
  summary: Generate placeholder images of various sizes