jitimage 0.1.0

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/.document ADDED
@@ -0,0 +1,5 @@
1
+ README.rdoc
2
+ lib/**/*.rb
3
+ bin/*
4
+ features/**/*.feature
5
+ LICENSE
data/.gitignore ADDED
@@ -0,0 +1,21 @@
1
+ ## MAC OS
2
+ .DS_Store
3
+
4
+ ## TEXTMATE
5
+ *.tmproj
6
+ tmtags
7
+
8
+ ## EMACS
9
+ *~
10
+ \#*
11
+ .\#*
12
+
13
+ ## VIM
14
+ *.swp
15
+
16
+ ## PROJECT::GENERAL
17
+ coverage
18
+ rdoc
19
+ pkg
20
+
21
+ ## PROJECT::SPECIFIC
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2009 Flying Saucer
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,20 @@
1
+ # Jitimage: A just-in-time image creator for pretty text headers
2
+
3
+ Jitimage provides on-demand text header images using the font of your choice. On its first request, Jitimage 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/jitimage
8
+
9
+ ## Installing
10
+
11
+ # Install the gem:
12
+ sudo gem install jitimage
13
+
14
+ ## Using in an existing project
15
+
16
+
17
+
18
+ ### Default configs
19
+
20
+
data/Rakefile ADDED
@@ -0,0 +1,51 @@
1
+ require 'rubygems'
2
+ require 'rake'
3
+
4
+ begin
5
+ require 'jeweler'
6
+ Jeweler::Tasks.new do |gem|
7
+ gem.name = "jitimage"
8
+ gem.summary = %Q{Jitimage: A just-in-time image creator for pretty text headers}
9
+ gem.description = %Q{Jitimage provides on-demand text header images using the font of your choice. On its first request, Jitimage 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/jitimage"
12
+ gem.authors = ["Chris Sessions", "Seth Engelhard"]
13
+ end
14
+ Jeweler::GemcutterTasks.new
15
+ rescue LoadError
16
+ puts "Jeweler (or a dependency) not available. Install it with: sudo gem install jeweler"
17
+ end
18
+
19
+ require 'rake/testtask'
20
+ Rake::TestTask.new(:test) do |test|
21
+ test.libs << 'lib' << 'test'
22
+ test.pattern = 'test/**/test_*.rb'
23
+ test.verbose = true
24
+ end
25
+
26
+ begin
27
+ require 'rcov/rcovtask'
28
+ Rcov::RcovTask.new do |test|
29
+ test.libs << 'test'
30
+ test.pattern = 'test/**/test_*.rb'
31
+ test.verbose = true
32
+ end
33
+ rescue LoadError
34
+ task :rcov do
35
+ abort "RCov is not available. In order to run rcov, you must: sudo gem install spicycode-rcov"
36
+ end
37
+ end
38
+
39
+ task :test => :check_dependencies
40
+
41
+ task :default => :test
42
+
43
+ require 'rake/rdoctask'
44
+ Rake::RDocTask.new do |rdoc|
45
+ version = File.exist?('VERSION') ? File.read('VERSION') : ""
46
+
47
+ rdoc.rdoc_dir = 'rdoc'
48
+ rdoc.title = "jitimage #{version}"
49
+ rdoc.rdoc_files.include('README*')
50
+ rdoc.rdoc_files.include('lib/**/*.rb')
51
+ end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.1.0
data/jitimage.gemspec ADDED
@@ -0,0 +1,54 @@
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{jitimage}
8
+ s.version = "0.1.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-10-23}
13
+ s.description = %q{Jitimage provides on-demand text header images using the font of your choice. On its first request, Jitimage 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
+ "jitimage.gemspec",
27
+ "lib/jitimage.rb",
28
+ "lib/jitimage/config.rb",
29
+ "lib/jitimage/fonts.rb",
30
+ "rails/init.rb",
31
+ "test/helper.rb",
32
+ "test/test_jitimage.rb"
33
+ ]
34
+ s.homepage = %q{http://github.com/flyingsaucer/jitimage}
35
+ s.rdoc_options = ["--charset=UTF-8"]
36
+ s.require_paths = ["lib"]
37
+ s.rubygems_version = %q{1.3.5}
38
+ s.summary = %q{Jitimage: A just-in-time image creator for pretty text headers}
39
+ s.test_files = [
40
+ "test/helper.rb",
41
+ "test/test_jitimage.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
+ else
50
+ end
51
+ else
52
+ end
53
+ end
54
+
@@ -0,0 +1,24 @@
1
+ module Jitimage
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/jitimage/',
10
+ :size => 13 }
11
+
12
+ def self.read
13
+ config = "#{RAILS_ROOT}/config/jitimage.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 Jitimage
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 "*** Jitimage Error: Font '#{_font}' could not be found in #{_path}"
9
+ when 1: return font.first
10
+ else raise "*** Jitimage Error: Multiple fonts matched '#{_font}' in #{_path}:\n + #{font.join("\n + ")}"
11
+ end
12
+ end
13
+
14
+ end
15
+ end
data/lib/jitimage.rb ADDED
@@ -0,0 +1,24 @@
1
+ require 'jitimage/config'
2
+ require 'jitimage/fonts'
3
+ require 'md5'
4
+
5
+ module Jitimage
6
+
7
+ def self.included(base)
8
+ Jitimage::Config.read
9
+ end
10
+
11
+ def jitimage(label = '<no label provided>', options = {})
12
+ options = Jitimage::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
+ `mkdir -p #{"#{RAILS_ROOT}/public/#{options[:img_path]}".gsub('//', '/')}`
17
+ `convert -background #{options[:background]} -fill "#{options[:color]}" \
18
+ -font #{Jitimage::Fonts.find(options[:font_dir], options[:font])} \
19
+ -pointsize #{options[:size]} -blur 0x.3 label:'#{label}' #{path}`
20
+ end
21
+ image_tag "/#{options[:img_path]}/#{hash}.#{options[:format]}".gsub('//', '/')
22
+ end
23
+
24
+ end
data/rails/init.rb ADDED
@@ -0,0 +1,5 @@
1
+ require 'jitimage'
2
+
3
+ # ActionController::Base.extend Jitimage::ControllerMixin
4
+
5
+ RAILS_DEFAULT_LOGGER.info("** Jitimage initialized with these settings:\n#{Jitimage::Config.settings.to_yaml}") if defined?(RAILS_DEFAULT_LOGGER)
data/test/helper.rb ADDED
@@ -0,0 +1,10 @@
1
+ require 'rubygems'
2
+ require 'test/unit'
3
+ require 'shoulda'
4
+
5
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
6
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
7
+ require 'jitimage'
8
+
9
+ class Test::Unit::TestCase
10
+ end
@@ -0,0 +1,7 @@
1
+ require 'helper'
2
+
3
+ class TestJitimage < Test::Unit::TestCase
4
+ should "probably rename this file and start testing for real" do
5
+ flunk "hey buddy, you should probably rename this file and start testing for real"
6
+ end
7
+ end
metadata ADDED
@@ -0,0 +1,70 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: jitimage
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Chris Sessions
8
+ - Seth Engelhard
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+
13
+ date: 2009-10-23 00:00:00 -07:00
14
+ default_executable:
15
+ dependencies: []
16
+
17
+ description: Jitimage provides on-demand text header images using the font of your choice. On its first request, Jitimage creates the requested header graphic. Then, and on subsequent requests, it returns an html image tag pointing to the header graphic file.
18
+ email: contact@flying-saucer.net
19
+ executables: []
20
+
21
+ extensions: []
22
+
23
+ extra_rdoc_files:
24
+ - LICENSE
25
+ - README.markdown
26
+ files:
27
+ - .document
28
+ - .gitignore
29
+ - LICENSE
30
+ - README.markdown
31
+ - Rakefile
32
+ - VERSION
33
+ - jitimage.gemspec
34
+ - lib/jitimage.rb
35
+ - lib/jitimage/config.rb
36
+ - lib/jitimage/fonts.rb
37
+ - rails/init.rb
38
+ - test/helper.rb
39
+ - test/test_jitimage.rb
40
+ has_rdoc: true
41
+ homepage: http://github.com/flyingsaucer/jitimage
42
+ licenses: []
43
+
44
+ post_install_message:
45
+ rdoc_options:
46
+ - --charset=UTF-8
47
+ require_paths:
48
+ - lib
49
+ required_ruby_version: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - ">="
52
+ - !ruby/object:Gem::Version
53
+ version: "0"
54
+ version:
55
+ required_rubygems_version: !ruby/object:Gem::Requirement
56
+ requirements:
57
+ - - ">="
58
+ - !ruby/object:Gem::Version
59
+ version: "0"
60
+ version:
61
+ requirements: []
62
+
63
+ rubyforge_project:
64
+ rubygems_version: 1.3.5
65
+ signing_key:
66
+ specification_version: 3
67
+ summary: "Jitimage: A just-in-time image creator for pretty text headers"
68
+ test_files:
69
+ - test/helper.rb
70
+ - test/test_jitimage.rb