jitterbug 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.document +5 -0
- data/.gitignore +21 -0
- data/LICENSE +20 -0
- data/README.markdown +19 -0
- data/Rakefile +44 -0
- data/VERSION +1 -0
- data/jitterbug.gemspec +57 -0
- data/lib/jitterbug.rb +27 -0
- data/lib/jitterbug/config.rb +24 -0
- data/lib/jitterbug/fonts.rb +15 -0
- data/spec/jitterbug_spec.rb +7 -0
- data/spec/spec.opts +1 -0
- data/spec/spec_helper.rb +9 -0
- metadata +79 -0
data/.document
ADDED
data/.gitignore
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2009 Chris Sessions
|
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
@@ -0,0 +1,19 @@
|
|
1
|
+
# Jitterbug: A just-in-time image creator for pretty text headers
|
2
|
+
|
3
|
+
Jitterbug provides on-demand text header images using the font of your choice. On its first request, Jitterbug creates the requested header graphic. Then, and on subsequent requests, it returns an html image tag pointing to the header graphic file.
|
4
|
+
|
5
|
+
## Quick Links
|
6
|
+
|
7
|
+
* http://github.com/flyingsaucer/jitterbug
|
8
|
+
|
9
|
+
## Installing
|
10
|
+
|
11
|
+
# Install the gem:
|
12
|
+
sudo gem install jitterbug
|
13
|
+
|
14
|
+
## Using in an existing project
|
15
|
+
|
16
|
+
|
17
|
+
|
18
|
+
### Default configs
|
19
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1,44 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'rake'
|
3
|
+
|
4
|
+
begin
|
5
|
+
require 'jeweler'
|
6
|
+
Jeweler::Tasks.new do |gem|
|
7
|
+
gem.name = "jitterbug"
|
8
|
+
gem.summary = %Q{Jitterbug: A just-in-time image creator for pretty text headers}
|
9
|
+
gem.description = %Q{Jitterbug provides on-demand text header images using the font of your choice. On its first request, Jitterbug creates the requested header graphic. Then, and on subsequent requests, it returns an html image tag pointing to the header graphic file.}
|
10
|
+
gem.email = "contact@flying-saucer.net"
|
11
|
+
gem.homepage = "http://github.com/flyingsaucer/jitterbug"
|
12
|
+
gem.authors = ["Chris Sessions", "Seth Engelhard"]
|
13
|
+
gem.add_development_dependency "rspec", ">= 1.2.9"
|
14
|
+
end
|
15
|
+
Jeweler::GemcutterTasks.new
|
16
|
+
rescue LoadError
|
17
|
+
puts "Jeweler (or a dependency) not available. Install it with: sudo gem install jeweler"
|
18
|
+
end
|
19
|
+
|
20
|
+
require 'spec/rake/spectask'
|
21
|
+
Spec::Rake::SpecTask.new(:spec) do |spec|
|
22
|
+
spec.libs << 'lib' << 'spec'
|
23
|
+
spec.spec_files = FileList['spec/**/*_spec.rb']
|
24
|
+
end
|
25
|
+
|
26
|
+
Spec::Rake::SpecTask.new(:rcov) do |spec|
|
27
|
+
spec.libs << 'lib' << 'spec'
|
28
|
+
spec.pattern = 'spec/**/*_spec.rb'
|
29
|
+
spec.rcov = true
|
30
|
+
end
|
31
|
+
|
32
|
+
task :spec => :check_dependencies
|
33
|
+
|
34
|
+
task :default => :spec
|
35
|
+
|
36
|
+
require 'rake/rdoctask'
|
37
|
+
Rake::RDocTask.new do |rdoc|
|
38
|
+
version = File.exist?('VERSION') ? File.read('VERSION') : ""
|
39
|
+
|
40
|
+
rdoc.rdoc_dir = 'rdoc'
|
41
|
+
rdoc.title = "jitterbug #{version}"
|
42
|
+
rdoc.rdoc_files.include('README*')
|
43
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
44
|
+
end
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.2.0
|
data/jitterbug.gemspec
ADDED
@@ -0,0 +1,57 @@
|
|
1
|
+
# Generated by jeweler
|
2
|
+
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
|
4
|
+
# -*- encoding: utf-8 -*-
|
5
|
+
|
6
|
+
Gem::Specification.new do |s|
|
7
|
+
s.name = %q{jitterbug}
|
8
|
+
s.version = "0.2.0"
|
9
|
+
|
10
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
+
s.authors = ["Chris Sessions", "Seth Engelhard"]
|
12
|
+
s.date = %q{2009-11-03}
|
13
|
+
s.description = %q{Jitterbug provides on-demand text header images using the font of your choice. On its first request, Jitterbug creates the requested header graphic. Then, and on subsequent requests, it returns an html image tag pointing to the header graphic file.}
|
14
|
+
s.email = %q{contact@flying-saucer.net}
|
15
|
+
s.extra_rdoc_files = [
|
16
|
+
"LICENSE",
|
17
|
+
"README.markdown"
|
18
|
+
]
|
19
|
+
s.files = [
|
20
|
+
".document",
|
21
|
+
".gitignore",
|
22
|
+
"LICENSE",
|
23
|
+
"README.markdown",
|
24
|
+
"Rakefile",
|
25
|
+
"VERSION",
|
26
|
+
"jitterbug.gemspec",
|
27
|
+
"lib/jitterbug.rb",
|
28
|
+
"lib/jitterbug/config.rb",
|
29
|
+
"lib/jitterbug/fonts.rb",
|
30
|
+
"spec/jitterbug_spec.rb",
|
31
|
+
"spec/spec.opts",
|
32
|
+
"spec/spec_helper.rb"
|
33
|
+
]
|
34
|
+
s.homepage = %q{http://github.com/flyingsaucer/jitterbug}
|
35
|
+
s.rdoc_options = ["--charset=UTF-8"]
|
36
|
+
s.require_paths = ["lib"]
|
37
|
+
s.rubygems_version = %q{1.3.5}
|
38
|
+
s.summary = %q{Jitterbug: A just-in-time image creator for pretty text headers}
|
39
|
+
s.test_files = [
|
40
|
+
"spec/jitterbug_spec.rb",
|
41
|
+
"spec/spec_helper.rb"
|
42
|
+
]
|
43
|
+
|
44
|
+
if s.respond_to? :specification_version then
|
45
|
+
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
46
|
+
s.specification_version = 3
|
47
|
+
|
48
|
+
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
49
|
+
s.add_development_dependency(%q<rspec>, [">= 1.2.9"])
|
50
|
+
else
|
51
|
+
s.add_dependency(%q<rspec>, [">= 1.2.9"])
|
52
|
+
end
|
53
|
+
else
|
54
|
+
s.add_dependency(%q<rspec>, [">= 1.2.9"])
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
data/lib/jitterbug.rb
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
require 'jitterbug/config'
|
2
|
+
require 'jitterbug/fonts'
|
3
|
+
require 'md5'
|
4
|
+
|
5
|
+
module Jitterbug
|
6
|
+
|
7
|
+
def self.included(base)
|
8
|
+
Jitterbug::Config.read
|
9
|
+
end
|
10
|
+
|
11
|
+
def jitterbug(label = '<no label provided>', options = {})
|
12
|
+
options = Jitterbug::Config.settings.merge(options)
|
13
|
+
hash = MD5.new("#{label}#{options.sort {|a, b| a[0].to_s <=> b[0].to_s}.to_s}")
|
14
|
+
path = "#{RAILS_ROOT}/public/#{options[:img_path]}/#{hash}.#{options[:format]}".gsub('//', '/')
|
15
|
+
unless File.exist?(path)
|
16
|
+
caption = options[:width] ? "-size #{options[:width]}x caption:'#{label}'" : "label:'#{label}'"
|
17
|
+
`mkdir -p #{"#{RAILS_ROOT}/public/#{options[:img_path]}".gsub('//', '/')}`
|
18
|
+
`convert -background #{options[:background]} -fill "#{options[:color]}" \
|
19
|
+
-font #{Jitterbug::Fonts.find(options[:font_dir], options[:font])} \
|
20
|
+
-pointsize #{options[:size]} -blur 0x.3 #{caption} #{path}`
|
21
|
+
end
|
22
|
+
image_tag "/#{options[:img_path]}/#{hash}.#{options[:format]}".gsub('//', '/'),
|
23
|
+
:class => (['jitterbug'] << options[:class]).compact.join(' '),
|
24
|
+
:alt => label
|
25
|
+
end
|
26
|
+
|
27
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
module Jitterbug
|
2
|
+
module Config
|
3
|
+
|
4
|
+
@@settings = { :background => 'transparent',
|
5
|
+
:color => 'black',
|
6
|
+
:font => '*',
|
7
|
+
:font_dir => '/lib/fonts/',
|
8
|
+
:format => 'png',
|
9
|
+
:img_path => '/content/jitterbug/',
|
10
|
+
:size => 13 }
|
11
|
+
|
12
|
+
def self.read
|
13
|
+
config = "#{RAILS_ROOT}/config/jitterbug.yml"
|
14
|
+
if File.exist?(config)
|
15
|
+
YAML.load_file(config)[RAILS_ENV].each {|key, value| @@settings[key.to_sym] = value}
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
def self.settings
|
20
|
+
@@settings
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
module Jitterbug
|
2
|
+
module Fonts
|
3
|
+
|
4
|
+
def self.find(_path, _font)
|
5
|
+
path = "#{RAILS_ROOT}/#{_path}/*#{_font}*".gsub('//', '/')
|
6
|
+
font = Dir.glob(path)
|
7
|
+
case font.size
|
8
|
+
when 0: raise "*** Jitterbug Error: Font '#{_font}' could not be found in #{_path}"
|
9
|
+
when 1: return font.first
|
10
|
+
else raise "*** Jitterbug Error: Multiple fonts matched '#{_font}' in #{_path}:\n + #{font.join("\n + ")}"
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
end
|
15
|
+
end
|
data/spec/spec.opts
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--color
|
data/spec/spec_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,79 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: jitterbug
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.2.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Chris Sessions
|
8
|
+
- Seth Engelhard
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
|
13
|
+
date: 2009-11-03 00:00:00 -08:00
|
14
|
+
default_executable:
|
15
|
+
dependencies:
|
16
|
+
- !ruby/object:Gem::Dependency
|
17
|
+
name: rspec
|
18
|
+
type: :development
|
19
|
+
version_requirement:
|
20
|
+
version_requirements: !ruby/object:Gem::Requirement
|
21
|
+
requirements:
|
22
|
+
- - ">="
|
23
|
+
- !ruby/object:Gem::Version
|
24
|
+
version: 1.2.9
|
25
|
+
version:
|
26
|
+
description: Jitterbug provides on-demand text header images using the font of your choice. On its first request, Jitterbug creates the requested header graphic. Then, and on subsequent requests, it returns an html image tag pointing to the header graphic file.
|
27
|
+
email: contact@flying-saucer.net
|
28
|
+
executables: []
|
29
|
+
|
30
|
+
extensions: []
|
31
|
+
|
32
|
+
extra_rdoc_files:
|
33
|
+
- LICENSE
|
34
|
+
- README.markdown
|
35
|
+
files:
|
36
|
+
- .document
|
37
|
+
- .gitignore
|
38
|
+
- LICENSE
|
39
|
+
- README.markdown
|
40
|
+
- Rakefile
|
41
|
+
- VERSION
|
42
|
+
- jitterbug.gemspec
|
43
|
+
- lib/jitterbug.rb
|
44
|
+
- lib/jitterbug/config.rb
|
45
|
+
- lib/jitterbug/fonts.rb
|
46
|
+
- spec/jitterbug_spec.rb
|
47
|
+
- spec/spec.opts
|
48
|
+
- spec/spec_helper.rb
|
49
|
+
has_rdoc: true
|
50
|
+
homepage: http://github.com/flyingsaucer/jitterbug
|
51
|
+
licenses: []
|
52
|
+
|
53
|
+
post_install_message:
|
54
|
+
rdoc_options:
|
55
|
+
- --charset=UTF-8
|
56
|
+
require_paths:
|
57
|
+
- lib
|
58
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
59
|
+
requirements:
|
60
|
+
- - ">="
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: "0"
|
63
|
+
version:
|
64
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: "0"
|
69
|
+
version:
|
70
|
+
requirements: []
|
71
|
+
|
72
|
+
rubyforge_project:
|
73
|
+
rubygems_version: 1.3.5
|
74
|
+
signing_key:
|
75
|
+
specification_version: 3
|
76
|
+
summary: "Jitterbug: A just-in-time image creator for pretty text headers"
|
77
|
+
test_files:
|
78
|
+
- spec/jitterbug_spec.rb
|
79
|
+
- spec/spec_helper.rb
|