pollock 0.1.2
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/LICENSE +20 -0
- data/README.markdown +3 -0
- data/Rakefile +61 -0
- data/VERSION +1 -0
- data/bin/pollockserver +36 -0
- data/lib/pollock/image.rb +90 -0
- data/lib/pollock/webapp.rb +20 -0
- data/public/images/faux-pollock.jpg +0 -0
- data/public/index.html +70 -0
- data/public/placeholders/100x100.jpg +0 -0
- data/public/placeholders/200x100-with_some_text.jpg +0 -0
- data/public/placeholders/305x100--00CC00.gif +0 -0
- data/public/placeholders/305x100-with_a_colour-FF0000.png +0 -0
- data/public/stylesheets/screen.css +34 -0
- data/test/helper.rb +10 -0
- data/test/test_image.rb +194 -0
- data/test/tmp/200x200-200x200-#CCCCCC.jpg +0 -0
- data/test/tmp/200x200-200x200-#CCCCCC.png +0 -0
- data/test/tmp/200x200-Wow! I'm a label-#CCCCCC.jpg +0 -0
- data/test/tmp/200x200-false-#CCCCCC.jpg +0 -0
- data/test/tmp/200x200-false-true.jpg +0 -0
- data/test/tmp/200x200-true-#CCCCCC.jpg +0 -0
- data/test/tmp/200x200-true-#CCCCCC.png +0 -0
- data/test/tmp/200x200-true-true.jpg +0 -0
- data/test/tmp/200x200-true-true.png +0 -0
- data/test/tmp/200x200-wow__i_m_a_label.jpg +0 -0
- data/test/tmp/200x200.jpg +0 -0
- data/test/tmp/200x200.png +0 -0
- data/test/tmp/200x300-200x300-#CCCCCC.jpg +0 -0
- data/test/tmp/200x300-true-#CCCCCC.jpg +0 -0
- data/test/tmp/200x300-true-true.jpg +0 -0
- data/test/tmp/200x300.jpg +0 -0
- metadata +130 -0
data/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2009 Gavin Montague
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.markdown
ADDED
data/Rakefile
ADDED
@@ -0,0 +1,61 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'rake'
|
3
|
+
|
4
|
+
begin
|
5
|
+
require 'jeweler'
|
6
|
+
Jeweler::Tasks.new do |gem|
|
7
|
+
gem.name = "pollock"
|
8
|
+
gem.summary = %Q{Generate placeholders for html wireframing without going near Photoshop}
|
9
|
+
gem.description = %Q{A little Sinatra and RMagick to generate placeholder images via an http call. Heavily inspired by http://placehold.it}
|
10
|
+
gem.email = "gavin@leftbrained.co.uk"
|
11
|
+
gem.homepage = "http://github.com/govan/pollock"
|
12
|
+
gem.authors = ["Gavin Montague"]
|
13
|
+
|
14
|
+
gem.add_development_dependency "thoughtbot-shoulda", ">= 0"
|
15
|
+
gem.add_dependency "rmagick", ">= 0"
|
16
|
+
gem.add_dependency "sinatra", ">= 0"
|
17
|
+
|
18
|
+
gem.executables = "pollockserver"
|
19
|
+
|
20
|
+
gem.files = FileList["[A-Z]*", "{bin,lib,public,test}/**/*", 'lib/jeweler/templates/.gitignore']
|
21
|
+
|
22
|
+
|
23
|
+
end
|
24
|
+
Jeweler::GemcutterTasks.new
|
25
|
+
rescue LoadError
|
26
|
+
puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
|
27
|
+
end
|
28
|
+
|
29
|
+
require 'rake/testtask'
|
30
|
+
Rake::TestTask.new(:test) do |test|
|
31
|
+
test.libs << 'lib' << 'test'
|
32
|
+
test.pattern = 'test/**/test_*.rb'
|
33
|
+
test.verbose = true
|
34
|
+
end
|
35
|
+
|
36
|
+
begin
|
37
|
+
require 'rcov/rcovtask'
|
38
|
+
Rcov::RcovTask.new do |test|
|
39
|
+
test.libs << 'test'
|
40
|
+
test.pattern = 'test/**/test_*.rb'
|
41
|
+
test.verbose = true
|
42
|
+
end
|
43
|
+
rescue LoadError
|
44
|
+
task :rcov do
|
45
|
+
abort "RCov is not available. In order to run rcov, you must: sudo gem install spicycode-rcov"
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
task :test => :check_dependencies
|
50
|
+
|
51
|
+
task :default => :test
|
52
|
+
|
53
|
+
require 'rake/rdoctask'
|
54
|
+
Rake::RDocTask.new do |rdoc|
|
55
|
+
version = File.exist?('VERSION') ? File.read('VERSION') : ""
|
56
|
+
|
57
|
+
rdoc.rdoc_dir = 'rdoc'
|
58
|
+
rdoc.title = "pollock #{version}"
|
59
|
+
rdoc.rdoc_files.include('README*')
|
60
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
61
|
+
end
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.1.2
|
data/bin/pollockserver
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
$:.unshift File.dirname(__FILE__) + "/../lib/pollock"
|
4
|
+
|
5
|
+
require 'optparse'
|
6
|
+
require 'rubygems'
|
7
|
+
require 'sinatra'
|
8
|
+
require 'image'
|
9
|
+
|
10
|
+
# Argument defaults
|
11
|
+
options = { :port => 1912}
|
12
|
+
|
13
|
+
# Get arguments
|
14
|
+
opts = OptionParser.new do |o|
|
15
|
+
o.banner = "usage: pollockserver [options]"
|
16
|
+
#
|
17
|
+
o.on("--port", "change the port from pollock's default of 1912") do
|
18
|
+
options[:port] = 1912
|
19
|
+
end
|
20
|
+
#
|
21
|
+
o.on_tail("-h", "--help", "show this message") do
|
22
|
+
puts opts
|
23
|
+
exit
|
24
|
+
end
|
25
|
+
|
26
|
+
# Version
|
27
|
+
# o.on_tail("-v", "--version", "show version") do
|
28
|
+
# # TODO
|
29
|
+
# exit
|
30
|
+
# end
|
31
|
+
end
|
32
|
+
|
33
|
+
opts.parse! # Parse arguments into `options` hash
|
34
|
+
|
35
|
+
require 'webapp' # and start it rolling...
|
36
|
+
Sinatra::Application.run!
|
@@ -0,0 +1,90 @@
|
|
1
|
+
require 'RMagick'
|
2
|
+
module Pollock
|
3
|
+
class Image
|
4
|
+
|
5
|
+
DEFAULT_COLOUR = "#CCCCCC"
|
6
|
+
FONT = "georgia"
|
7
|
+
|
8
|
+
attr_accessor :height, :width, :text, :colour, :format
|
9
|
+
def initialize(args={})
|
10
|
+
args = build_args_from_string(args) if args.is_a? String
|
11
|
+
raise ArgumentError.new("Image requires at least a size :height=>300") unless (args[:height]||args[:width]).to_i >0
|
12
|
+
self.height = (args[:height]||args[:width]).to_i
|
13
|
+
self.width = (args[:width]||args[:height]).to_i
|
14
|
+
self.text = args[:text]
|
15
|
+
self.colour = args[:colour]
|
16
|
+
self.format = args[:format]||'jpg'
|
17
|
+
end
|
18
|
+
|
19
|
+
def format=(new_format)
|
20
|
+
raise ArgumentError.new("Unknown image format") unless %w(jpg jpeg gif png).include? new_format
|
21
|
+
@format=new_format
|
22
|
+
end
|
23
|
+
|
24
|
+
def text
|
25
|
+
@text.to_s.empty? ? default_text : @text
|
26
|
+
end
|
27
|
+
|
28
|
+
def text=(new_text)
|
29
|
+
@text = new_text.to_s.gsub('_', ' ') unless new_text.nil?
|
30
|
+
end
|
31
|
+
|
32
|
+
def colour=(new_colour)
|
33
|
+
@colour = ("#"+new_colour.to_s).gsub("##", '#') if new_colour =~ /^#?[0-9a-f]{6}$/i
|
34
|
+
end
|
35
|
+
|
36
|
+
def colour
|
37
|
+
@colour||DEFAULT_COLOUR
|
38
|
+
end
|
39
|
+
|
40
|
+
def text_colour
|
41
|
+
"#CC0000"
|
42
|
+
end
|
43
|
+
|
44
|
+
def file_name
|
45
|
+
parts = [default_text]
|
46
|
+
parts << ((text == default_text) ? '' : text.downcase.gsub(/[^a-z]/, '_'))
|
47
|
+
parts << ((colour == DEFAULT_COLOUR) ? '' : colour.gsub("#", ''))
|
48
|
+
parts.join('-').gsub(/-+$/, '')+"."+format
|
49
|
+
end
|
50
|
+
|
51
|
+
def save(dir)
|
52
|
+
path = File.join(dir, file_name)
|
53
|
+
image.write(path)
|
54
|
+
path
|
55
|
+
end
|
56
|
+
|
57
|
+
private
|
58
|
+
def build_args_from_string(str)
|
59
|
+
str, format = str.split(".")
|
60
|
+
bits = str.split('-')
|
61
|
+
height, width = bits.shift.to_s.split('x')
|
62
|
+
width = height if width.nil?
|
63
|
+
text = bits.shift
|
64
|
+
colour = bits.shift
|
65
|
+
{:colour=>colour, :text=>text, :height=>height, :width=>width, :format=>format}
|
66
|
+
end
|
67
|
+
|
68
|
+
def default_text
|
69
|
+
"#{height}x#{width}"
|
70
|
+
end
|
71
|
+
|
72
|
+
def image
|
73
|
+
the_colour = colour
|
74
|
+
the_text_colour = text_colour
|
75
|
+
img = Magick::Image.new(height, width) do
|
76
|
+
self.background_color = the_colour
|
77
|
+
end
|
78
|
+
|
79
|
+
image_text = Magick::Draw.new
|
80
|
+
image_text.font_family = FONT
|
81
|
+
image_text.pointsize = 20
|
82
|
+
image_text.gravity = Magick::CenterGravity
|
83
|
+
image_text.annotate(img, 0,0,0,0, self.text)
|
84
|
+
image_text.fill = self.text_colour
|
85
|
+
img
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
|
@@ -0,0 +1,20 @@
|
|
1
|
+
#
|
2
|
+
# Sinatra app to server images. If the image exists serve it, if it doesn't
|
3
|
+
# generate and cache it.
|
4
|
+
#
|
5
|
+
|
6
|
+
PUBLIC_DIR = File.join(File.dirname(File.dirname(File.dirname(__FILE__))), 'public')
|
7
|
+
POLLOCK_PORT = 1912
|
8
|
+
|
9
|
+
set :port, POLLOCK_PORT
|
10
|
+
set :public, PUBLIC_DIR
|
11
|
+
set :environment, :production
|
12
|
+
|
13
|
+
get "/" do
|
14
|
+
File.open(File.join(PUBLIC_DIR, 'index.html'))
|
15
|
+
end
|
16
|
+
|
17
|
+
get %r{/placeholders/(.*)} do |image_params|
|
18
|
+
image = Pollock::Image.new(image_params)
|
19
|
+
File.open(image.save(File.join(PUBLIC_DIR, 'placeholders')))
|
20
|
+
end
|
Binary file
|
data/public/index.html
ADDED
@@ -0,0 +1,70 @@
|
|
1
|
+
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
|
2
|
+
"http://www.w3.org/TR/html4/strict.dtd">
|
3
|
+
|
4
|
+
<html lang="en">
|
5
|
+
<head>
|
6
|
+
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
7
|
+
<title>Pollock - Hassle free placeholder images.</title>
|
8
|
+
<link rel="stylesheet" href="stylesheets/screen.css" type="text/css" media="screen" title="no title" charset="utf-8">
|
9
|
+
</head>
|
10
|
+
<body>
|
11
|
+
<div id="wrapper">
|
12
|
+
<h1><a href="/">POLLOCK</a></h1>
|
13
|
+
<p>Generate placeholders for html wireframing without going near Photoshop.</p>
|
14
|
+
|
15
|
+
<h2>Usage</h2>
|
16
|
+
<p>Before you install the gem, you'll need <a href="http://www.imagemagick.org">ImageMagick</a>. After that, it's just</p>
|
17
|
+
<pre>
|
18
|
+
$ sudo gem install pollock
|
19
|
+
</pre>
|
20
|
+
|
21
|
+
<p>You'll now have access to the web-app:</p>
|
22
|
+
<pre>
|
23
|
+
$ pollockserver
|
24
|
+
</pre>
|
25
|
+
|
26
|
+
<p>You're ready to start generating placeholders!</p>
|
27
|
+
|
28
|
+
<h2>Syntax</h2>
|
29
|
+
|
30
|
+
<pre>
|
31
|
+
/placeholders/width[xheight][-some_label_text][-color].format
|
32
|
+
</pre>
|
33
|
+
|
34
|
+
<p>Only a width is required to generate a square image. A label can be supplied to override the default behaviour of printing the image dimensions, and finally a #RRGGBB colour can be given to change the background.</p>
|
35
|
+
|
36
|
+
<p>The parameters are separated by '-' and any spaces in the label should be substitued with '_', sorry no non-alphanumeric characters yet.</p>
|
37
|
+
|
38
|
+
<p>You can supply any format extension ImageMagick is capable of generating.</p>
|
39
|
+
|
40
|
+
<pre>
|
41
|
+
http://localhost:1912/placeholders/100x100.jpg
|
42
|
+
http://localhost:1912/placeholders/200x100-with_some_text.jpg
|
43
|
+
http://localhost:1912/placeholders/305x100-with_a_colour-FF0000.png
|
44
|
+
http://localhost:1912/placeholders/305x100--00CC00.gif
|
45
|
+
</pre>
|
46
|
+
|
47
|
+
<img src="./placeholders/100x100.jpg" />
|
48
|
+
<img src="./placeholders/200x100-with_some_text.jpg" /><br>
|
49
|
+
<img src="./placeholders/305x100-with_a_colour-FF0000.png" /><br>
|
50
|
+
<img src="./placeholders/305x100--00CC00.gif" /><br>
|
51
|
+
|
52
|
+
<h2>ToDo</h2>
|
53
|
+
<ul>
|
54
|
+
<li>Options for pollockserver - port, debugging info, etc.</li>
|
55
|
+
<li>A less noisy server.</li>
|
56
|
+
<li>Moar image options!</li>
|
57
|
+
</ul>
|
58
|
+
|
59
|
+
<h2>Credits</h2>
|
60
|
+
<ul>
|
61
|
+
<li>Pollock is very, very, very heavily inspired by <a href="http://placehold.it/">Placehold.it</a>, and if it wasn't for
|
62
|
+
the fact that I like to work offline I'd probably just use that.</li>
|
63
|
+
<li>All the work is being done by <a href="http://sinatrarb.com/">Sinatra</a> and <a href="http://www.imagemagick.org">ImageMagick</a></li>
|
64
|
+
|
65
|
+
<li>The bits were glued together by <a href="http://www.leftbrained.co.uk">Gavin Montague</a> because the hotel TV only had terrestrial channels and Sky Sports.</li>
|
66
|
+
</ul>
|
67
|
+
|
68
|
+
</div>
|
69
|
+
</body>
|
70
|
+
</html>
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
@@ -0,0 +1,34 @@
|
|
1
|
+
* {
|
2
|
+
color:#575757;
|
3
|
+
}
|
4
|
+
h1, h2 {
|
5
|
+
font-family: "HeadlineA", Helvetica, Arial, sans-serif;
|
6
|
+
font-weight:bold;
|
7
|
+
color:#121212;
|
8
|
+
margin-bottom:5px;
|
9
|
+
}
|
10
|
+
html {
|
11
|
+
background:url(../images/faux-pollock.jpg) top left no-repeat;
|
12
|
+
}
|
13
|
+
#wrapper {
|
14
|
+
width:600px;
|
15
|
+
margin-left:320px;
|
16
|
+
}
|
17
|
+
pre {
|
18
|
+
background:#EAEAEA;
|
19
|
+
padding:4px 10px;
|
20
|
+
border-right:solid 1px #DADADA;
|
21
|
+
border-bottom:solid 1px #DADADA;
|
22
|
+
}
|
23
|
+
p, li {
|
24
|
+
font-size:15px;
|
25
|
+
line-height:20px;
|
26
|
+
font-family:Georgia;
|
27
|
+
}
|
28
|
+
a {
|
29
|
+
color:#000000;
|
30
|
+
font-weight:bold;
|
31
|
+
}
|
32
|
+
a:hover {
|
33
|
+
color:#999999;
|
34
|
+
}
|
data/test/helper.rb
ADDED
data/test/test_image.rb
ADDED
@@ -0,0 +1,194 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
class TestPollock < Test::Unit::TestCase
|
4
|
+
def setup
|
5
|
+
@height = 200
|
6
|
+
@width = 300
|
7
|
+
@output_dir = File.join(File.dirname(__FILE__), 'tmp')
|
8
|
+
end
|
9
|
+
|
10
|
+
should 'Image should complain if it receives no arguments' do
|
11
|
+
assert_raise ArgumentError do
|
12
|
+
Pollock::Image.new
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
context "The String Constructor" do
|
17
|
+
should "accept an explicit format" do
|
18
|
+
image = Pollock::Image.new("200.png")
|
19
|
+
assert_equal 'png', image.format
|
20
|
+
end
|
21
|
+
|
22
|
+
should "understand the a single argument constructor" do
|
23
|
+
image = Pollock::Image.new("200.jpg")
|
24
|
+
assert_equal 200, image.height
|
25
|
+
assert_equal 200, image.width
|
26
|
+
end
|
27
|
+
|
28
|
+
should "understand different height and widths" do
|
29
|
+
image = Pollock::Image.new("200x300.jpg")
|
30
|
+
assert_equal 200, image.height
|
31
|
+
assert_equal 300, image.width
|
32
|
+
end
|
33
|
+
|
34
|
+
should 'understand labels' do
|
35
|
+
image = Pollock::Image.new("200-a_sample_label.jpg")
|
36
|
+
assert_equal 'a sample label', image.text
|
37
|
+
image = Pollock::Image.new("200.jpg")
|
38
|
+
assert_equal '200x200', image.text
|
39
|
+
end
|
40
|
+
|
41
|
+
should "understand colours" do
|
42
|
+
image = Pollock::Image.new("200--FF0000.jpg")
|
43
|
+
assert_equal '#FF0000', image.colour
|
44
|
+
end
|
45
|
+
|
46
|
+
should "understand this" do
|
47
|
+
image = Pollock::Image.new('305x100--FF0000.jpg')
|
48
|
+
assert_equal 305, image.height
|
49
|
+
assert_equal 100, image.width
|
50
|
+
assert_equal '305x100', image.text
|
51
|
+
assert_equal '#FF0000', image.colour
|
52
|
+
end
|
53
|
+
|
54
|
+
end
|
55
|
+
|
56
|
+
context "Given an Image that only has a height" do
|
57
|
+
setup {
|
58
|
+
@image = Pollock::Image.new(:height=>@height)
|
59
|
+
}
|
60
|
+
|
61
|
+
should "set height to 200px" do
|
62
|
+
assert_equal @height, @image.height
|
63
|
+
end
|
64
|
+
|
65
|
+
should "set width to the same as the height" do
|
66
|
+
assert_equal @height, @image.width
|
67
|
+
end
|
68
|
+
|
69
|
+
should "set the text to '200x200'" do
|
70
|
+
assert_equal "#{@height}x#{@height}", @image.text
|
71
|
+
end
|
72
|
+
|
73
|
+
should "set the format to 'jpg'" do
|
74
|
+
assert_equal "jpg", @image.format
|
75
|
+
end
|
76
|
+
|
77
|
+
should "use the default background colour" do
|
78
|
+
assert_equal "#CCCCCC", @image.colour
|
79
|
+
end
|
80
|
+
|
81
|
+
should "use the default text colour" do
|
82
|
+
assert_equal "#CC0000", @image.text_colour
|
83
|
+
end
|
84
|
+
|
85
|
+
should "set the file_name" do
|
86
|
+
assert_equal "#{@height}x#{@height}.jpg", @image.file_name
|
87
|
+
end
|
88
|
+
|
89
|
+
should "write out an image" do
|
90
|
+
@image.save(@output_dir)
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
94
|
+
context "Given an Image with a height and width" do
|
95
|
+
setup {
|
96
|
+
@image = Pollock::Image.new(:height=>@height, :width=>@width)
|
97
|
+
}
|
98
|
+
should "set height to 200px" do
|
99
|
+
assert_equal @height, @image.height
|
100
|
+
end
|
101
|
+
|
102
|
+
should "set width to 200px" do
|
103
|
+
assert_equal @width, @image.width
|
104
|
+
end
|
105
|
+
|
106
|
+
should "set the text to '200x300'" do
|
107
|
+
assert_equal '200x300', @image.text
|
108
|
+
end
|
109
|
+
|
110
|
+
should "set the filename correctly" do
|
111
|
+
assert_equal "#{@height}x#{@width}.jpg", @image.file_name
|
112
|
+
end
|
113
|
+
|
114
|
+
should "write out an image" do
|
115
|
+
@image.save(@output_dir)
|
116
|
+
end
|
117
|
+
end
|
118
|
+
|
119
|
+
context "Given an Image with an explicit label" do
|
120
|
+
setup {
|
121
|
+
@text = "Wow! I'm a label"
|
122
|
+
@image = Pollock::Image.new(:height=>@height, :text=>@text)
|
123
|
+
}
|
124
|
+
should "set the text to that value" do
|
125
|
+
assert_equal @text, @image.text
|
126
|
+
end
|
127
|
+
|
128
|
+
should "set the filename correctly" do
|
129
|
+
assert_equal '200x200-wow__i_m_a_label.jpg', @image.file_name
|
130
|
+
end
|
131
|
+
|
132
|
+
should "write out an image" do
|
133
|
+
@image.save(@output_dir)
|
134
|
+
end
|
135
|
+
end
|
136
|
+
|
137
|
+
context "Given an explicit colour" do
|
138
|
+
should "set the colour to that value" do
|
139
|
+
colour = "#999AAA"
|
140
|
+
image = Pollock::Image.new(:height=>@height, :colour=>colour)
|
141
|
+
assert_equal colour, image.colour
|
142
|
+
end
|
143
|
+
|
144
|
+
should "accept a colour without a hash" do
|
145
|
+
colour = "999AAA"
|
146
|
+
image = Pollock::Image.new(:height=>@height, :colour=>colour)
|
147
|
+
assert_equal '#'+colour, image.colour
|
148
|
+
end
|
149
|
+
|
150
|
+
|
151
|
+
should "Ignore a colour that's invalid and keep the default" do
|
152
|
+
image = Pollock::Image.new(:height=>@height, :colour=>"An invalid colour")
|
153
|
+
assert_equal image.colour, Pollock::Image.new(:height=>100).colour
|
154
|
+
end
|
155
|
+
|
156
|
+
should "set the filename correctly" do
|
157
|
+
colour = "999AAA"
|
158
|
+
image = Pollock::Image.new(:height=>@height, :colour=>colour)
|
159
|
+
assert_equal "200x200--999AAA.jpg", image.file_name
|
160
|
+
end
|
161
|
+
|
162
|
+
end
|
163
|
+
|
164
|
+
context "Given an Image with an explicit format" do
|
165
|
+
setup {
|
166
|
+
@format = "png"
|
167
|
+
@image = Pollock::Image.new(:height=>@height, :format=>@format)
|
168
|
+
}
|
169
|
+
should "set the text to that value" do
|
170
|
+
assert_equal @format, @image.format
|
171
|
+
end
|
172
|
+
|
173
|
+
should "set the file_name" do
|
174
|
+
assert_equal "#{@height}x#{@height}.#{@format}", @image.file_name
|
175
|
+
end
|
176
|
+
|
177
|
+
should "Raise an exception for an unknown format" do
|
178
|
+
assert_raise ArgumentError do
|
179
|
+
Pollock::Image.new(:height=>@height, :format=>'bad_format')
|
180
|
+
end
|
181
|
+
end
|
182
|
+
|
183
|
+
|
184
|
+
should "set the filename correctly" do
|
185
|
+
assert_equal "200x200.png", @image.file_name
|
186
|
+
end
|
187
|
+
|
188
|
+
should "write out an image" do
|
189
|
+
@image.save(@output_dir)
|
190
|
+
end
|
191
|
+
|
192
|
+
end
|
193
|
+
|
194
|
+
end
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
metadata
ADDED
@@ -0,0 +1,130 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: pollock
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease: false
|
5
|
+
segments:
|
6
|
+
- 0
|
7
|
+
- 1
|
8
|
+
- 2
|
9
|
+
version: 0.1.2
|
10
|
+
platform: ruby
|
11
|
+
authors:
|
12
|
+
- Gavin Montague
|
13
|
+
autorequire:
|
14
|
+
bindir: bin
|
15
|
+
cert_chain: []
|
16
|
+
|
17
|
+
date: 2010-03-26 00:00:00 +00:00
|
18
|
+
default_executable: pollockserver
|
19
|
+
dependencies:
|
20
|
+
- !ruby/object:Gem::Dependency
|
21
|
+
name: thoughtbot-shoulda
|
22
|
+
prerelease: false
|
23
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
24
|
+
requirements:
|
25
|
+
- - ">="
|
26
|
+
- !ruby/object:Gem::Version
|
27
|
+
segments:
|
28
|
+
- 0
|
29
|
+
version: "0"
|
30
|
+
type: :development
|
31
|
+
version_requirements: *id001
|
32
|
+
- !ruby/object:Gem::Dependency
|
33
|
+
name: rmagick
|
34
|
+
prerelease: false
|
35
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
36
|
+
requirements:
|
37
|
+
- - ">="
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
segments:
|
40
|
+
- 0
|
41
|
+
version: "0"
|
42
|
+
type: :runtime
|
43
|
+
version_requirements: *id002
|
44
|
+
- !ruby/object:Gem::Dependency
|
45
|
+
name: sinatra
|
46
|
+
prerelease: false
|
47
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
48
|
+
requirements:
|
49
|
+
- - ">="
|
50
|
+
- !ruby/object:Gem::Version
|
51
|
+
segments:
|
52
|
+
- 0
|
53
|
+
version: "0"
|
54
|
+
type: :runtime
|
55
|
+
version_requirements: *id003
|
56
|
+
description: A little Sinatra and RMagick to generate placeholder images via an http call. Heavily inspired by http://placehold.it
|
57
|
+
email: gavin@leftbrained.co.uk
|
58
|
+
executables:
|
59
|
+
- pollockserver
|
60
|
+
extensions: []
|
61
|
+
|
62
|
+
extra_rdoc_files:
|
63
|
+
- LICENSE
|
64
|
+
- README.markdown
|
65
|
+
files:
|
66
|
+
- LICENSE
|
67
|
+
- README.markdown
|
68
|
+
- Rakefile
|
69
|
+
- VERSION
|
70
|
+
- bin/pollockserver
|
71
|
+
- lib/pollock/image.rb
|
72
|
+
- lib/pollock/webapp.rb
|
73
|
+
- public/images/faux-pollock.jpg
|
74
|
+
- public/index.html
|
75
|
+
- public/placeholders/100x100.jpg
|
76
|
+
- public/placeholders/200x100-with_some_text.jpg
|
77
|
+
- public/placeholders/305x100--00CC00.gif
|
78
|
+
- public/placeholders/305x100-with_a_colour-FF0000.png
|
79
|
+
- public/stylesheets/screen.css
|
80
|
+
- test/helper.rb
|
81
|
+
- test/test_image.rb
|
82
|
+
- test/tmp/200x200-200x200-#CCCCCC.jpg
|
83
|
+
- test/tmp/200x200-200x200-#CCCCCC.png
|
84
|
+
- test/tmp/200x200-Wow! I'm a label-#CCCCCC.jpg
|
85
|
+
- test/tmp/200x200-false-#CCCCCC.jpg
|
86
|
+
- test/tmp/200x200-false-true.jpg
|
87
|
+
- test/tmp/200x200-true-#CCCCCC.jpg
|
88
|
+
- test/tmp/200x200-true-#CCCCCC.png
|
89
|
+
- test/tmp/200x200-true-true.jpg
|
90
|
+
- test/tmp/200x200-true-true.png
|
91
|
+
- test/tmp/200x200-wow__i_m_a_label.jpg
|
92
|
+
- test/tmp/200x200.jpg
|
93
|
+
- test/tmp/200x200.png
|
94
|
+
- test/tmp/200x300-200x300-#CCCCCC.jpg
|
95
|
+
- test/tmp/200x300-true-#CCCCCC.jpg
|
96
|
+
- test/tmp/200x300-true-true.jpg
|
97
|
+
- test/tmp/200x300.jpg
|
98
|
+
has_rdoc: true
|
99
|
+
homepage: http://github.com/govan/pollock
|
100
|
+
licenses: []
|
101
|
+
|
102
|
+
post_install_message:
|
103
|
+
rdoc_options:
|
104
|
+
- --charset=UTF-8
|
105
|
+
require_paths:
|
106
|
+
- lib
|
107
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
108
|
+
requirements:
|
109
|
+
- - ">="
|
110
|
+
- !ruby/object:Gem::Version
|
111
|
+
segments:
|
112
|
+
- 0
|
113
|
+
version: "0"
|
114
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
115
|
+
requirements:
|
116
|
+
- - ">="
|
117
|
+
- !ruby/object:Gem::Version
|
118
|
+
segments:
|
119
|
+
- 0
|
120
|
+
version: "0"
|
121
|
+
requirements: []
|
122
|
+
|
123
|
+
rubyforge_project:
|
124
|
+
rubygems_version: 1.3.6
|
125
|
+
signing_key:
|
126
|
+
specification_version: 3
|
127
|
+
summary: Generate placeholders for html wireframing without going near Photoshop
|
128
|
+
test_files:
|
129
|
+
- test/helper.rb
|
130
|
+
- test/test_image.rb
|