summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid A. Cuadrado <krawek@gmail.com>2008-04-04 16:53:54 -0500
committerDavid A. Cuadrado <krawek@gmail.com>2008-04-04 16:53:54 -0500
commit91b62bc75699f15f9ba5b0210ed7e7cff1969b95 (patch)
tree18e62ddfc51f3064a3b0252f3f3b0888226ae9fe
parent708aef7b5f4b007a17b28d7753f9be588c665b4a (diff)
parent5b9a1d6781613e3420575b3440e7ffe92cbb5c8f (diff)
downloadgitorious-mainline-outdated-91b62bc75699f15f9ba5b0210ed7e7cff1969b95.zip
gitorious-mainline-outdated-91b62bc75699f15f9ba5b0210ed7e7cff1969b95.tar.gz
gitorious-mainline-outdated-91b62bc75699f15f9ba5b0210ed7e7cff1969b95.tar.bz2
Merge branch 'master' into events
Conflicts: app/controllers/merge_requests_controller.rb app/controllers/users_controller.rb
-rw-r--r--.gitignore2
-rw-r--r--AUTHORS3
-rw-r--r--HACKING36
-rw-r--r--TODO.txt1
-rw-r--r--app/controllers/application.rb16
-rw-r--r--app/controllers/committers_controller.rb14
-rw-r--r--app/controllers/merge_requests_controller.rb22
-rw-r--r--app/controllers/users_controller.rb6
-rw-r--r--app/helpers/application_helper.rb117
-rw-r--r--app/helpers/blobs_helper.rb10
-rw-r--r--app/helpers/repositories_helper.rb14
-rw-r--r--app/helpers/trees_helper.rb2
-rw-r--r--app/models/merge_request.rb2
-rw-r--r--app/models/project.rb20
-rw-r--r--app/models/repository.rb98
-rw-r--r--app/models/user.rb4
-rw-r--r--app/views/layouts/application.html.erb4
-rw-r--r--app/views/logs/_log.html.erb14
-rw-r--r--app/views/logs/feed.atom.builder8
-rw-r--r--app/views/logs/show.html.erb10
-rw-r--r--app/views/merge_requests/show.html.erb2
-rw-r--r--app/views/projects/_project.html.erb5
-rw-r--r--app/views/projects/show.html.erb17
-rw-r--r--app/views/repositories/show.html.erb4
-rw-r--r--app/views/site/index.html.erb8
-rw-r--r--app/views/trees/show.html.erb6
-rw-r--r--app/views/users/show.html.erb6
-rw-r--r--config/initializers/ultrasphinx.rb2
-rw-r--r--config/routes.rb6
-rw-r--r--config/ultrasphinx/default.base4
-rw-r--r--db/schema.rb166
-rw-r--r--lib/gitorious/graphs/builder.rb40
-rw-r--r--lib/gitorious/graphs/commits_builder.rb54
-rw-r--r--lib/gitorious/graphs/commits_by_author_builder.rb40
-rw-r--r--public/images/default_face.gifbin0 -> 1094 bytes
-rw-r--r--public/images/default_face.pngbin5663 -> 0 bytes
-rw-r--r--public/images/overview_contributors.pngbin15491 -> 24865 bytes
-rw-r--r--public/images/overview_projects.pngbin19910 -> 33502 bytes
-rw-r--r--public/stylesheets/base.css60
-rwxr-xr-xscript/graph_generator28
-rwxr-xr-xscript/spec_server7
-rw-r--r--spec/controllers/users_controller_spec.rb8
-rw-r--r--spec/helpers/application_helper_spec.rb28
-rw-r--r--spec/models/repository_spec.rb17
-rw-r--r--vendor/plugins/googlecharts/History.txt21
-rw-r--r--vendor/plugins/googlecharts/Manifest.txt27
-rw-r--r--vendor/plugins/googlecharts/README.txt179
-rw-r--r--vendor/plugins/googlecharts/Rakefile4
-rw-r--r--vendor/plugins/googlecharts/config/hoe.rb71
-rw-r--r--vendor/plugins/googlecharts/config/requirements.rb16
-rw-r--r--vendor/plugins/googlecharts/lib/gchart.rb364
-rw-r--r--vendor/plugins/googlecharts/lib/gchart/aliases.rb14
-rw-r--r--vendor/plugins/googlecharts/lib/gchart/version.rb9
-rw-r--r--vendor/plugins/googlecharts/log/debug.log0
-rwxr-xr-xvendor/plugins/googlecharts/script/destroy14
-rwxr-xr-xvendor/plugins/googlecharts/script/generate14
-rwxr-xr-xvendor/plugins/googlecharts/script/txt2html74
-rw-r--r--vendor/plugins/googlecharts/setup.rb1585
-rw-r--r--vendor/plugins/googlecharts/spec/gchart_spec.rb277
-rw-r--r--vendor/plugins/googlecharts/spec/spec.opts1
-rw-r--r--vendor/plugins/googlecharts/spec/spec_helper.rb7
-rw-r--r--vendor/plugins/googlecharts/tasks/deployment.rake34
-rw-r--r--vendor/plugins/googlecharts/tasks/environment.rake7
-rw-r--r--vendor/plugins/googlecharts/tasks/rspec.rake21
-rw-r--r--vendor/plugins/googlecharts/tasks/website.rake17
-rw-r--r--vendor/plugins/googlecharts/website/index.html601
-rw-r--r--vendor/plugins/googlecharts/website/index.txt417
-rw-r--r--vendor/plugins/googlecharts/website/javascripts/rounded_corners_lite.inc.js285
-rw-r--r--vendor/plugins/googlecharts/website/stylesheets/screen.css138
-rw-r--r--vendor/plugins/googlecharts/website/template.rhtml53
-rw-r--r--vendor/plugins/gruff/History.txt98
-rw-r--r--vendor/plugins/gruff/MIT-LICENSE (renamed from vendor/plugins/googlecharts/License.txt)5
-rw-r--r--vendor/plugins/gruff/Manifest.txt76
-rw-r--r--vendor/plugins/gruff/README.txt40
-rw-r--r--vendor/plugins/gruff/Rakefile54
-rw-r--r--vendor/plugins/gruff/assets/bubble.pngbin0 -> 18324 bytes
-rw-r--r--vendor/plugins/gruff/assets/city_scene/background/0000.pngbin0 -> 30295 bytes
-rw-r--r--vendor/plugins/gruff/assets/city_scene/background/0600.pngbin0 -> 23109 bytes
-rw-r--r--vendor/plugins/gruff/assets/city_scene/background/2000.pngbin0 -> 30295 bytes
-rw-r--r--vendor/plugins/gruff/assets/city_scene/clouds/cloudy.pngbin0 -> 7598 bytes
-rw-r--r--vendor/plugins/gruff/assets/city_scene/clouds/partly_cloudy.pngbin0 -> 7269 bytes
-rw-r--r--vendor/plugins/gruff/assets/city_scene/clouds/stormy.pngbin0 -> 7311 bytes
-rw-r--r--vendor/plugins/gruff/assets/city_scene/grass/default.pngbin0 -> 6250 bytes
-rw-r--r--vendor/plugins/gruff/assets/city_scene/haze/true.pngbin0 -> 21943 bytes
-rw-r--r--vendor/plugins/gruff/assets/city_scene/number_sample/1.pngbin0 -> 2092 bytes
-rw-r--r--vendor/plugins/gruff/assets/city_scene/number_sample/2.pngbin0 -> 2087 bytes
-rw-r--r--vendor/plugins/gruff/assets/city_scene/number_sample/default.pngbin0 -> 2083 bytes
-rw-r--r--vendor/plugins/gruff/assets/city_scene/sky/0000.pngbin0 -> 2092 bytes
-rw-r--r--vendor/plugins/gruff/assets/city_scene/sky/0200.pngbin0 -> 2087 bytes
-rw-r--r--vendor/plugins/gruff/assets/city_scene/sky/0400.pngbin0 -> 2083 bytes
-rw-r--r--vendor/plugins/gruff/assets/city_scene/sky/0600.pngbin0 -> 2430 bytes
-rw-r--r--vendor/plugins/gruff/assets/city_scene/sky/0800.pngbin0 -> 2421 bytes
-rw-r--r--vendor/plugins/gruff/assets/city_scene/sky/1000.pngbin0 -> 2427 bytes
-rw-r--r--vendor/plugins/gruff/assets/city_scene/sky/1200.pngbin0 -> 2431 bytes
-rw-r--r--vendor/plugins/gruff/assets/city_scene/sky/1400.pngbin0 -> 2432 bytes
-rw-r--r--vendor/plugins/gruff/assets/city_scene/sky/1500.pngbin0 -> 2426 bytes
-rw-r--r--vendor/plugins/gruff/assets/city_scene/sky/1700.pngbin0 -> 2425 bytes
-rw-r--r--vendor/plugins/gruff/assets/city_scene/sky/2000.pngbin0 -> 2089 bytes
-rw-r--r--vendor/plugins/gruff/assets/pc306715.jpgbin0 -> 79771 bytes
-rw-r--r--vendor/plugins/gruff/assets/plastik/blue.pngbin0 -> 5075 bytes
-rw-r--r--vendor/plugins/gruff/assets/plastik/green.pngbin0 -> 5080 bytes
-rw-r--r--vendor/plugins/gruff/assets/plastik/red.pngbin0 -> 5078 bytes
-rw-r--r--vendor/plugins/gruff/init.rb2
-rw-r--r--vendor/plugins/gruff/lib/gruff.rb27
-rw-r--r--vendor/plugins/gruff/lib/gruff/accumulator_bar.rb27
-rw-r--r--vendor/plugins/gruff/lib/gruff/area.rb58
-rw-r--r--vendor/plugins/gruff/lib/gruff/bar.rb83
-rw-r--r--vendor/plugins/gruff/lib/gruff/bar_conversion.rb46
-rw-r--r--vendor/plugins/gruff/lib/gruff/base.rb1073
-rw-r--r--vendor/plugins/gruff/lib/gruff/bullet.rb109
-rw-r--r--vendor/plugins/gruff/lib/gruff/deprecated.rb39
-rw-r--r--vendor/plugins/gruff/lib/gruff/line.rb105
-rw-r--r--vendor/plugins/gruff/lib/gruff/mini/bar.rb32
-rw-r--r--vendor/plugins/gruff/lib/gruff/mini/legend.rb77
-rw-r--r--vendor/plugins/gruff/lib/gruff/mini/pie.rb36
-rw-r--r--vendor/plugins/gruff/lib/gruff/mini/side_bar.rb35
-rw-r--r--vendor/plugins/gruff/lib/gruff/net.rb142
-rw-r--r--vendor/plugins/gruff/lib/gruff/photo_bar.rb100
-rw-r--r--vendor/plugins/gruff/lib/gruff/pie.rb124
-rw-r--r--vendor/plugins/gruff/lib/gruff/scene.rb209
-rw-r--r--vendor/plugins/gruff/lib/gruff/side_bar.rb114
-rw-r--r--vendor/plugins/gruff/lib/gruff/side_stacked_bar.rb73
-rw-r--r--vendor/plugins/gruff/lib/gruff/spider.rb130
-rw-r--r--vendor/plugins/gruff/lib/gruff/stacked_area.rb66
-rw-r--r--vendor/plugins/gruff/lib/gruff/stacked_bar.rb53
-rw-r--r--vendor/plugins/gruff/lib/gruff/stacked_mixin.rb23
-rw-r--r--vendor/plugins/gruff/rails_generators/gruff/gruff_generator.rb63
-rw-r--r--vendor/plugins/gruff/rails_generators/gruff/templates/controller.rb32
-rw-r--r--vendor/plugins/gruff/rails_generators/gruff/templates/functional_test.rb24
-rw-r--r--vendor/plugins/gruff/test/gruff_test_case.rb123
-rw-r--r--vendor/plugins/gruff/test/test_accumulator_bar.rb50
-rw-r--r--vendor/plugins/gruff/test/test_area.rb134
-rw-r--r--vendor/plugins/gruff/test/test_bar.rb283
-rw-r--r--vendor/plugins/gruff/test/test_base.rb8
-rw-r--r--vendor/plugins/gruff/test/test_bullet.rb26
-rw-r--r--vendor/plugins/gruff/test/test_legend.rb71
-rw-r--r--vendor/plugins/gruff/test/test_line.rb513
-rw-r--r--vendor/plugins/gruff/test/test_mini_bar.rb32
-rw-r--r--vendor/plugins/gruff/test/test_mini_pie.rb20
-rw-r--r--vendor/plugins/gruff/test/test_mini_side_bar.rb37
-rw-r--r--vendor/plugins/gruff/test/test_net.rb230
-rw-r--r--vendor/plugins/gruff/test/test_photo.rb41
-rw-r--r--vendor/plugins/gruff/test/test_pie.rb154
-rw-r--r--vendor/plugins/gruff/test/test_scene.rb100
-rw-r--r--vendor/plugins/gruff/test/test_side_bar.rb12
-rw-r--r--vendor/plugins/gruff/test/test_sidestacked_bar.rb89
-rw-r--r--vendor/plugins/gruff/test/test_spider.rb216
-rw-r--r--vendor/plugins/gruff/test/test_stacked_bar.rb52
-rw-r--r--vendor/plugins/ultrasphinx/lib/ultrasphinx/ultrasphinx.rb5
149 files changed, 5909 insertions, 4623 deletions
diff --git a/.gitignore b/.gitignore
index 354937d..0eeee4b 100644
--- a/.gitignore
+++ b/.gitignore
@@ -2,6 +2,7 @@
.DS_Store
coverage/*
public/cache/*
+public/images/graphs/*
config/database.yml
config/gitorious.yml
config/ultrasphinx/development.conf
@@ -9,5 +10,6 @@ config/ultrasphinx/test.conf
config/ultrasphinx/production.conf
config/ultrasphinx/staging.conf
db/schema.rb
+db/*.sqlite3
.autotest
db/sphinx/*
diff --git a/AUTHORS b/AUTHORS
index 11cd0c8..ccd5510 100644
--- a/AUTHORS
+++ b/AUTHORS
@@ -12,9 +12,10 @@ Contributors
-------------
A number of people have contributed directly to Gitorious by writing documentation
-or developing code. A list of these people in alphabetical order is included
+or developing code and/or graphics. A list of these people in alphabetical order is included
below:
* David A. Cuadrado <krawek@gmail.com>
* August Lilleaas <augustlilleaas@gmail.com>
+ * Simon Bohlin <simon.bohlin@zondera.com>
\ No newline at end of file
diff --git a/HACKING b/HACKING
index 9ce36c2..21ee9e1 100644
--- a/HACKING
+++ b/HACKING
@@ -2,12 +2,23 @@
=== Dependencies
-* bluecloth (http://rubyforge.org/projects/bluecloth/)
+Ruby libraries/bindings/gems
+
+* BlueCloth (http://rubyforge.org/projects/bluecloth/)
* mime-types (http://rubyforge.org/projects/mime-types)
* oniguruma (http://rubyforge.org/projects/oniguruma)
-** requires the oniguruma C library: (http://www.geocities.jp/kosako3/oniguruma/)
* textpow (http://rubyforge.org/projects/textpow)
-* chronic
+* chronic (http://rubyforge.org/projects/chronic)
+* rmagick (http://rubyforge.org/projects/rmagick)
+
+Libraries/applications:
+
+* Git (http://git-scm.org)
+* Oniguruma C library (http://www.geocities.jp/kosako3/oniguruma/)
+* Sphinx (http://sphinxsearch.com/)
+
+(App is deployed on mysql, allthough source should be free of mysql-isms/quirks)
+
=== The Hackers digest guide:
@@ -23,3 +34,22 @@
Consult the mailinglist (http://groups.google.com/group/gitorious) or drop in
by #gitorious on irc.freenode.net if you have questions.
+
+
+=== Tasks and other scripts
+
+* script/task_performer runs any tasks in the queue (creating repositories etc)
+* script/graph_generator generates graph.
+* rake ultrasphinx:index runs the search indexer
+
+
+=== Coding style
+
+* Two spaces, no tabs, for indention
+* Don't use and and or for boolean tests, instead always use && and ||
+* MyClass.my_method(my_arg) -- not my_method( my_arg ) or my_method my_arg
+* Unless presedence is an issue; do .. end for multi-line blocks, braces for single line blocks
+* Follow the conventions you see used in the source already
+
+(copied mostly verbatim from dev.rubyonrails.org)
+
diff --git a/TODO.txt b/TODO.txt
index 8d829b1..987ad27 100644
--- a/TODO.txt
+++ b/TODO.txt
@@ -1,5 +1,6 @@
(in no particular order)
+* Get rid of the non-libre google graphs in favor of locally-generated ones (though NOT by the rails app)
* Make the fact that you _can_ clone/fork any repo more visible, maybe reword it since people confuse it with local cloning
* Update the HACKING with some basic coding guidelines
* Show the most recent mergerequests on users dashboard so they can track them
diff --git a/app/controllers/application.rb b/app/controllers/application.rb
index ad6b6d7..d3401ad 100644
--- a/app/controllers/application.rb
+++ b/app/controllers/application.rb
@@ -7,7 +7,21 @@ class ApplicationController < ActionController::Base
include ExceptionNotifiable
rescue_from ActiveRecord::RecordNotFound, :with => :render_not_found
- rescue_from ActionController::RoutingError, :with => :render_not_found
+ rescue_from ActionController::UnknownController, :with => :render_not_found
+ rescue_from ActionController::UnknownAction, :with => :render_not_found
+
+ def rescue_action(exception)
+ return super if RAILS_ENV != "production"
+
+ case exception
+ # Can't catch RoutingError with rescue_from it seems,
+ # so do it the old-fashioned way
+ when ActionController::RoutingError
+ render_not_found
+ else
+ super
+ end
+ end
protected
def require_user_has_ssh_keys
diff --git a/app/controllers/committers_controller.rb b/app/controllers/committers_controller.rb
index 9f7f7ca..028e4c4 100644
--- a/app/controllers/committers_controller.rb
+++ b/app/controllers/committers_controller.rb
@@ -1,8 +1,8 @@
class CommittersController < ApplicationController
- before_filter :login_required, :only => [:new, :create, :destroy]
+ before_filter :login_required, :only => [:new, :create, :destroy, :list]
before_filter :find_project
before_filter :find_repository,
- :only => [:show, :new, :create, :edit, :update, :destroy]
+ :only => [:show, :new, :create, :edit, :update, :destroy, :list]
def new
@committer = User.new
@@ -24,8 +24,7 @@ class CommittersController < ApplicationController
Event.from_action_name("add committer", current_user, @repository, @committer.id)
format.html { redirect_to([@repository.project, @repository]) }
format.xml do
- render :nothing, :status => :created,
- :location => project_repository_path(@repository.project, @repository)
+ render :xml => @committer
end
else
flash[:error] = "Could not add user or user is already a committer"
@@ -54,6 +53,13 @@ class CommittersController < ApplicationController
end
end
+ def list
+ @committers = @repository.committers
+ respond_to do |format|
+ format.xml { render :xml => @committers }
+ end
+ end
+
def auto_complete_for_user_login
login = params[:user][:login]
@users = User.find(:all,
diff --git a/app/controllers/merge_requests_controller.rb b/app/controllers/merge_requests_controller.rb
index c69e0e0..09bb9a9 100644
--- a/app/controllers/merge_requests_controller.rb
+++ b/app/controllers/merge_requests_controller.rb
@@ -26,13 +26,21 @@ class MergeRequestsController < ApplicationController
def create
@merge_request = @repository.proposed_merge_requests.new(params[:merge_request])
@merge_request.user = current_user
- if @merge_request.save
- Event.from_action_name("request merge", current_user, @repository, @merge_request.id)
- flash[:success] = %Q{You sent a merge request to "#{@merge_request.target_repository.name}"}
- redirect_to project_repository_path(@project, @repository) and return
- else
- @repositories = @project.repositories.find(:all, :conditions => ["id != ?", @repository.id])
- render :action => "new"
+ respond_to do |format|
+ if @merge_request.save
+ Event.from_action_name("request merge", current_user, @repository, @merge_request.id)
+ format.html {
+ flash[:success] = %Q{You sent a merge request to "#{@merge_request.target_repository.name}"}
+ redirect_to project_repository_path(@project, @repository) and return
+ }
+ format.xml { render :xml => @merge_request, :status => :created }
+ else
+ format.html {
+ @repositories = @project.repositories.find(:all, :conditions => ["id != ?", @repository.id])
+ render :action => "new"
+ }
+ format.xml { render :xml => @merge_request.errors, :status => :unprocessable_entity }
+ end
end
end
diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb
index c9b95d9..a760699 100644
--- a/app/controllers/users_controller.rb
+++ b/app/controllers/users_controller.rb
@@ -8,6 +8,11 @@ class UsersController < ApplicationController
@projects = @user.projects.find(:all, :include => [:tags, { :repositories => :project }])
@repositories = @user.repositories.find(:all, :conditions => ["mainline = ?", false])
@events = @user.events.find(:all, :order => "events.date asc", :include => [:action, :user, {:repository => :project}])
+
+ @commits_last_week = 0
+ @projects.map{|p| p.repositories.first }.concat(@repositories).each do |repo|
+ @commits_last_week += repo.count_commits_from_last_week_by_user(@user)
+ end
end
def create
@@ -32,5 +37,4 @@ class UsersController < ApplicationController
end
redirect_back_or_default('/')
end
-
end
diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb
index c2a56d6..d531cdb 100644
--- a/app/helpers/application_helper.rb
+++ b/app/helpers/application_helper.rb
@@ -28,8 +28,14 @@ module ApplicationHelper
end
end
- def selected_if_current_page(url_options)
- "selected" if current_page?(url_options)
+ def selected_if_current_page(url_options, slack = false)
+ if slack
+ if controller.request.request_uri.index(CGI.escapeHTML(url_for(url_options))) == 0
+ "selected"
+ end
+ else
+ "selected" if current_page?(url_options)
+ end
end
def link_to_with_selected(name, options = {}, html_options = nil)
@@ -57,8 +63,11 @@ module ApplicationHelper
end
def gravatar_url_for(email, options = {})
- default = "http://#{GitoriousConfig['gitorious_host']}/images/default_face.png"
- "http://www.gravatar.com/avatar.php?default=#{default}&amp;gravatar_id=#{Digest::MD5.hexdigest(email)}#{options.map { |k,v| "&amp;#{k}=#{v}" }.join}"
+ "http://www.gravatar.com/avatar.php?gravatar_id=" <<
+ Digest::MD5.hexdigest(email) <<
+ "&amp;default=" <<
+ u("http://#{request.host}:#{request.port}/images/default_face.gif") <<
+ options.map { |k,v| "&amp;#{k}=#{v}" }.join
end
def gravatar(email, options = {})
@@ -70,98 +79,26 @@ module ApplicationHelper
image_tag(gravatar_url_for(email, options), image_options)
end
+ def gravatar_frame(email, options = {})
+ extra_css_class = options[:style] ? " gravatar_#{options[:style]}" : ""
+ %{<div class="gravatar#{extra_css_class}">#{gravatar(email, options)}</div>}
+ end
+
def flashes
flash.map { |type, content| content_tag(:div, content_tag(:p, content), :class => "flash_message #{type}")}
end
- def commit_graph_tag(project, sha = "master", width = 250, height = 150)
- repo = project.repositories.first
- git_repo = repo.git
- git = git_repo.git
-
- h = Hash.new
- dategroup = Date.new
-
- data = git.rev_list({:pretty => "format:%at", :since => "24 weeks ago"}, sha)
- rx = /^\d/.freeze
- data.each_line { |line|
- if line =~ rx then
- date = Time.at(line.to_i)
-
- dategroup = Date.new(date.year, date.month, 1)
- if h[dategroup]
- h[dategroup] += 1
- else
- h[dategroup] = 1
- end
- end
- }
-
- commits = []
- labels = []
-
- h.each { |entry|
- date = entry.first
- value = entry.last
-
- labels << date.strftime("%m/%y")
- commits << value
- }
-
- Gchart.line(:data => commits, :labels => labels, :width => width, :height => height, :bg => "efefef", :format => "img_tag")
+ def commit_graph_tag(repository, ref = "master")
+ filename = "#{repository.project.slug}_#{repository.name}_#{h(ref)}_commit_count.png"
+ if File.exist?(File.join(Gitorious::Graphs::Builder.graph_dir, filename))
+ image_tag("graphs/#{filename}")
+ end
end
- def commit_graph_by_author_tag(project, sha = "master", width = 400, height = 200)
- repo = project.repositories.first
- git_repo = repo.git
- git = git_repo.git
-
- h = Hash.new
-
- data = git.rev_list({:pretty => "format:name:%cn", :since => "1 years ago" }, sha)
- data.each_line { |line|
- if line =~ /^name:(.*)$/ then
- author = $1
-
- if h[author]
- h[author] += 1
- else
- h[author] = 1
- end
- end
- }
-
- sorted = h.sort_by { |author, commits|
- commits
- }
-
- labels = []
- data = []
-
- max = 5
- others = []
- top = sorted
-
-
- if sorted.size > max
- top = sorted[sorted.size-max, sorted.size]
- others = sorted[0, sorted.size-max]
- end
-
- top.each { |entry|
- author = entry.first
- v = entry.last
-
- data << v
- labels << author
- }
-
- unless others.empty?
- others_v = others.inject { |v, acum| [v.last + acum.last] }
- labels << "others"
- data << others_v.last
+ def commit_graph_by_author_tag(repository, ref = "master")
+ filename = "#{repository.project.slug}_#{repository.name}_#{h(ref)}_commit_count_by_author.png"
+ if File.exist?(File.join(Gitorious::Graphs::Builder.graph_dir, filename))
+ image_tag("graphs/#{filename}")
end
-
- Gchart.pie(:data => data, :labels => labels, :width => width, :height => height, :bg => "efefef", :format => "img_tag" )
end
end
diff --git a/app/helpers/blobs_helper.rb b/app/helpers/blobs_helper.rb
index 34e6c05..64c2687 100644
--- a/app/helpers/blobs_helper.rb
+++ b/app/helpers/blobs_helper.rb
@@ -21,7 +21,15 @@ module BlobsHelper
def render_highlighted(text, filename, theme = "idle")
syntax_name = Uv.syntax_names_for_data(filename, text).first #TODO: render a choice select box if > 1
- highlighted = Uv.parse(text, "xhtml", syntax_name, false, theme)
+ begin
+ highlighted = Uv.parse(text, "xhtml", syntax_name, false, theme)
+ rescue => e
+ if e.to_s =~ /Oniguruma Error/
+ highlighted = text
+ else
+ raise e
+ end
+ end
line_numbers_for(highlighted, theme)
end
diff --git a/app/helpers/repositories_helper.rb b/app/helpers/repositories_helper.rb
index b2bd8a7..96fdb9d 100644
--- a/app/helpers/repositories_helper.rb
+++ b/app/helpers/repositories_helper.rb
@@ -1,16 +1,4 @@
-module RepositoriesHelper
- # Returns a Hash {email => user}
- def self.users_by_commits(commits)
- emails = commits.map { |commit| commit.committer.email }
- users = User.find(:all, :conditions => ["email in (?)", emails])
- email_user = {}
- users.each { |user|
- email_user[user.email] = user
- }
-
- email_user
- end
-
+module RepositoriesHelper
def log_path(objectish = "master", options = {})
if options.blank? # just to avoid the ? being tacked onto the url
project_repository_log_path(@project, @repository, objectish)
diff --git a/app/helpers/trees_helper.rb b/app/helpers/trees_helper.rb
index d5b522b..57da3e3 100644
--- a/app/helpers/trees_helper.rb
+++ b/app/helpers/trees_helper.rb
@@ -9,7 +9,7 @@ module TreesHelper
current_path << path
end
- def breadcrumb_path(root_name = "root", commit_id = params[:sha])
+ def breadcrumb_path(root_name = "root", commit_id = params[:id])
out = %Q{<ul class="path_breadcrumbs">\n}
visited_path = []
out << %Q{ <li>/ #{link_to(root_name, tree_path(commit_id, []))}</li>\n}
diff --git a/app/models/merge_request.rb b/app/models/merge_request.rb
index b226b45..78c2586 100644
--- a/app/models/merge_request.rb
+++ b/app/models/merge_request.rb
@@ -7,7 +7,7 @@ class MergeRequest < ActiveRecord::Base
:association_name => "user",
:field => "login",
:as => "proposed_by"
- }]
+ }], :conditions => "status = 0"
attr_protected :user_id, :status
diff --git a/app/models/project.rb b/app/models/project.rb
index 181d161..854d8b2 100644
--- a/app/models/project.rb
+++ b/app/models/project.rb
@@ -49,7 +49,7 @@ class Project < ActiveRecord::Base
'Ruby License',
'GNU General Public License version 2(GPLv2)',
'GNU General Public License version 3 (GPLv3)',
- 'GNU Library Public License (LGPL)',
+ 'GNU Lesser General Public License (LGPL)',
'Mozilla Public License 1.0 (MPL)',
'Mozilla Public License 1.1 (MPL 1.1)',
'Qt Public License (QPL)',
@@ -101,6 +101,24 @@ class Project < ActiveRecord::Base
# sanitizer.sanitize(description, :tags => %w(str), :attributes => %w(class))
end
+ def to_xml(opts = {})
+ info = Proc.new { |options|
+ builder = options[:builder]
+ builder.owner user.login
+
+ builder.repositories :type => "array" do
+ repositories.each { |repo|
+ builder.repository do
+ builder.id repo.id
+ builder.name repo.name
+ builder.owner repo.user.login
+ end
+ }
+ end
+ }
+ super({:procs => [info]}.merge(opts))
+ end
+
protected
def create_mainline_repository
self.repositories.create!(:user => self.user, :name => "mainline")
diff --git a/app/models/repository.rb b/app/models/repository.rb
index 154feea..43c11e0 100644
--- a/app/models/repository.rb
+++ b/app/models/repository.rb
@@ -89,8 +89,8 @@ class Repository < ActiveRecord::Base
name
end
- def to_xml
- super(:methods => [:gitdir, :clone_url, :push_url])
+ def to_xml(opts = {})
+ super({:methods => [:gitdir, :clone_url, :push_url]}.merge(opts))
end
def add_committer(user)
@@ -134,6 +134,100 @@ class Repository < ActiveRecord::Base
commits = WillPaginate::Collection.new(page, per_page, total)
commits.replace git.commits(tree_name, per_page, offset)
end
+
+ def count_commits_from_last_week_by_user(user)
+ return 0 unless has_commits?
+
+ commits_by_email = git.commits_since("master", "last week").collect do |commit|
+ commit.committer.email == user.email
+ end
+ commits_by_email.size
+ end
+
+ # TODO: cache
+ def commit_graph_data(head = "master")
+ commits = git.commits_since(head, "24 weeks ago")
+ commits_by_week = commits.group_by{|c| c.committed_date.strftime("%W") }
+
+ # build an initial empty set of 24 week commit data
+ weeks = [1.day.from_now-1.week]
+ 23.times{|w| weeks << weeks.last-1.week }
+ week_numbers = weeks.map{|d| d.strftime("%W") }
+ commits = (0...24).to_a.map{|i| 0 }
+
+ commits_by_week.each do |week, commits_in_week|
+ if week_pos = week_numbers.index(week)
+ commits[week_pos+1] = commits_in_week.size
+ end
+ end
+ commits = [] if commits.max == 0
+ [week_numbers.reverse, commits.reverse]
+ end
+
+ # TODO: refactor into simpler approach
+ # TODO: caching
+ def commit_graph_data_by_author(head = "master")
+ h = Hash.new
+
+ data = self.git.git.rev_list({:pretty => "format:name:%cn", :since => "1 years ago" }, head)
+ data.each_line do |line|
+ if line =~ /^name:(.*)$/ then
+ author = $1
+
+ if h[author]
+ h[author] += 1
+ else
+ h[author] = 1
+ end
+ end
+ end
+
+ sorted = h.sort_by do |author, commits|
+ commits
+ end
+
+ labels = []
+ data = []
+
+ max = 8
+ others = []
+ top = sorted
+
+
+ if sorted.size > max
+ top = sorted[sorted.size-max, sorted.size]
+ others = sorted[0, sorted.size-max]
+ end
+
+ top.each do |entry|
+ author = entry.first
+ v = entry.last
+
+ data << v
+ labels << author
+ end
+
+ unless others.empty?
+ others_v = others.inject { |v, acum| [v.last + acum.last] }
+ labels << "others"
+ data << others_v.last
+ end
+
+ #[labels, data]
+ labels.inject({}) do |hash, label|
+ hash[label] = data[labels.index(label)]
+ hash
+ end
+ end
+
+ # Returns a Hash {email => user}, where email is selected from the +commits+
+ def users_by_commits(commits)
+ emails = commits.map { |commit| commit.committer.email }.uniq
+ users = User.find(:all, :conditions => ["email in (?)", emails])
+
+ users_by_email = users.inject({}){|hash, user| hash[user.email] = user; hash }
+ users_by_email
+ end
protected
def set_as_mainline_if_first
diff --git a/app/models/user.rb b/app/models/user.rb
index da8adfe..6f92991 100644
--- a/app/models/user.rb
+++ b/app/models/user.rb
@@ -101,6 +101,10 @@ class User < ActiveRecord::Base
def to_param
login
end
+
+ def to_xml(opts = {})
+ super({:except => [:activation_code, :crypted_password, :remember_token, :remember_token_expires_at, :salt, :ssh_key_id]}.merge(opts))
+ end
protected
# before filter
diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb
index c2ab2bd..22d7149 100644
--- a/app/views/layouts/application.html.erb
+++ b/app/views/layouts/application.html.erb
@@ -57,11 +57,11 @@
<li class="<%= selected_if_current_page(project_repository_path(@project, @repository)) -%>">
<%= link_to "#{h(@repository.name)} repository", project_repository_path(@project, @repository) -%>
</li>
- <li class="<%= selected_if_current_page(project_repository_logs_path(@project, @repository)) -%>">
+ <li class="<%= selected_if_current_page(project_repository_logs_path(@project, @repository), slack=true) -%>">
<%= link_to "Commits", project_repository_logs_path(@project, @repository) -%>
</li>
<% if @repository.head_candidate -%>
- <li class="<%= selected_if_current_page(project_repository_tree_path(@project, @repository, @repository.head_candidate.name)) -%>">
+ <li class="<%= selected_if_current_page(project_repository_tree_path(@project, @repository, @repository.head_candidate.name), slack=true) -%>">
<%= link_to "Source Tree", project_repository_tree_path(@project, @repository, @repository.head_candidate.name) -%>
</li>
<% end -%>
diff --git a/app/views/logs/_log.html.erb b/app/views/logs/_log.html.erb
index e79a579..f790de9 100644
--- a/app/views/logs/_log.html.erb
+++ b/app/views/logs/_log.html.erb
@@ -1,16 +1,16 @@
-<% email_user = RepositoriesHelper.users_by_commits(@commits) %>
-<ul>
+<% users_by_email = @repository.users_by_commits(@commits) %>
+<ul class="commit_list">
<% @commits.each do |commit| -%>
-<% user = email_user[commit.committer.email] %>
+<% user = users_by_email[commit.committer.email] %>
<li class="commit_item">
<div>
<a href=""><%= link_to h(commit.id_abbrev),
project_repository_commit_path(@project, @repository, commit.id) -%></a>
- by <strong><%=h commit.committer.name -%></strong><small> <%= user ? "[#{link_to user.login, user_path(user)}]" : "" -%></small> <%=h time_ago_in_words(commit.committed_date) -%> ago
+ by <strong><%= user ? link_to(user.login, user_path(user)) : h(commit.committer.name) -%></strong> <%=h time_ago_in_words(commit.committed_date) -%> ago
</div>
- <div style="float: left; width: 5%;"> <%= gravatar(commit.committer.email, :size => 32) %></div>
- <div class="commit_message"> <%= simple_format(h(commit.message)) -%></div>
-
+ <%= gravatar_frame(commit.committer.email, :size => 32) %>
+ <div class="commit_message"> <%= link_to simple_format(h(commit.short_message)), project_repository_commit_path(@project, @repository, commit.id) -%></div>
+ <div class="clear_left"></div>
</li>
<% end -%>
</ul>
diff --git a/app/views/logs/feed.atom.builder b/app/views/logs/feed.atom.builder
index da4a39d..f434165 100644
--- a/app/views/logs/feed.atom.builder
+++ b/app/views/logs/feed.atom.builder
@@ -14,17 +14,15 @@ atom_feed do |feed|
}) do |entry|
entry.title(truncate(commit.message, 75))
entry.content(<<-EOS, :type => 'html')
-<h1>In #{@repository.gitdir}</h1>
+<h1>In #{@repository.gitdir} #{params[:id]}</h1>
<pre>
-#{@repository.name}:#{params[:id]} in #{@project.title}
+#{word_wrap commit.message}
+
Date: #{commit.committed_date.strftime("%Y-%m-%d %H:%M")}
Author: #{commit.author.name}
Committer: #{commit.committer.name}
-#{word_wrap commit.message}
-
-
#{commit.stats.total[:lines]} lines changed in #{commit.stats.total[:files]} files:
------------------------------------------------------------------------------
adds dels file
diff --git a/app/views/logs/show.html.erb b/app/views/logs/show.html.erb
index 6f9dfe7..8357fb3 100644
--- a/app/views/logs/show.html.erb
+++ b/app/views/logs/show.html.erb
@@ -9,10 +9,14 @@
<% unless @commits.blank? -%>
<li><strong>HEAD tree:</strong> <%= link_to h(@commits.first.tree.id),
tree_path(@commits.first.id) -%></li>
- <li><%= commit_graph_by_author_tag(@project) %></li>
<% end -%>
</ul>
+<% if @commits.current_page == 1 -%>
+ <div class="commits_by_author_graph">
+ <%= commit_graph_by_author_tag(@repository, params[:id]) %>
+ </div>
+<% end -%>
<h2>Commits in "<%=h params[:id] -%>"</h2>
<%= render :partial => "log" -%>
<%= will_paginate @commits %>
@@ -20,14 +24,14 @@
<% content_for :sidebar do -%>
<h5>Branches:</h5>
<ul class="links">
- <% @git.branches.each do |branch| -%>
+ <% @git.branches.sort{|a, b| a.name <=> b.name }.each do |branch| -%>
<li><%= link_to h(branch.name), log_path(branch.name) -%></li>
<% end -%>
</ul>
<h5>Tags:</h5>
<ul class="links">
- <% @git.tags.each do |tag| -%>
+ <% @git.tags.sort{|a, b| a.name <=> b.name }.each do |tag| -%>
<li><%= link_to h(tag.name), commit_path(tag.commit.id) -%></li>
<% end -%>
</ul>
diff --git a/app/views/merge_requests/show.html.erb b/app/views/merge_requests/show.html.erb
index d7f67e1..bfaafe8 100644
--- a/app/views/merge_requests/show.html.erb
+++ b/app/views/merge_requests/show.html.erb
@@ -17,7 +17,7 @@
<% if @merge_request.open? -%>
<p>The simplest way to merge in these changes is to simply pull them in with the following command:</p>
- <pre>git pull <%= @merge_request.source_repository.clone_url -%></pre>
+ <pre>git pull <%= @merge_request.source_repository.clone_url -%> <%= @merge_request.source_branch -%></pre>
<% end -%>
<% end -%>
diff --git a/app/views/projects/_project.html.erb b/app/views/projects/_project.html.erb
index a6f3183..31a4d12 100644
--- a/app/views/projects/_project.html.erb
+++ b/app/views/projects/_project.html.erb
@@ -1,8 +1,5 @@
-<h3><%= link_to project.title, project_path(project) -%></h3>
+<h3><%= link_to h(project.title), project_path(project) -%></h3>
<p><%= truncate h(project.stripped_description), 250 -%></p>
-<% if project.repositories.first.has_commits? %>
- <div><%= commit_graph_tag(project) %></div>
-<% end -%>
<p class="hint">
<strong>Categories:</strong>
<%= project.tag_list.blank? ? "none" : linked_tag_list_as_sentence(project.tags) -%>
diff --git a/app/views/projects/show.html.erb b/app/views/projects/show.html.erb
index 65adc51..1e7fe4f 100644
--- a/app/views/projects/show.html.erb
+++ b/app/views/projects/show.html.erb
@@ -20,9 +20,6 @@
<li><strong>Bugtracker at </strong>
<%= link_to base_url(@project.bugtracker_url), h(@project.bugtracker_url) -%></li>
<% end -%>
- <% if @repositories.first.has_commits? %>
- <li><%= commit_graph_tag(@project) %></li>
- <% end -%>
</ul>
</div>
@@ -36,21 +33,18 @@
<th>Name</th>
<th>Owner</th>
<th>Last Commit</th>
- <th>Commiter</th>
<th></th>
<th></th>
</thead>
- <% commits = [] %>
+ <% commits = [] -%>
<% repositories = @repositories.sort_by { |e| if e.last_commit then commits << e.last_commit; e.mainline? ? Time.now : e.last_commit.committed_date; else Time.at(0); end } %>
- <% email_user = RepositoriesHelper.users_by_commits(commits) %>
<% repositories.reverse_each do |repos| # FIXME: need to graph the parent relation proper -%>
- <% user = email_user[repos.last_commit.committer.email] if repos.has_commits? %>
<tr class="<%= cycle("even", "odd") -%> <%= repos.mainline? ? "mainline" : "clone" -%>">
<td class="name">
<%= link_to h(repos.name), project_repository_path(@project, repos) -%>
</td>
<td>
- <%= gravatar(repos.user.email, :size => 16) %>
+ <%= gravatar_frame(repos.user.email, :size => 16, :style => "tiny") %>
<%= link_to h(repos.user.login), user_path(repos.user) -%>
</td>
<td>
@@ -61,13 +55,6 @@
<em>none</em>
<% end -%>
</td>
- <td>
- <% if user.nil? %>
- <%= repos.last_commit.committer.name if repos.has_commits? %>
- <% else %>
- <%= link_to(user.login, user_path(user)) %>
- <% end -%>
- </td>
<td><%= link_to "commits", project_repository_logs_path(@project, repos) -%></td>
<td><%= link_to "tree", project_repository_trees_path(@project, repos) -%></td>
</tr>
diff --git a/app/views/repositories/show.html.erb b/app/views/repositories/show.html.erb
index 6bf2dd0..d2496ff 100644
--- a/app/views/repositories/show.html.erb
+++ b/app/views/repositories/show.html.erb
@@ -7,6 +7,10 @@
<%= render :partial => "infobox" -%>
+ <div class="commit_graph">
+ <%= commit_graph_tag(@repository) %>
+ </div>
+
<ul class="tab_menu">
<li class="selected">Recent commits</li>
<li><%= link_to "comments (#{@comment_count})",
diff --git a/app/views/site/index.html.erb b/app/views/site/index.html.erb
index 23a0bda..ed91dcc 100644
--- a/app/views/site/index.html.erb
+++ b/app/views/site/index.html.erb
@@ -11,12 +11,12 @@
<% unless logged_in? -%>
<table>
<tr>
- <th><h2>For Projects</h2></th>
- <th><h2>For Contributors</h2></th>
+ <th class="left"><h2>For Projects</h2></th>
+ <th class="right"><h2>For Contributors</h2></th>
</tr>
<tr>
- <td><%= image_tag("overview_projects.png") -%></td>
- <td><%= image_tag("overview_contributors.png") -%></td>
+ <td class="left"><%= image_tag("overview_projects.png") -%></td>
+ <td class="right"><%= image_tag("overview_contributors.png") -%></td>
</tr>
</table>
diff --git a/app/views/trees/show.html.erb b/app/views/trees/show.html.erb
index 6b5e094..3d9b88c 100644
--- a/app/views/trees/show.html.erb
+++ b/app/views/trees/show.html.erb
@@ -3,7 +3,7 @@
Tree of <%= h(@repository.name) -%> repository in <%= h(@project.title) -%>
</h1>
-<%= breadcrumb_path(@repository.name, @commit.id) -%>
+<%= breadcrumb_path(@repository.name) -%>
<% cache(tree_path(@commit.id, params[:path])) do -%>
<table class="listing tree">
@@ -32,14 +32,14 @@
<% content_for :sidebar do -%>
<h5>Branches:</h5>
<ul class="links">
- <% @git.branches.each do |branch| -%>
+ <% @git.branches.sort{|a, b| a.name <=> b.name }.each do |branch| -%>
<li><%= link_to h(branch.name), tree_path(branch.name) -%></li>
<% end -%>
</ul>
<h5>Tags:</h5>
<ul class="links">
- <% @git.tags.each do |tag| -%>
+ <% @git.tags.sort{|a, b| a.name <=> b.name }.each do |tag| -%>
<li><%= link_to h(tag.name), commit_path(tag.commit.id) -%></li>
<% end -%>
</ul>
diff --git a/app/views/users/show.html.erb b/app/views/users/show.html.erb
index 3903fc8..489febd 100644
--- a/app/views/users/show.html.erb
+++ b/app/views/users/show.html.erb
@@ -9,12 +9,14 @@
<div style="float: right;"><%= link_to(gravatar(@user.email, { :size => 80 }), :action => "show") %></div>
<ul>
<li><strong>Email:</strong> <%= encoded_mail_to(@user.email) -%></li>
- <li><strong>Url:</strong> <a href="<%=h @user.url -%>"><%=h @user.url -%></a></li>
+ <% if @user.url %>
+ <li><strong>Url:</strong> <a href="<%=h @user.url -%>"><%=h @user.url -%></a></li>
+ <% end -%>
<li><strong>Member for</strong> <%= time_ago_in_words(@user.created_at) -%></li>
+ <li><strong><%= @commits_last_week -%></strong> commits so far this week.</li>
</ul>
</div>
-
<div id="left">
<% unless @projects.blank? -%>
<h2>Projects</h2>
diff --git a/config/initializers/ultrasphinx.rb b/config/initializers/ultrasphinx.rb
index f96587b..c25b7b4 100644
--- a/config/initializers/ultrasphinx.rb
+++ b/config/initializers/ultrasphinx.rb
@@ -14,7 +14,7 @@ Ultrasphinx::Search.query_defaults = HashWithIndifferentAccess.new({
Ultrasphinx::MAIN_INDEX,
(Ultrasphinx::DELTA_INDEX if Ultrasphinx.delta_index_present?)
].compact,
- :weights => { "title" => 2.0, "name" => 2.0 },
+ :weights => { "title" => 3.0, "name" => 2.0 },
:class_names => [],
:filters => {},
:facets => []
diff --git a/config/routes.rb b/config/routes.rb
index bc7f2ba..819ba7f 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -38,9 +38,9 @@ ActionController::Routing::Routes.draw do |map|
:writable_by => :get,
:confirm_delete => :get
}, :as => "repos") do |repo|
- repo.resources :committers, :name_prefix => nil, :collection => {:auto_complete_for_user_login => :post}
- repo.resources :comments
- repo.resources :merge_requests, :member => { :resolve => :put }
+ repo.resources :committers, :name_prefix => nil, :collection => {:auto_complete_for_user_login => :post, :list => :get, :create => :post}
+ repo.resources :comments, :member => { :commmit => :get }
+ repo.resources :merge_requests, :member => { :resolve => :put }, :collection => { :create => :post }
repo.commit_comment "comments/commit/:sha", :controller => "comments",
:action => "commit", :conditions => { :method => :get }
diff --git a/config/ultrasphinx/default.base b/config/ultrasphinx/default.base
index 0cb9255..5dc57bd 100644
--- a/config/ultrasphinx/default.base
+++ b/config/ultrasphinx/default.base
@@ -77,8 +77,8 @@ index
html_index_attrs =
# Enable these if you need wildcard searching. They will slow down indexing significantly.
- # min_infix_len = 1
- # enable_star = 1
+ min_infix_len = 1
+ enable_star = 1
charset_type = utf-8 # or sbcs (Single Byte Character Set)
charset_table = 0..9, A..Z->a..z, -, _, ., &, a..z, U+410..U+42F->U+430..U+44F, U+430..U+44F,U+C5->U+E5, U+E5, U+C4->U+E4, U+E4, U+D6->U+F6, U+F6, U+16B, U+0c1->a, U+0c4->a, U+0c9->e, U+0cd->i, U+0d3->o, U+0d4->o, U+0da->u, U+0dd->y, U+0e1->a, U+0e4->a, U+0e9->e, U+0ed->i, U+0f3->o, U+0f4->o, U+0fa->u, U+0fd->y, U+104->U+105, U+105, U+106->U+107, U+10c->c, U+10d->c, U+10e->d, U+10f->d, U+116->U+117, U+117, U+118->U+119, U+11a->e, U+11b->e, U+12E->U+12F, U+12F, U+139->l, U+13a->l, U+13d->l, U+13e->l, U+141->U+142, U+142, U+143->U+144, U+144,U+147->n, U+148->n, U+154->r, U+155->r, U+158->r, U+159->r, U+15A->U+15B, U+15B, U+160->s, U+160->U+161, U+161->s, U+164->t, U+165->t, U+16A->U+16B, U+16B, U+16e->u, U+16f->u, U+172->U+173, U+173, U+179->U+17A, U+17A, U+17B->U+17C, U+17C, U+17d->z, U+17e->z,
diff --git a/db/schema.rb b/db/schema.rb
deleted file mode 100644
index 07fb4cb..0000000
--- a/db/schema.rb
+++ /dev/null
@@ -1,166 +0,0 @@
-# This file is auto-generated from the current state of the database. Instead of editing this file,
-# please use the migrations feature of ActiveRecord to incrementally modify your database, and
-# then regenerate this schema definition.
-#
-# Note that this schema.rb definition is the authoritative source for your database schema. If you need
-# to create the application database on another system, you should be using db:schema:load, not running
-# all the migrations from scratch. The latter is a flawed and unsustainable approach (the more migrations
-# you'll amass, the slower it'll run and the greater likelihood for issues).
-#
-# It's strongly recommended to check this file into your version control system.
-
-ActiveRecord::Schema.define(:version => 23) do
-
- create_table "actions", :force => true do |t|
- t.string "name"
- end
-
- add_index "actions", ["name"], :name => "index_actions_on_name", :unique => true
-
- create_table "comments", :force => true do |t|
- t.integer "user_id", :null => false
- t.integer "repository_id", :null => false
- t.string "sha1"
- t.text "body"
- t.datetime "created_at"
- t.datetime "updated_at"
- t.integer "project_id"
- end
-
- add_index "comments", ["project_id"], :name => "index_comments_on_project_id"
- add_index "comments", ["repository_id"], :name => "index_comments_on_repository_id"
- add_index "comments", ["sha1"], :name => "index_comments_on_sha1"
- add_index "comments", ["user_id"], :name => "index_comments_on_user_id"
-
- create_table "committerships", :force => true do |t|
- t.integer "user_id"
- t.integer "repository_id"
- t.integer "kind", :default => 2
- t.datetime "created_at"
- t.datetime "updated_at"
- end
-
- add_index "committerships", ["repository_id"], :name => "index_permissions_on_repository_id"
- add_index "committerships", ["user_id"], :name => "index_permissions_on_user_id"
-
- create_table "events", :force => true do |t|
- t.integer "user_id", :null => false
- t.integer "repository_id"
- t.integer "action_id", :null => false
- t.string "ref"
- t.text "body"
- t.datetime "date", :null => false
- end
-
- add_index "events", ["user_id"], :name => "index_events_on_user_id"
-
- create_table "merge_requests", :force => true do |t|
- t.integer "user_id"
- t.integer "source_repository_id"
- t.integer "target_repository_id"
- t.text "proposal"
- t.string "sha_snapshot"
- t.integer "status", :default => 0
- t.datetime "created_at"
- t.datetime "updated_at"
- end
-
- add_index "merge_requests", ["source_repository_id"], :name => "index_merge_requests_on_source_repository_id"
- add_index "merge_requests", ["status"], :name => "index_merge_requests_on_status"
- add_index "merge_requests", ["target_repository_id"], :name => "index_merge_requests_on_target_repository_id"
- add_index "merge_requests", ["user_id"], :name => "index_merge_requests_on_user_id"
-
- create_table "projects", :force => true do |t|
- t.string "title"
- t.text "description"
- t.integer "user_id"
- t.datetime "created_at"
- t.datetime "updated_at"
- t.string "slug"
- t.string "license"
- t.string "home_url"
- t.string "mailinglist_url"
- t.string "bugtracker_url"
- end
-
- add_index "projects", ["title"], :name => "index_projects_on_name"
- add_index "projects", ["slug"], :name => "index_projects_on_slug", :unique => true
- add_index "projects", ["user_id"], :name => "index_projects_on_user_id"
-
- create_table "repositories", :force => true do |t|
- t.string "name"
- t.integer "project_id"
- t.integer "user_id"
- t.datetime "created_at"
- t.datetime "updated_at"
- t.boolean "mainline", :default => false
- t.integer "parent_id"
- t.boolean "ready", :default => false
- end
-
- add_index "repositories", ["name"], :name => "index_repositories_on_name"
- add_index "repositories", ["parent_id"], :name => "index_repositories_on_parent_id"
- add_index "repositories", ["project_id"], :name => "index_repositories_on_project_id"
- add_index "repositories", ["ready"], :name => "index_repositories_on_ready"
- add_index "repositories", ["user_id"], :name => "index_repositories_on_user_id"
-
- create_table "ssh_keys", :force => true do |t|
- t.integer "user_id"
- t.text "key"
- t.datetime "created_at"
- t.datetime "updated_at"
- t.boolean "ready", :default => false
- end
-
- add_index "ssh_keys", ["user_id"], :name => "index_ssh_keys_on_user_id"
-
- create_table "taggings", :force => true do |t|
- t.integer "tag_id"
- t.integer "taggable_id"
- t.string "taggable_type"
- t.datetime "created_at"
- end
-
- add_index "taggings", ["tag_id"], :name => "index_taggings_on_tag_id"
- add_index "taggings", ["taggable_id", "taggable_type"], :name => "index_taggings_on_taggable_id_and_taggable_type"
-
- create_table "tags", :force => true do |t|
- t.string "name"
- end
-
- add_index "tags", ["name"], :name => "index_tags_on_name", :unique => true
-
- create_table "tasks", :force => true do |t|
- t.string "target_class"
- t.string "command"
- t.text "arguments"
- t.boolean "performed", :default => false
- t.datetime "performed_at"
- t.datetime "created_at"
- t.datetime "updated_at"
- t.integer "target_id"
- end
-
- add_index "tasks", ["performed"], :name => "index_tasks_on_performed"
-
- create_table "users", :force => true do |t|
- t.string "login"
- t.string "email"
- t.string "crypted_password", :limit => 40
- t.string "salt", :limit => 40
- t.datetime "created_at"
- t.datetime "updated_at"
- t.string "remember_token"
- t.datetime "remember_token_expires_at"
- t.string "activation_code", :limit => 40
- t.datetime "activated_at"
- t.integer "ssh_key_id"
- t.string "fullname"
- t.text "url"
- end
-
- add_index "users", ["email"], :name => "index_users_on_email"
- add_index "users", ["login"], :name => "index_users_on_login"
- add_index "users", ["ssh_key_id"], :name => "index_users_on_ssh_key_id"
-
-end
diff --git a/lib/gitorious/graphs/builder.rb b/lib/gitorious/graphs/builder.rb
new file mode 100644
index 0000000..1da8810
--- /dev/null
+++ b/lib/gitorious/graphs/builder.rb
@@ -0,0 +1,40 @@
+require "gruff"
+
+silence_warnings do
+ Gruff::Base::TITLE_MARGIN = 2.0
+end
+
+module Gitorious
+ module Graphs
+ class Builder
+ def self.generate_all_for(repository)
+ CommitsBuilder.generate_for(repository)
+ CommitsByAuthorBuilder.generate_for(repository)
+ end
+
+ def self.graph_dir
+ File.join(RAILS_ROOT, "public/images/graphs/")
+ end
+
+ def self.default_theme
+ {
+ :colors => [
+ '#acd64f',
+ '#bcde71',
+ '#cce692',
+ '#dceeb4',
+ '#ecf6d6',
+ ],
+ :marker_color => '#aea9a9', # Grey
+ :font_color => 'black',
+ :background_colors => 'white'
+ }
+ end
+
+ def write
+ dest = File.join(self.class.graph_dir, construct_filename)
+ @graph.write(dest)
+ end
+ end
+ end
+end
diff --git a/lib/gitorious/graphs/commits_builder.rb b/lib/gitorious/graphs/commits_builder.rb
new file mode 100644
index 0000000..ff15273
--- /dev/null
+++ b/lib/gitorious/graphs/commits_builder.rb
@@ -0,0 +1,54 @@
+module Gitorious
+ module Graphs
+
+ class CommitsBuilder < Gitorious::Graphs::Builder
+ def self.generate_for(repository)
+ if repository.has_commits?
+ builder = new(repository, repository.head_candidate.name)
+ builder.build
+ builder.write
+ end
+ end
+
+ def initialize(repository, branch)
+ @repository = repository
+ @branch = branch
+ @graph = Gruff::Area.new("650x150")
+ @graph.title = "Commits by week (24 week period)"
+ #@graph.x_axis_label = 'Commits by week (24 week period)'
+ #@graph.y_axis_label = "Commits"
+ @graph.theme = self.class.default_theme
+ @graph.hide_legend = true
+ @graph.title_font_size = 12.5
+ @graph.marker_font_size = 12
+ @graph.top_margin = 1
+ @graph.bottom_margin = 1
+ end
+
+ def build
+ week_numbers, commits_by_week = @repository.commit_graph_data(@branch)
+
+ @graph.y_axis_increment = commits_by_week.max# / 3
+ @graph.data("Commits", commits_by_week)
+ @graph.labels = build_labels(week_numbers)
+ end
+
+ def construct_filename
+ "#{@repository.project.slug}_#{@repository.name}_#{@branch}_commit_count.png"
+ end
+
+ private
+ def build_labels(week_numbers)
+ label_names = {}
+ week_numbers.each_with_index do |week, index|
+ if (index % 5) == 0
+ label_names[index] = "Week #{week}"
+ end
+ end
+ label_names[week_numbers.index(week_numbers.last)] = "Week #{week_numbers.last}"
+ label_names
+ end
+ end
+
+ end
+end
diff --git a/lib/gitorious/graphs/commits_by_author_builder.rb b/lib/gitorious/graphs/commits_by_author_builder.rb
new file mode 100644
index 0000000..fd3d414
--- /dev/null
+++ b/lib/gitorious/graphs/commits_by_author_builder.rb
@@ -0,0 +1,40 @@
+module Gitorious
+ module Graphs
+
+ class CommitsByAuthorBuilder < Gitorious::Graphs::Builder
+ def self.generate_for(repository)
+ if repository.has_commits?
+ repository.git.heads.each do |head|
+ builder = new(repository, head.name)
+ builder.build
+ builder.write
+ end
+ end
+ end
+
+ def initialize(repository, branch)
+ @repository = repository
+ @branch = branch
+ @graph = Gruff::Mini::Pie.new(250)
+ @graph.theme_pastel
+ @graph.marker_font_size = 32
+ @graph.legend_font_size = 32
+ @graph.top_margin = 1
+ @graph.bottom_margin = 1
+ end
+
+ def build
+ commits_by_author = @repository.commit_graph_data_by_author(@branch)
+
+ commits_by_author.each do |author, count|
+ @graph.data(author, count)
+ end
+ end
+
+ def construct_filename
+ "#{@repository.project.slug}_#{@repository.name}_#{@branch}_commit_count_by_author.png"
+ end
+ end
+
+ end
+end
diff --git a/public/images/default_face.gif b/public/images/default_face.gif
new file mode 100644
index 0000000..e09dae6
--- /dev/null
+++ b/public/images/default_face.gif
Binary files differ
diff --git a/public/images/default_face.png b/public/images/default_face.png
deleted file mode 100644
index 194acfe..0000000
--- a/public/images/default_face.png
+++ /dev/null
Binary files differ
diff --git a/public/images/overview_contributors.png b/public/images/overview_contributors.png
index a35cb29..e972814 100644
--- a/public/images/overview_contributors.png
+++ b/public/images/overview_contributors.png
Binary files differ
diff --git a/public/images/overview_projects.png b/public/images/overview_projects.png
index 8cba251..cf4a81a 100644
--- a/public/images/overview_projects.png
+++ b/public/images/overview_projects.png
Binary files differ
diff --git a/public/stylesheets/base.css b/public/stylesheets/base.css
index 123dc54..4a8f6a2 100644
--- a/public/stylesheets/base.css
+++ b/public/stylesheets/base.css
@@ -120,6 +120,11 @@ abbr {
height: 0;
}
+.clear_left {
+ clear: left;
+ height: 0;
+}
+
#container {
width: 90%;
margin-top: 20px;
@@ -431,19 +436,46 @@ table.repository_list tr.clone td.name {
margin-bottom:0;
}
+.commit_list .commit_item {
+ clear:left;
+ margin-bottom: 15px;
+}
+
.commit_message, .commit_message p {
margin-top: 10px;
margin-left: 10px;
font: 95%/105% "Bitstream Vera Sans Mono", Monaco, "Courier New", Courier, monospace;
}
+.commit_list .commit_item .commit_message {
+ margin-left: 40px;
+}
+
small.commit_message {
margin: 0;
font: 85%/95% "Bitstream Vera Sans Mono", Monaco, "Courier New", Courier, monospace;
}
.commit_message a {
- color: #000;
+ color: #000;
+}
+
+.gravatar {
+ background-color: white;
+ border: 1px solid #CCCCCC;
+ float: left;
+ margin-right: 10px;
+ padding: 2px;
+}
+
+.gravatar_tiny {
+ background: transparent;
+ border: none;
+ margin-right: 5px;
+}
+
+.commit_list .commit_item .gravatar {
+ margin-top: 5px;
}
ul.project_list li {
@@ -804,13 +836,20 @@ ul.diff_stats small.deletions { color: #DC0000; }
margin-bottom: 4em;
margin-left: auto;
margin-right: auto;
- width: 910px;
+ width: 888px;
text-align:center;
}
#site_overview table td, #site_overview table th {
text-align:center;
- padding: 10px;
+}
+
+#site_overview table td.left, #site_overview table th.left {
+ border-right: 1px dotted #ccc;
+ padding-right: 10px;
+}
+#site_overview table td.right, #site_overview table th.right {
+ padding-left: 10px;
}
#site_overview p.create_account_hint {
@@ -949,4 +988,17 @@ ul.diff_stats small.deletions { color: #DC0000; }
margin:0;
}
.search_bar p { margin-bottom: 2px; }
-.search_bar { margin-bottom: 20px; } \ No newline at end of file
+.search_bar { margin-bottom: 20px; }
+
+#users .infobox {
+ margin-bottom: 20px;
+}
+
+.commits_by_author_graph img {
+ float: right;
+ margin: 0 0 10px 10px;
+}
+
+.commit_graph {
+ text-align:center;
+} \ No newline at end of file
diff --git a/script/graph_generator b/script/graph_generator
new file mode 100755
index 0000000..1208024
--- /dev/null
+++ b/script/graph_generator
@@ -0,0 +1,28 @@
+#!/usr/bin/env ruby
+
+ENV["RAILS_ENV"] ||= "production"
+require File.dirname(__FILE__) + "/../config/environment"
+
+log = Logger.new(File.join(RAILS_ROOT, "log", "graph_generator.log"))
+log.formatter = Logger::Formatter.new
+log.level = Logger::INFO
+log.formatter.datetime_format = "%Y-%m-%d %H:%M:%S"
+
+log.info "Starting graph generation run..."
+Repository.find(:all).each_with_index do |repository, index|
+ begin
+ Gitorious::Graphs::Builder.generate_all_for(repository)
+ if index % 5 == 0
+ # GC every five cycles
+ GC.start
+ end
+ sleep(0.1)
+ rescue => e
+ log.fatal "Error generating graphs for repo##{repository.id}"
+ exception_backtrace_string = "#{e.class.name} #{e.message}\n#{e.backtrace.join("\n ")}"
+ log.fatal exception_backtrace_string
+ $stderr.puts exception_backtrace_string
+# exit(1)
+ end
+end
+log.info "Done with graph generation run" \ No newline at end of file
diff --git a/script/spec_server b/script/spec_server
index d48df92..3787a39 100755
--- a/script/spec_server
+++ b/script/spec_server
@@ -25,10 +25,13 @@ module Spec
end
end
- if ::Dispatcher.respond_to?(:cleanup_application)
- ::Dispatcher.cleanup_application
+ if ActionController.const_defined?(:Dispatcher)
+ dispatcher = ::ActionController::Dispatcher.new($stdout)
+ dispatcher.cleanup_application(true)
elsif ::Dispatcher.respond_to?(:reset_application!)
::Dispatcher.reset_application!
+ else
+ raise "Application reloading failed"
end
::Dependencies.mechanism = :load
require_dependency('application.rb') unless Object.const_defined?(:ApplicationController)
diff --git a/spec/controllers/users_controller_spec.rb b/spec/controllers/users_controller_spec.rb
index 523f03e..8acb3c7 100644
--- a/spec/controllers/users_controller_spec.rb
+++ b/spec/controllers/users_controller_spec.rb
@@ -90,5 +90,11 @@ describe UsersController do
p[:action].should == "activate"
p[:activation_code].should == "abc123"
end
-
+
+ it "counts the number of commits in the last week" do
+ get :show, :id => users(:johan).login
+ response.should be_success
+ assigns[:commits_last_week].kind_of?(Fixnum).should == true
+ (assigns[:commits_last_week] >= 0).should == true
+ end
end
diff --git a/spec/helpers/application_helper_spec.rb b/spec/helpers/application_helper_spec.rb
index c5fd2a1..abbc8a0 100644
--- a/spec/helpers/application_helper_spec.rb
+++ b/spec/helpers/application_helper_spec.rb
@@ -44,28 +44,16 @@ describe ApplicationHelper do
end
- it "should generate a commit graph url" do
- project = projects(:johans)
- FileUtils.mkpath(project.mainline_repository.full_repository_path)
-
- url = commit_graph_tag(project)
-
- (url =~ /\<img/).should == 0
- url.include?("google.com").should == true
-
- Gchart.should_receive(:line)
- commit_graph_tag(project)
+ it "should generate a blank commit graph url if the graph isn't there" do
+ File.should_receive(:exist?).and_return(false)
+ url = commit_graph_tag(repositories(:johans))
+ url.should == nil
end
- it "should generate a url for commit graph by author" do
- project = projects(:johans)
- FileUtils.mkpath(project.mainline_repository.full_repository_path)
-
- url = commit_graph_by_author_tag(project)
- (url =~ /\<img/).should == 0
- url.include?("google.com").should == true
+ it "should generate a blank url for commit graph by author if the graph isn't there" do
+ File.should_receive(:exist?).and_return(false)
- Gchart.should_receive(:pie)
- commit_graph_by_author_tag(project)
+ url = commit_graph_by_author_tag(repositories(:johans))
+ url.should == nil
end
end
diff --git a/spec/models/repository_spec.rb b/spec/models/repository_spec.rb
index aa98b7e..8407ef7 100644
--- a/spec/models/repository_spec.rb
+++ b/spec/models/repository_spec.rb
@@ -1,4 +1,5 @@
require File.dirname(__FILE__) + '/../spec_helper'
+require "ostruct"
describe Repository do
before(:each) do
@@ -290,6 +291,22 @@ describe Repository do
commits.should be_instance_of(WillPaginate::Collection)
end
+ it "has a count_commits_from_last_week_by_user of 0 if no commits" do
+ @repository.should_receive(:has_commits?).and_return(false)
+ @repository.count_commits_from_last_week_by_user(users(:johan)).should == 0
+ end
+
+ it "returns a set of users from a list of commits" do
+ commits = []
+ users(:johan, :moe).map(&:email).each do |email|
+ committer = OpenStruct.new(:email => email)
+ commits << OpenStruct.new(:committer => committer)
+ end
+ users = @repository.users_by_commits(commits)
+ users.keys.sort.should == users(:johan, :moe).map(&:email).sort
+ users.values.map(&:login).sort.should == users(:johan, :moe).map(&:login).sort
+ end
+
describe "observers" do
it "sends an email to the admin if there's a parent" do
Mailer.should_receive(:deliver_new_repository_clone).with(@repository).and_return(true)
diff --git a/vendor/plugins/googlecharts/History.txt b/vendor/plugins/googlecharts/History.txt
deleted file mode 100644
index 906267f..0000000
--- a/vendor/plugins/googlecharts/History.txt
+++ /dev/null
@@ -1,21 +0,0 @@
-== 1.1.0
-* fixed another bug fix related to the uri escaping required to download the file properly.
-== 1.0.0
-* fixed the (URI::InvalidURIError) issue
-== 0.2.0
-* added export options (file and image tag)
-* added support for all arguments to be passed as a string or an array
-
-== 0.1.0 2007-12-11
-* fixed the axis labels
-
-== 0.0.3 2007-12-11
-* added :chart_background alias and fixed a bug related to the background colors.
-
-== 0.0.2 2007-12-11
-* added support for more features and aliases
-
-== 0.0.1 2007-12-08
-
-* 1 major enhancement:
- * Initial release
diff --git a/vendor/plugins/googlecharts/Manifest.txt b/vendor/plugins/googlecharts/Manifest.txt
deleted file mode 100644
index 500a692..0000000
--- a/vendor/plugins/googlecharts/Manifest.txt
+++ /dev/null
@@ -1,27 +0,0 @@
-History.txt
-License.txt
-Manifest.txt
-README.txt
-Rakefile
-config/hoe.rb
-config/requirements.rb
-lib/gchart.rb
-lib/gchart/aliases.rb
-lib/gchart/version.rb
-log/debug.log
-script/destroy
-script/generate
-script/txt2html
-setup.rb
-spec/gchart_spec.rb
-spec/spec.opts
-spec/spec_helper.rb
-tasks/deployment.rake
-tasks/environment.rake
-tasks/rspec.rake
-tasks/website.rake
-website/index.html
-website/index.txt
-website/javascripts/rounded_corners_lite.inc.js
-website/stylesheets/screen.css
-website/template.rhtml
diff --git a/vendor/plugins/googlecharts/README.txt b/vendor/plugins/googlecharts/README.txt
deleted file mode 100644
index ca494a3..0000000
--- a/vendor/plugins/googlecharts/README.txt
+++ /dev/null
@@ -1,179 +0,0 @@
-The goal of this Gem is to make the creation of Google Charts a simple and easy task.
-
-Gchart.line( :size => '200x300',
- :title => "example title",
- :bg => 'efefef',
- :legend => ['first data set label', 'second data set label'],
- :data => [10, 30, 120, 45, 72])
-
-
-
-==Chart Type
-
-This gem supports the following types of charts:
-
- * line,
- * line_xy
- * scatter
- * bar
- * venn
- * pie
- * pie_3d
-
-To create a chart, simply require Gchart and call any of the existing type:
-
- require 'gchart'
- Gchart.pie
-
-
-==Chart Title
-
- To add a title to a chart pass the title to your chart:
-
- Gchart.line(:title => 'Sexy Charts!')
-
-You can also specify the color and/or size
-
- Gchart.line(:title => 'Sexy Charts!', :title_color => 'FF0000', :title_size => '20')
-
-==Colors
-
-Specify a color with at least a 6-letter string of hexadecimal values in the format RRGGBB. For example:
-
- * FF0000 = red
- * 00FF00 = green
- * 0000FF = blue
- * 000000 = black
- * FFFFFF = white
-
-You can optionally specify transparency by appending a value between 00 and FF where 00 is completely transparent and FF completely opaque. For example:
-
- * 0000FFFF = solid blue
- * 0000FF00 = transparent blue
-
-If you need to use multiple colors, check the doc. Usually you just need to pass :attribute => 'FF0000,00FF00'
-
-Some charts have more options than other, make sure to refer to the documentation.
-
-===Background options:
-
-If you don't set the background option, your graph will be transparent.
-
-* You have 3 types of background http://code.google.com/apis/chart/#chart_or_background_fill
-
-- solid
-- gradient
-- stripes
-
-By default, if you set a background color, the fill will be solid:
-
- Gchart.bar(:bg => 'efefef')
-
-However you can specify another fill type such as:
-
- Gchart.line(:bg => {:color => 'efefef', :type => 'gradient'})
-
-In the above code, we decided to have a gradient background, however since we only passed one color, the chart will start by the specified color and transition to white. By the default, the gradient angle is 0. Change it as follows:
-
- Gchart.line(:title =>'bg example', :bg => {:color => 'efefef', :type => 'gradient', :angle => 90})
-
-For a more advance use of colors, refer to http://code.google.com/apis/chart/#linear_gradient
-
- Gchart.line(:bg => {:color => '76A4FB,1,ffffff,0', :type => 'gradient'})
-
-
-The same way you set the background color, you can also set the graph background:
-
- Gchart.line(:graph_bg => 'cccccc')
-
-or both
-
- Gchart.line(:bg => {:color => '76A4FB,1,ffffff,0', :type => 'gradient'}, :graph_bg => 'cccccc', :title => 'Sexy Chart')
-
-
-Another type of fill is stripes http://code.google.com/apis/chart/#linear_stripes
-
- Gchart.line(:bg => {:color => 'efefef', :type => 'stripes'})
-
-You can customize the amount of stripes, colors and width by changing the color value.
-
-
-== Legend & Labels
-
-You probably will want to use a legend or labels for your graph.
-
- Gchart.line(:legend => 'legend label')
-or
- Gchart.line(:legend => ['legend label 1', 'legend label 2'])
-
-Will do the trick. You can also use the labels alias (makes more sense when using the pie charts)
-
- chart = Gchart.pie(:labels => ['label 1', 'label 2'])
-
-== Multiple axis labels
-
-Multiple axis labels are available for line charts, bar charts and scatter plots.
-
-* x = bottom x-axis
-* t = top x-axis
-* y = left y-axis
-* r = right y-axis
-
- Gchart.line(:label_axis => 'x,y,r')
-
-To add labels on these axis:
-
- Gchart.line(:axis_labels => ['Jan|July|Jan|July|Jan', '0|100', 'A|B|C', '2005|2006|2007'])
-
-
-== Data options
-
-Data are passed using an array or a nested array.
-
- Gchart.bar(:data => [1,2,4,67,100,41,234])
-
- Gchart.bar(:data => [[1,2,4,67,100,41,234],[45,23,67,12,67,300, 250]])
-
-By default, the graph is drawn with your max value representing 100% of the height or width of the graph. You can change that my passing the max value.
-
- Gchart.bar(:data => [1,2,4,67,100,41,234], :max_value => 300)
- Gchart.bar(:data => [1,2,4,67,100,41,234], :max_value => 'auto')
-
-or if you want to use the real values from your dataset:
-
- Gchart.bar(:data => [1,2,4,67,100,41,234], :max_value => false)
-
-
-You can also define a different encoding to add more granularity:
-
- Gchart.bar(:data => [1,2,4,67,100,41,234], :encoding => 'simple')
- Gchart.bar(:data => [1,2,4,67,100,41,234], :encoding => 'extended')
- Gchart.bar(:data => [1,2,4,67,100,41,234], :encoding => 'text')
-
-
-==Pies:
-
-you have 2 type of pies:
- - Gchart.pie() the standard 2D pie
- _ Gchart.pie_3d() the fancy 3D pie
-
-To set labels, you can use one of these two options:
-
- @legend = ['Matt_fu', 'Rob_fu']
- Gchart.pie_3d(:title => @title, :labels => @legend, :data => @data, :size => '400x200')
- Gchart.pie_3d(:title => @title, :legend => @legend, :data => @data, :size => '400x200')
-
-
-
-=== try yourself
-
-Gchart.bar( :data => [[1,2,4,67,100,41,234],[45,23,67,12,67,300, 250]],
- :title => 'SDRuby Fu level',
- :legend => ['matt','patrick'],
- :bg => {:color => '76A4FB', :type => 'gradient'},
- :bar_colors => 'ff0000,00ff00')
-
- "http://chart.apis.google.com/chart?chs=300x200&chdl=matt|patrick&chd=s:AAANUIv,JENCN9y&chtt=SDRuby+Fu+level&chf=bg,lg,0,76A4FB,0,ffffff,1&cht=bvs&chco=ff0000,00ff00"
-
-Gchart.pie(:data => [20,10,15,5,50], :title => 'SDRuby Fu level', :size => '400x200', :labels => ['matt', 'rob', 'patrick', 'ryan', 'jordan'])
-http://chart.apis.google.com/chart?cht=p&chs=400x200&chd=s:YMSG9&chtt=SDRuby+Fu+level&chl=matt|rob|patrick|ryan|jordan
diff --git a/vendor/plugins/googlecharts/Rakefile b/vendor/plugins/googlecharts/Rakefile
deleted file mode 100644
index e469154..0000000
--- a/vendor/plugins/googlecharts/Rakefile
+++ /dev/null
@@ -1,4 +0,0 @@
-require 'config/requirements'
-require 'config/hoe' # setup Hoe + all gem configuration
-
-Dir['tasks/**/*.rake'].each { |rake| load rake } \ No newline at end of file
diff --git a/vendor/plugins/googlecharts/config/hoe.rb b/vendor/plugins/googlecharts/config/hoe.rb
deleted file mode 100644
index ae0b1da..0000000
--- a/vendor/plugins/googlecharts/config/hoe.rb
+++ /dev/null
@@ -1,71 +0,0 @@
-require 'gchart/version'
-
-AUTHOR = 'Matt Aimonetti' # can also be an array of Authors
-EMAIL = "mattaimonetti@gmail.com"
-DESCRIPTION = "description of gem"
-GEM_NAME = 'googlecharts' # what ppl will type to install your gem
-RUBYFORGE_PROJECT = 'googlecharts' # The unix name for your project
-HOMEPATH = "http://#{RUBYFORGE_PROJECT}.rubyforge.org"
-DOWNLOAD_PATH = "http://rubyforge.org/projects/#{RUBYFORGE_PROJECT}"
-
-@config_file = "~/.rubyforge/user-config.yml"
-@config = nil
-RUBYFORGE_USERNAME = "matt_a"
-def rubyforge_username
- unless @config
- begin
- @config = YAML.load(File.read(File.expand_path(@config_file)))
- rescue
- puts <<-EOS
-ERROR: No rubyforge config file found: #{@config_file}
-Run 'rubyforge setup' to prepare your env for access to Rubyforge
- - See http://newgem.rubyforge.org/rubyforge.html for more details
- EOS
- exit
- end
- end
- RUBYFORGE_USERNAME.replace @config["username"]
-end
-
-
-REV = nil
-# UNCOMMENT IF REQUIRED:
-# REV = `svn info`.each {|line| if line =~ /^Revision:/ then k,v = line.split(': '); break v.chomp; else next; end} rescue nil
-VERS = GchartInfo::VERSION::STRING + (REV ? ".#{REV}" : "")
-RDOC_OPTS = ['--quiet', '--title', 'gchart documentation',
- "--opname", "index.html",
- "--line-numbers",
- "--main", "README",
- "--inline-source"]
-
-class Hoe
- def extra_deps
- @extra_deps.reject! { |x| Array(x).first == 'hoe' }
- @extra_deps
- end
-end
-
-# Generate all the Rake tasks
-# Run 'rake -T' to see list of generated tasks (from gem root directory)
-hoe = Hoe.new(GEM_NAME, VERS) do |p|
- p.author = AUTHOR
- p.description = DESCRIPTION
- p.email = EMAIL
- p.summary = DESCRIPTION
- p.url = HOMEPATH
- p.rubyforge_name = RUBYFORGE_PROJECT if RUBYFORGE_PROJECT
- p.test_globs = ["test/**/test_*.rb"]
- p.clean_globs |= ['**/.*.sw?', '*.gem', '.config', '**/.DS_Store'] #An array of file patterns to delete on clean.
-
- # == Optional
- p.changes = p.paragraphs_of("History.txt", 0..1).join("\n\n")
- #p.extra_deps = [] # An array of rubygem dependencies [name, version], e.g. [ ['active_support', '>= 1.3.1'] ]
-
- #p.spec_extras = {} # A hash of extra values to set in the gemspec.
-
-end
-
-CHANGES = hoe.paragraphs_of('History.txt', 0..1).join("\\n\\n")
-PATH = (RUBYFORGE_PROJECT == GEM_NAME) ? RUBYFORGE_PROJECT : "#{RUBYFORGE_PROJECT}/#{GEM_NAME}"
-hoe.remote_rdoc_dir = File.join(PATH.gsub(/^#{RUBYFORGE_PROJECT}\/?/,''), 'rdoc')
-hoe.rsync_args = '-av --delete --ignore-errors' \ No newline at end of file
diff --git a/vendor/plugins/googlecharts/config/requirements.rb b/vendor/plugins/googlecharts/config/requirements.rb
deleted file mode 100644
index bf1b541..0000000
--- a/vendor/plugins/googlecharts/config/requirements.rb
+++ /dev/null
@@ -1,16 +0,0 @@
-require 'fileutils'
-include FileUtils
-
-require 'rubygems'
-%w[rake hoe newgem rubigen].each do |req_gem|
- begin
- require req_gem
- rescue LoadError
- puts "This Rakefile could use '#{req_gem}' RubyGem."
- puts "Installation: gem install #{req_gem} -y"
- end
-end
-
-$:.unshift(File.join(File.dirname(__FILE__), %w[.. lib]))
-
-require 'gchart' \ No newline at end of file
diff --git a/vendor/plugins/googlecharts/lib/gchart.rb b/vendor/plugins/googlecharts/lib/gchart.rb
deleted file mode 100644
index f26b8e8..0000000
--- a/vendor/plugins/googlecharts/lib/gchart.rb
+++ /dev/null
@@ -1,364 +0,0 @@
-$:.unshift File.dirname(__FILE__)
-require 'gchart/version'
-require "open-uri"
-require "uri"
-
-class Gchart
-
- include GchartInfo
-
- @@url = "http://chart.apis.google.com/chart?"
- @@types = ['line', 'line_xy', 'scatter', 'bar', 'venn', 'pie', 'pie_3d', 'jstize']
- @@simple_chars = ('A'..'Z').to_a + ('a'..'z').to_a + ('0'..'9').to_a
- @@chars = @@simple_chars + ['-', '.']
- @@ext_pairs = @@chars.map { |char_1| @@chars.map { |char_2| char_1 + char_2 } }.flatten
- @@file_name = 'chart.png'
-
- attr_accessor :title, :type, :width, :height, :horizontal, :grouped, :legend, :data, :encoding, :max_value, :bar_colors,
- :title_color, :title_size, :custom, :axis_with_labels, :axis_labels
-
- class << self
- # Support for Gchart.line(:title => 'my title', :size => '400x600')
- def method_missing(m, options={})
- # Extract the format and optional filename, then clean the hash
- format = options[:format] || 'url'
- @@file_name = options[:filename] unless options[:filename].nil?
- options.delete(:format)
- options.delete(:filename)
- # create the chart and return it in the format asked for
- if @@types.include?(m.to_s)
- chart = new(options.merge!({:type => m}))
- chart.send(format)
- elsif m.to_s == 'version'
- Gchart::VERSION::STRING
- else
- "#{m} is not a supported chart format, please use one of the following: #{supported_types}."
- end
- end
-
- end
-
- def initialize(options={})
- @type = :line
- @data = []
- @width = 300
- @height = 200
- @horizontal = false
- @grouped = false
- @encoding = 'simple'
- @max_value = 'auto'
-
- # set the options value if definable
- options.each do |attribute, value|
- send("#{attribute.to_s}=", value) if self.respond_to?("#{attribute}=")
- end
- end
-
- def self.supported_types
- @@types.join(' ')
- end
-
- # Defines the Graph size using the following format:
- # width X height
- def size=(size='300x200')
- @width, @height = size.split("x").map { |dimension| dimension.to_i }
- end
-
- def size
- "#{@width}x#{@height}"
- end
-
- # Sets the orientation of a bar graph
- def orientation=(orientation='h')
- if orientation == 'h' || orientation == 'horizontal'
- self.horizontal = true
- elsif orientation == 'v' || orientation == 'vertical'
- self.horizontal = false
- end
- end
-
- # Sets the bar graph presentation (stacked or grouped)
- def stacked=(option=true)
- @grouped = option ? false : true
- end
-
- def bg=(options)
- if options.is_a?(String)
- @bg_color = options
- elsif options.is_a?(Hash)
- @bg_color = options[:color]
- @bg_type = options[:type]
- @bg_angle = options[:angle]
- end
- end
-
- def graph_bg=(options)
- if options.is_a?(String)
- @chart_color = options
- elsif options.is_a?(Hash)
- @chart_color = options[:color]
- @chart_type = options[:type]
- @chart_angle = options[:angle]
- end
- end
-
- def self.jstize(string)
- string.gsub(' ', '+').gsub(/\[|\{|\}|\||\\|\^|\[|\]|\`|\]/) {|c| "%#{c[0].to_s(16).upcase}"}
- end
- # load all the custom aliases
- require 'gchart/aliases'
-
- protected
-
- # Returns the chart's generated PNG as a blob. (borrowed from John's gchart.rubyforge.org)
- def fetch
- open(query_builder) { |io| io.read }
- end
-
- # Writes the chart's generated PNG to a file. (borrowed from John's gchart.rubyforge.org)
- def write(io_or_file=@@file_name)
- return io_or_file.write(fetch) if io_or_file.respond_to?(:write)
- open(io_or_file, "w+") { |io| io.write(fetch) }
- end
-
- # Format
-
- def img_tag
- "<img src='#{query_builder}'/>"
- end
-
- def url
- query_builder
- end
-
- def file
- write
- end
-
- #
- def jstize(string)
- Gchart.jstize(string)
- end
-
- private
-
- # The title size cannot be set without specifying a color.
- # A dark key will be used for the title color if no color is specified
- def set_title
- title_params = "chtt=#{title}"
- unless (title_color.nil? && title_size.nil? )
- title_params << "&chts=" + (color, size = (@title_color || '454545'), @title_size).compact.join(',')
- end
- title_params
- end
-
- def set_size
- "chs=#{size}"
- end
-
- def set_data
- data = send("#{@encoding}_encoding", @data)
- "chd=#{data}"
- end
-
- def set_colors
- bg_type = fill_type(@bg_type) || 's' if @bg_color
- chart_type = fill_type(@chart_type) || 's' if @chart_color
-
- "chf=" + {'bg' => fill_for(bg_type, @bg_color, @bg_angle), 'c' => fill_for(chart_type, @chart_color, @chart_angle)}.map{|k,v| "#{k},#{v}" unless v.nil?}.compact.join('|')
- end
-
- # set bar, line colors
- def set_bar_colors
- @bar_colors = @bar_colors.join(',') if @bar_colors.is_a?(Array)
- "chco=#{@bar_colors}"
- end
-
- def fill_for(type=nil, color='', angle=nil)
- unless type.nil?
- case type
- when 'lg'
- angle ||= 0
- color = "#{color},0,ffffff,1" if color.split(',').size == 1
- "#{type},#{angle},#{color}"
- when 'ls'
- angle ||= 90
- color = "#{color},0.2,ffffff,0.2" if color.split(',').size == 1
- "#{type},#{angle},#{color}"
- else
- "#{type},#{color}"
- end
- end
- end
-
- # A chart can have one or many legends.
- # Gchart.line(:legend => 'label')
- # or
- # Gchart.line(:legend => ['first label', 'last label'])
- def set_legend
- return set_labels if @type == :pie || @type == :pie_3d
-
- if @legend.is_a?(Array)
- "chdl=#{@legend.map{|label| "#{label}"}.join('|')}"
- else
- "chdl=#{@legend}"
- end
-
- end
-
- def set_labels
- if @legend.is_a?(Array)
- "chl=#{@legend.map{|label| "#{label}"}.join('|')}"
- else
- "chl=#{@legend}"
- end
- end
-
- def set_axis_with_labels
- @axis_with_labels = @axis_with_labels.join(',') if @axis_with_labels.is_a?(Array)
- "chxt=#{@axis_with_labels}"
- end
-
- def set_axis_labels
- labels_arr = []
- axis_labels.each_with_index do |labels,index|
- if labels.is_a?(Array)
- labels_arr << "#{index}:|#{labels.join('|')}"
- else
- labels_arr << "#{index}:|#{labels}"
- end
- end
- "chxl=#{labels_arr.join('|')}"
- end
-
- def set_type
- case @type
- when :line
- "cht=lc"
- when :line_xy
- "cht=lxy"
- when :bar
- "cht=b" + (horizontal? ? "h" : "v") + (grouped? ? "g" : "s")
- when :pie_3d
- "cht=p3"
- when :pie
- "cht=p"
- when :venn
- "cht=v"
- when :scatter
- "cht=s"
- end
- end
-
- def fill_type(type)
- case type
- when 'solid'
- 's'
- when 'gradient'
- 'lg'
- when 'stripes'
- 'ls'
- end
- end
-
- # Wraps a single dataset inside another array to support more datasets
- def prepare_dataset(ds)
- ds = [ds] unless ds.first.is_a?(Array)
- ds
- end
-
- def convert_to_simple_value(number)
- if number.nil?
- "_"
- else
- value = @@simple_chars[number.to_i]
- value.nil? ? "_" : value
- end
- end
-
- # http://code.google.com/apis/chart/#simple
- # Simple encoding has a resolution of 62 different values.
- # Allowing five pixels per data point, this is sufficient for line and bar charts up
- # to about 300 pixels. Simple encoding is suitable for all other types of chart regardless of size.
- def simple_encoding(dataset=[])
- dataset = prepare_dataset(dataset)
- @max_value = dataset.map{|ds| ds.max}.max if @max_value == 'auto'
-
- if @max_value == false || @max_value == 'false' || @max_value == :false
- "s:" + dataset.map { |ds| ds.map { |number| convert_to_simple_value(number) }.join }.join(',')
- else
- "s:" + dataset.map { |ds| ds.map { |number| convert_to_simple_value( (@@simple_chars.size - 1) * number / @max_value) }.join }.join(',')
- end
-
- end
-
- # http://code.google.com/apis/chart/#text
- # Text encoding has a resolution of 1,000 different values,
- # using floating point numbers between 0.0 and 100.0. Allowing five pixels per data point,
- # integers (1.0, 2.0, and so on) are sufficient for line and bar charts up to about 500 pixels.
- # Include a single decimal place (35.7 for example) if you require higher resolution.
- # Text encoding is suitable for all other types of chart regardless of size.
- def text_encoding(dataset=[])
- dataset = prepare_dataset(dataset)
- "t:" + dataset.map{ |ds| ds.join(',') }.join('|')
- end
-
- def convert_to_extended_value(number)
- if number.nil?
- '__'
- else
- value = @@ext_pairs[number.to_i]
- value.nil? ? "__" : value
- end
- end
-
- # http://code.google.com/apis/chart/#extended
- # Extended encoding has a resolution of 4,096 different values
- # and is best used for large charts where a large data range is required.
- def extended_encoding(dataset=[])
-
- dataset = prepare_dataset(dataset)
- @max_value = dataset.map{|ds| ds.max}.max if @max_value == 'auto'
-
- if @max_value == false || @max_value == 'false' || @max_value == :false
- "e:" + dataset.map { |ds| ds.map { |number| convert_to_extended_value(number)}.join }.join(',')
- else
- "e:" + dataset.map { |ds| ds.map { |number| convert_to_extended_value( (@@ext_pairs.size - 1) * number / @max_value) }.join }.join(',')
- end
-
- end
-
-
- def query_builder
- query_params = instance_variables.map do |var|
- case var
- # Set the graph size
- when '@width'
- set_size unless @width.nil? || @height.nil?
- when '@type'
- set_type
- when '@title'
- set_title unless @title.nil?
- when '@legend'
- set_legend unless @legend.nil?
- when '@bg_color'
- set_colors
- when '@chart_color'
- set_colors if @bg_color.nil?
- when '@data'
- set_data unless @data == []
- when '@bar_colors'
- set_bar_colors
- when '@axis_with_labels'
- set_axis_with_labels
- when '@axis_labels'
- set_axis_labels
- when '@custom'
- @custom
- end
- end.compact
-
- jstize(@@url + query_params.join('&'))
- end
-
-end \ No newline at end of file
diff --git a/vendor/plugins/googlecharts/lib/gchart/aliases.rb b/vendor/plugins/googlecharts/lib/gchart/aliases.rb
deleted file mode 100644
index f7071fd..0000000
--- a/vendor/plugins/googlecharts/lib/gchart/aliases.rb
+++ /dev/null
@@ -1,14 +0,0 @@
-class Gchart
-
- alias_method :background=, :bg=
- alias_method :chart_bg=, :graph_bg=
- alias_method :chart_color=, :graph_bg=
- alias_method :chart_background=, :graph_bg=
- alias_method :bar_color=, :bar_colors=
- alias_method :line_colors=, :bar_colors=
- alias_method :line_color=, :bar_colors=
- alias_method :labels=, :legend=
- alias_method :horizontal?, :horizontal
- alias_method :grouped?, :grouped
-
-end \ No newline at end of file
diff --git a/vendor/plugins/googlecharts/lib/gchart/version.rb b/vendor/plugins/googlecharts/lib/gchart/version.rb
deleted file mode 100644
index 06be613..0000000
--- a/vendor/plugins/googlecharts/lib/gchart/version.rb
+++ /dev/null
@@ -1,9 +0,0 @@
-module GchartInfo #:nodoc:
- module VERSION #:nodoc:
- MAJOR = 1
- MINOR = 1
- TINY = 0
-
- STRING = [MAJOR, MINOR, TINY].join('.')
- end
-end
diff --git a/vendor/plugins/googlecharts/log/debug.log b/vendor/plugins/googlecharts/log/debug.log
deleted file mode 100644
index e69de29..0000000
--- a/vendor/plugins/googlecharts/log/debug.log
+++ /dev/null
diff --git a/vendor/plugins/googlecharts/script/destroy b/vendor/plugins/googlecharts/script/destroy
deleted file mode 100755
index 5fa7e10..0000000
--- a/vendor/plugins/googlecharts/script/destroy
+++ /dev/null
@@ -1,14 +0,0 @@
-#!/usr/bin/env ruby
-APP_ROOT = File.join(File.dirname(__FILE__), '..')
-
-begin
- require 'rubigen'
-rescue LoadError
- require 'rubygems'
- require 'rubigen'
-end
-require 'rubigen/scripts/destroy'
-
-ARGV.shift if ['--help', '-h'].include?(ARGV[0])
-RubiGen::Base.use_component_sources! [:rubygems, :newgem, :newgem_theme, :test_unit]
-RubiGen::Scripts::Destroy.new.run(ARGV)
diff --git a/vendor/plugins/googlecharts/script/generate b/vendor/plugins/googlecharts/script/generate
deleted file mode 100755
index 230a186..0000000
--- a/vendor/plugins/googlecharts/script/generate
+++ /dev/null
@@ -1,14 +0,0 @@
-#!/usr/bin/env ruby
-APP_ROOT = File.join(File.dirname(__FILE__), '..')
-
-begin
- require 'rubigen'
-rescue LoadError
- require 'rubygems'
- require 'rubigen'
-end
-require 'rubigen/scripts/generate'
-
-ARGV.shift if ['--help', '-h'].include?(ARGV[0])
-RubiGen::Base.use_component_sources! [:rubygems, :newgem, :newgem_theme, :test_unit]
-RubiGen::Scripts::Generate.new.run(ARGV)
diff --git a/vendor/plugins/googlecharts/script/txt2html b/vendor/plugins/googlecharts/script/txt2html
deleted file mode 100755
index 87198bc..0000000
--- a/vendor/plugins/googlecharts/script/txt2html
+++ /dev/null
@@ -1,74 +0,0 @@
-#!/usr/bin/env ruby
-
-require 'rubygems'
-begin
- require 'newgem'
-rescue LoadError
- puts "\n\nGenerating the website requires the newgem RubyGem"
- puts "Install: gem install newgem\n\n"
- exit(1)
-end
-require 'redcloth'
-require 'syntax/convertors/html'
-require 'erb'
-require File.dirname(__FILE__) + '/../lib/gchart'
-
-version = Gchart.version
-download = 'http://rubyforge.org/projects/googlecharts'
-
-class Fixnum
- def ordinal
- # teens
- return 'th' if (10..19).include?(self % 100)
- # others
- case self % 10
- when 1: return 'st'
- when 2: return 'nd'
- when 3: return 'rd'
- else return 'th'
- end
- end
-end
-
-class Time
- def pretty
- return "#{mday}#{mday.ordinal} #{strftime('%B')} #{year}"
- end
-end
-
-def convert_syntax(syntax, source)
- return Syntax::Convertors::HTML.for_syntax(syntax).convert(source).gsub(%r!^<pre>|</pre>$!,'')
-end
-
-if ARGV.length >= 1
- src, template = ARGV
- template ||= File.join(File.dirname(__FILE__), '/../website/template.rhtml')
-
-else
- puts("Usage: #{File.split($0).last} source.txt [template.rhtml] > output.html")
- exit!
-end
-
-template = ERB.new(File.open(template).read)
-
-title = nil
-body = nil
-File.open(src) do |fsrc|
- title_text = fsrc.readline
- body_text = fsrc.read
- syntax_items = []
- body_text.gsub!(%r!<(pre|code)[^>]*?syntax=['"]([^'"]+)[^>]*>(.*?)</\1>!m){
- ident = syntax_items.length
- element, syntax, source = $1, $2, $3
- syntax_items << "<#{element} class='syntax'>#{convert_syntax(syntax, source)}</#{element}>"
- "syntax-temp-#{ident}"
- }
- title = RedCloth.new(title_text).to_html.gsub(%r!<.*?>!,'').strip
- body = RedCloth.new(body_text).to_html
- body.gsub!(%r!(?:<pre><code>)?syntax-temp-(\d+)(?:</code></pre>)?!){ syntax_items[$1.to_i] }
-end
-stat = File.stat(src)
-created = stat.ctime
-modified = stat.mtime
-
-$stdout << template.result(binding)
diff --git a/vendor/plugins/googlecharts/setup.rb b/vendor/plugins/googlecharts/setup.rb
deleted file mode 100644
index 424a5f3..0000000
--- a/vendor/plugins/googlecharts/setup.rb
+++ /dev/null
@@ -1,1585 +0,0 @@
-#
-# setup.rb
-#
-# Copyright (c) 2000-2005 Minero Aoki
-#
-# This program is free software.
-# You can distribute/modify this program under the terms of
-# the GNU LGPL, Lesser General Public License version 2.1.
-#
-
-unless Enumerable.method_defined?(:map) # Ruby 1.4.6
- module Enumerable
- alias map collect
- end
-end
-
-unless File.respond_to?(:read) # Ruby 1.6
- def File.read(fname)
- open(fname) {|f|
- return f.read
- }
- end
-end
-
-unless Errno.const_defined?(:ENOTEMPTY) # Windows?
- module Errno
- class ENOTEMPTY
- # We do not raise this exception, implementation is not needed.
- end
- end
-end
-
-def File.binread(fname)
- open(fname, 'rb') {|f|
- return f.read
- }
-end
-
-# for corrupted Windows' stat(2)
-def File.dir?(path)
- File.directory?((path[-1,1] == '/') ? path : path + '/')
-end
-
-
-class ConfigTable
-
- include Enumerable
-
- def initialize(rbconfig)
- @rbconfig = rbconfig
- @items = []
- @table = {}
- # options
- @install_prefix = nil
- @config_opt = nil
- @verbose = true
- @no_harm = false
- end
-
- attr_accessor :install_prefix
- attr_accessor :config_opt
-
- attr_writer :verbose
-
- def verbose?
- @verbose
- end
-
- attr_writer :no_harm
-
- def no_harm?
- @no_harm
- end
-
- def [](key)
- lookup(key).resolve(self)
- end
-
- def []=(key, val)
- lookup(key).set val
- end
-
- def names
- @items.map {|i| i.name }
- end
-
- def each(&block)
- @items.each(&block)
- end
-
- def key?(name)
- @table.key?(name)
- end
-
- def lookup(name)
- @table[name] or setup_rb_error "no such config item: #{name}"
- end
-
- def add(item)
- @items.push item
- @table[item.name] = item
- end
-
- def remove(name)
- item = lookup(name)
- @items.delete_if {|i| i.name == name }
- @table.delete_if {|name, i| i.name == name }
- item
- end
-
- def load_script(path, inst = nil)
- if File.file?(path)
- MetaConfigEnvironment.new(self, inst).instance_eval File.read(path), path
- end
- end
-
- def savefile
- '.config'
- end
-
- def load_savefile
- begin
- File.foreach(savefile()) do |line|
- k, v = *line.split(/=/, 2)
- self[k] = v.strip
- end
- rescue Errno::ENOENT
- setup_rb_error $!.message + "\n#{File.basename($0)} config first"
- end
- end
-
- def save
- @items.each {|i| i.value }
- File.open(savefile(), 'w') {|f|
- @items.each do |i|
- f.printf "%s=%s\n", i.name, i.value if i.value? and i.value
- end
- }
- end
-
- def load_standard_entries
- standard_entries(@rbconfig).each do |ent|
- add ent
- end
- end
-
- def standard_entries(rbconfig)
- c = rbconfig
-
- rubypath = File.join(c['bindir'], c['ruby_install_name'] + c['EXEEXT'])
-
- major = c['MAJOR'].to_i
- minor = c['MINOR'].to_i
- teeny = c['TEENY'].to_i
- version = "#{major}.#{minor}"
-
- # ruby ver. >= 1.4.4?
- newpath_p = ((major >= 2) or
- ((major == 1) and
- ((minor >= 5) or
- ((minor == 4) and (teeny >= 4)))))
-
- if c['rubylibdir']
- # V > 1.6.3
- libruby = "#{c['prefix']}/lib/ruby"
- librubyver = c['rubylibdir']
- librubyverarch = c['archdir']
- siteruby = c['sitedir']
- siterubyver = c['sitelibdir']
- siterubyverarch = c['sitearchdir']
- elsif newpath_p
- # 1.4.4 <= V <= 1.6.3
- libruby = "#{c['prefix']}/lib/ruby"
- librubyver = "#{c['prefix']}/lib/ruby/#{version}"
- librubyverarch = "#{c['prefix']}/lib/ruby/#{version}/#{c['arch']}"
- siteruby = c['sitedir']
- siterubyver = "$siteruby/#{version}"
- siterubyverarch = "$siterubyver/#{c['arch']}"
- else
- # V < 1.4.4
- libruby = "#{c['prefix']}/lib/ruby"
- librubyver = "#{c['prefix']}/lib/ruby/#{version}"
- librubyverarch = "#{c['prefix']}/lib/ruby/#{version}/#{c['arch']}"
- siteruby = "#{c['prefix']}/lib/ruby/#{version}/site_ruby"
- siterubyver = siteruby
- siterubyverarch = "$siterubyver/#{c['arch']}"
- end
- parameterize = lambda {|path|
- path.sub(/\A#{Regexp.quote(c['prefix'])}/, '$prefix')
- }
-
- if arg = c['configure_args'].split.detect {|arg| /--with-make-prog=/ =~ arg }
- makeprog = arg.sub(/'/, '').split(/=/, 2)[1]
- else
- makeprog = 'make'
- end
-
- [
- ExecItem.new('installdirs', 'std/site/home',
- 'std: install under libruby; site: install under site_ruby; home: install under $HOME')\
- {|val, table|
- case val
- when 'std'
- table['rbdir'] = '$librubyver'
- table['sodir'] = '$librubyverarch'
- when 'site'
- table['rbdir'] = '$siterubyver'
- table['sodir'] = '$siterubyverarch'
- when 'home'
- setup_rb_error '$HOME was not set' unless ENV['HOME']
- table['prefix'] = ENV['HOME']
- table['rbdir'] = '$libdir/ruby'
- table['sodir'] = '$libdir/ruby'
- end
- },
- PathItem.new('prefix', 'path', c['prefix'],
- 'path prefix of target environment'),
- PathItem.new('bindir', 'path', parameterize.call(c['bindir']),
- 'the directory for commands'),
- PathItem.new('libdir', 'path', parameterize.call(c['libdir']),
- 'the directory for libraries'),
- PathItem.new('datadir', 'path', parameterize.call(c['datadir']),
- 'the directory for shared data'),
- PathItem.new('mandir', 'path', parameterize.call(c['mandir']),
- 'the directory for man pages'),
- PathItem.new('sysconfdir', 'path', parameterize.call(c['sysconfdir']),
- 'the directory for system configuration files'),
- PathItem.new('localstatedir', 'path', parameterize.call(c['localstatedir']),
- 'the directory for local state data'),
- PathItem.new('libruby', 'path', libruby,
- 'the directory for ruby libraries'),
- PathItem.new('librubyver', 'path', librubyver,
- 'the directory for standard ruby libraries'),
- PathItem.new('librubyverarch', 'path', librubyverarch,
- 'the directory for standard ruby extensions'),
- PathItem.new('siteruby', 'path', siteruby,
- 'the directory for version-independent aux ruby libraries'),
- PathItem.new('siterubyver', 'path', siterubyver,
- 'the directory for aux ruby libraries'),
- PathItem.new('siterubyverarch', 'path', siterubyverarch,
- 'the directory for aux ruby binaries'),
- PathItem.new('rbdir', 'path', '$siterubyver',
- 'the directory for ruby scripts'),
- PathItem.new('sodir', 'path', '$siterubyverarch',
- 'the directory for ruby extentions'),
- PathItem.new('rubypath', 'path', rubypath,
- 'the path to set to #! line'),
- ProgramItem.new('rubyprog', 'name', rubypath,
- 'the ruby program using for installation'),
- ProgramItem.new('makeprog', 'name', makeprog,
- 'the make program to compile ruby extentions'),
- SelectItem.new('shebang', 'all/ruby/never', 'ruby',
- 'shebang line (#!) editing mode'),
- BoolItem.new('without-ext', 'yes/no', 'no',
- 'does not compile/install ruby extentions')
- ]
- end
- private :standard_entries
-
- def load_multipackage_entries
- multipackage_entries().each do |ent|
- add ent
- end
- end
-
- def multipackage_entries
- [
- PackageSelectionItem.new('with', 'name,name...', '', 'ALL',
- 'package names that you want to install'),
- PackageSelectionItem.new('without', 'name,name...', '', 'NONE',
- 'package names that you do not want to install')
- ]
- end
- private :multipackage_entries
-
- ALIASES = {
- 'std-ruby' => 'librubyver',
- 'stdruby' => 'librubyver',
- 'rubylibdir' => 'librubyver',
- 'archdir' => 'librubyverarch',
- 'site-ruby-common' => 'siteruby', # For backward compatibility
- 'site-ruby' => 'siterubyver', # For backward compatibility
- 'bin-dir' => 'bindir',
- 'bin-dir' => 'bindir',
- 'rb-dir' => 'rbdir',
- 'so-dir' => 'sodir',
- 'data-dir' => 'datadir',
- 'ruby-path' => 'rubypath',
- 'ruby-prog' => 'rubyprog',
- 'ruby' => 'rubyprog',
- 'make-prog' => 'makeprog',
- 'make' => 'makeprog'
- }
-
- def fixup
- ALIASES.each do |ali, name|
- @table[ali] = @table[name]
- end
- @items.freeze
- @table.freeze
- @options_re = /\A--(#{@table.keys.join('|')})(?:=(.*))?\z/
- end
-
- def parse_opt(opt)
- m = @options_re.match(opt) or setup_rb_error "config: unknown option #{opt}"
- m.to_a[1,2]
- end
-
- def dllext
- @rbconfig['DLEXT']
- end
-
- def value_config?(name)
- lookup(name).value?
- end
-
- class Item
- def initialize(name, template, default, desc)
- @name = name.freeze
- @template = template
- @value = default
- @default = default
- @description = desc
- end
-
- attr_reader :name
- attr_reader :description
-
- attr_accessor :default
- alias help_default default
-
- def help_opt
- "--#{@name}=#{@template}"
- end
-
- def value?
- true
- end
-
- def value
- @value
- end
-
- def resolve(table)
- @value.gsub(%r<\$([^/]+)>) { table[$1] }
- end
-
- def set(val)
- @value = check(val)
- end
-
- private
-
- def check(val)
- setup_rb_error "config: --#{name} requires argument" unless val
- val
- end
- end
-
- class BoolItem < Item
- def config_type
- 'bool'
- end
-
- def help_opt
- "--#{@name}"
- end
-
- private
-
- def check(val)
- return 'yes' unless val
- case val
- when /\Ay(es)?\z/i, /\At(rue)?\z/i then 'yes'
- when /\An(o)?\z/i, /\Af(alse)\z/i then 'no'
- else
- setup_rb_error "config: --#{@name} accepts only yes/no for argument"
- end
- end
- end
-
- class PathItem < Item
- def config_type
- 'path'
- end
-
- private
-
- def check(path)
- setup_rb_error "config: --#{@name} requires argument" unless path
- path[0,1] == '$' ? path : File.expand_path(path)
- end
- end
-
- class ProgramItem < Item
- def config_type
- 'program'
- end
- end
-
- class SelectItem < Item
- def initialize(name, selection, default, desc)
- super
- @ok = selection.split('/')
- end
-
- def config_type
- 'select'
- end
-
- private
-
- def check(val)
- unless @ok.include?(val.strip)
- setup_rb_error "config: use --#{@name}=#{@template} (#{val})"
- end
- val.strip
- end
- end
-
- class ExecItem < Item
- def initialize(name, selection, desc, &block)
- super name, selection, nil, desc
- @ok = selection.split('/')
- @action = block
- end
-
- def config_type
- 'exec'
- end
-
- def value?
- false
- end
-
- def resolve(table)
- setup_rb_error "$#{name()} wrongly used as option value"
- end
-
- undef set
-
- def evaluate(val, table)
- v = val.strip.downcase
- unless @ok.include?(v)
- setup_rb_error "invalid option --#{@name}=#{val} (use #{@template})"
- end
- @action.call v, table
- end
- end
-
- class PackageSelectionItem < Item
- def initialize(name, template, default, help_default, desc)
- super name, template, default, desc
- @help_default = help_default
- end
-
- attr_reader :help_default
-
- def config_type
- 'package'
- end
-
- private
-
- def check(val)
- unless File.dir?("packages/#{val}")
- setup_rb_error "config: no such package: #{val}"
- end
- val
- end
- end
-
- class MetaConfigEnvironment
- def initialize(config, installer)
- @config = config
- @installer = installer
- end
-
- def config_names
- @config.names
- end
-
- def config?(name)
- @config.key?(name)
- end
-
- def bool_config?(name)
- @config.lookup(name).config_type == 'bool'
- end
-
- def path_config?(name)
- @config.lookup(name).config_type == 'path'
- end
-
- def value_config?(name)
- @config.lookup(name).config_type != 'exec'
- end
-
- def add_config(item)
- @config.add item
- end
-
- def add_bool_config(name, default, desc)
- @config.add BoolItem.new(name, 'yes/no', default ? 'yes' : 'no', desc)
- end
-
- def add_path_config(name, default, desc)
- @config.add PathItem.new(name, 'path', default, desc)
- end
-
- def set_config_default(name, default)
- @config.lookup(name).default = default
- end
-
- def remove_config(name)
- @config.remove(name)
- end
-
- # For only multipackage
- def packages
- raise '[setup.rb fatal] multi-package metaconfig API packages() called for single-package; contact application package vendor' unless @installer
- @installer.packages
- end
-
- # For only multipackage
- def declare_packages(list)
- raise '[setup.rb fatal] multi-package metaconfig API declare_packages() called for single-package; contact application package vendor' unless @installer
- @installer.packages = list
- end
- end
-
-end # class ConfigTable
-
-
-# This module requires: #verbose?, #no_harm?
-module FileOperations
-
- def mkdir_p(dirname, prefix = nil)
- dirname = prefix + File.expand_path(dirname) if prefix
- $stderr.puts "mkdir -p #{dirname}" if verbose?
- return if no_harm?
-
- # Does not check '/', it's too abnormal.
- dirs = File.expand_path(dirname).split(%r<(?=/)>)
- if /\A[a-z]:\z/i =~ dirs[0]
- disk = dirs.shift
- dirs[0] = disk + dirs[0]
- end
- dirs.each_index do |idx|
- path = dirs[0..idx].join('')
- Dir.mkdir path unless File.dir?(path)
- end
- end
-
- def rm_f(path)
- $stderr.puts "rm -f #{path}" if verbose?
- return if no_harm?
- force_remove_file path
- end
-
- def rm_rf(path)
- $stderr.puts "rm -rf #{path}" if verbose?
- return if no_harm?
- remove_tree path
- end
-
- def remove_tree(path)
- if File.symlink?(path)
- remove_file path
- elsif File.dir?(path)
- remove_tree0 path
- else
- force_remove_file path
- end
- end
-
- def remove_tree0(path)
- Dir.foreach(path) do |ent|
- next if ent == '.'
- next if ent == '..'
- entpath = "#{path}/#{ent}"
- if File.symlink?(entpath)
- remove_file entpath
- elsif File.dir?(entpath)
- remove_tree0 entpath
- else
- force_remove_file entpath
- end
- end
- begin
- Dir.rmdir path
- rescue Errno::ENOTEMPTY
- # directory may not be empty
- end
- end
-
- def move_file(src, dest)
- force_remove_file dest
- begin
- File.rename src, dest
- rescue
- File.open(dest, 'wb') {|f|
- f.write File.binread(src)
- }
- File.chmod File.stat(src).mode, dest
- File.unlink src
- end
- end
-
- def force_remove_file(path)
- begin
- remove_file path
- rescue
- end
- end
-
- def remove_file(path)
- File.chmod 0777, path
- File.unlink path
- end
-
- def install(from, dest, mode, prefix = nil)
- $stderr.puts "install #{from} #{dest}" if verbose?
- return if no_harm?
-
- realdest = prefix ? prefix + File.expand_path(dest) : dest
- realdest = File.join(realdest, File.basename(from)) if File.dir?(realdest)
- str = File.binread(from)
- if diff?(str, realdest)
- verbose_off {
- rm_f realdest if File.exist?(realdest)
- }
- File.open(realdest, 'wb') {|f|
- f.write str
- }
- File.chmod mode, realdest
-
- File.open("#{objdir_root()}/InstalledFiles", 'a') {|f|
- if prefix
- f.puts realdest.sub(prefix, '')
- else
- f.puts realdest
- end
- }
- end
- end
-
- def diff?(new_content, path)
- return true unless File.exist?(path)
- new_content != File.binread(path)
- end
-
- def command(*args)
- $stderr.puts args.join(' ') if verbose?
- system(*args) or raise RuntimeError,
- "system(#{args.map{|a| a.inspect }.join(' ')}) failed"
- end
-
- def ruby(*args)
- command config('rubyprog'), *args
- end
-
- def make(task = nil)
- command(*[config('makeprog'), task].compact)
- end
-
- def extdir?(dir)
- File.exist?("#{dir}/MANIFEST") or File.exist?("#{dir}/extconf.rb")
- end
-
- def files_of(dir)
- Dir.open(dir) {|d|
- return d.select {|ent| File.file?("#{dir}/#{ent}") }
- }
- end
-
- DIR_REJECT = %w( . .. CVS SCCS RCS CVS.adm .svn )
-
- def directories_of(dir)
- Dir.open(dir) {|d|
- return d.select {|ent| File.dir?("#{dir}/#{ent}") } - DIR_REJECT
- }
- end
-
-end
-
-
-# This module requires: #srcdir_root, #objdir_root, #relpath
-module HookScriptAPI
-
- def get_config(key)
- @config[key]
- end
-
- alias config get_config
-
- # obsolete: use metaconfig to change configuration
- def set_config(key, val)
- @config[key] = val
- end
-
- #
- # srcdir/objdir (works only in the package directory)
- #
-
- def curr_srcdir
- "#{srcdir_root()}/#{relpath()}"
- end
-
- def curr_objdir
- "#{objdir_root()}/#{relpath()}"
- end
-
- def srcfile(path)
- "#{curr_srcdir()}/#{path}"
- end
-
- def srcexist?(path)
- File.exist?(srcfile(path))
- end
-
- def srcdirectory?(path)
- File.dir?(srcfile(path))
- end
-
- def srcfile?(path)
- File.file?(srcfile(path))
- end
-
- def srcentries(path = '.')
- Dir.open("#{curr_srcdir()}/#{path}") {|d|
- return d.to_a - %w(. ..)
- }
- end
-
- def srcfiles(path = '.')
- srcentries(path).select {|fname|
- File.file?(File.join(curr_srcdir(), path, fname))
- }
- end
-
- def srcdirectories(path = '.')
- srcentries(path).select {|fname|
- File.dir?(File.join(curr_srcdir(), path, fname))
- }
- end
-
-end
-
-
-class ToplevelInstaller
-
- Version = '3.4.1'
- Copyright = 'Copyright (c) 2000-2005 Minero Aoki'
-
- TASKS = [
- [ 'all', 'do config, setup, then install' ],
- [ 'config', 'saves your configurations' ],
- [ 'show', 'shows current configuration' ],
- [ 'setup', 'compiles ruby extentions and others' ],
- [ 'install', 'installs files' ],
- [ 'test', 'run all tests in test/' ],
- [ 'clean', "does `make clean' for each extention" ],
- [ 'distclean',"does `make distclean' for each extention" ]
- ]
-
- def ToplevelInstaller.invoke
- config = ConfigTable.new(load_rbconfig())
- config.load_standard_entries
- config.load_multipackage_entries if multipackage?
- config.fixup
- klass = (multipackage?() ? ToplevelInstallerMulti : ToplevelInstaller)
- klass.new(File.dirname($0), config).invoke
- end
-
- def ToplevelInstaller.multipackage?
- File.dir?(File.dirname($0) + '/packages')
- end
-
- def ToplevelInstaller.load_rbconfig
- if arg = ARGV.detect {|arg| /\A--rbconfig=/ =~ arg }
- ARGV.delete(arg)
- load File.expand_path(arg.split(/=/, 2)[1])
- $".push 'rbconfig.rb'
- else
- require 'rbconfig'
- end
- ::Config::CONFIG
- end
-
- def initialize(ardir_root, config)
- @ardir = File.expand_path(ardir_root)
- @config = config
- # cache
- @valid_task_re = nil
- end
-
- def config(key)
- @config[key]
- end
-
- def inspect
- "#<#{self.class} #{__id__()}>"
- end
-
- def invoke
- run_metaconfigs
- case task = parsearg_global()
- when nil, 'all'
- parsearg_config
- init_installers
- exec_config
- exec_setup
- exec_install
- else
- case task
- when 'config', 'test'
- ;
- when 'clean', 'distclean'
- @config.load_savefile if File.exist?(@config.savefile)
- else
- @config.load_savefile
- end
- __send__ "parsearg_#{task}"
- init_installers
- __send__ "exec_#{task}"
- end
- end
-
- def run_metaconfigs
- @config.load_script "#{@ardir}/metaconfig"
- end
-
- def init_installers
- @installer = Installer.new(@config, @ardir, File.expand_path('.'))
- end
-
- #
- # Hook Script API bases
- #
-
- def srcdir_root
- @ardir
- end
-
- def objdir_root
- '.'
- end
-
- def relpath
- '.'
- end
-
- #
- # Option Parsing
- #
-
- def parsearg_global
- while arg = ARGV.shift
- case arg
- when /\A\w+\z/
- setup_rb_error "invalid task: #{arg}" unless valid_task?(arg)
- return arg
- when '-q', '--quiet'
- @config.verbose = false
- when '--verbose'
- @config.verbose = true
- when '--help'
- print_usage $stdout
- exit 0
- when '--version'
- puts "#{File.basename($0)} version #{Version}"
- exit 0
- when '--copyright'
- puts Copyright
- exit 0
- else
- setup_rb_error "unknown global option '#{arg}'"
- end
- end
- nil
- end
-
- def valid_task?(t)
- valid_task_re() =~ t
- end
-
- def valid_task_re
- @valid_task_re ||= /\A(?:#{TASKS.map {|task,desc| task }.join('|')})\z/
- end
-
- def parsearg_no_options
- unless ARGV.empty?
- task = caller(0).first.slice(%r<`parsearg_(\w+)'>, 1)
- setup_rb_error "#{task}: unknown options: #{ARGV.join(' ')}"
- end
- end
-
- alias parsearg_show parsearg_no_options
- alias parsearg_setup parsearg_no_options
- alias parsearg_test parsearg_no_options
- alias parsearg_clean parsearg_no_options
- alias parsearg_distclean parsearg_no_options
-
- def parsearg_config
- evalopt = []
- set = []
- @config.config_opt = []
- while i = ARGV.shift
- if /\A--?\z/ =~ i
- @config.config_opt = ARGV.dup
- break
- end
- name, value = *@config.parse_opt(i)
- if @config.value_config?(name)
- @config[name] = value
- else
- evalopt.push [name, value]
- end
- set.push name
- end
- evalopt.each do |name, value|
- @config.lookup(name).evaluate value, @config
- end
- # Check if configuration is valid
- set.each do |n|
- @config[n] if @config.value_config?(n)
- end
- end
-
- def parsearg_install
- @config.no_harm = false
- @config.install_prefix = ''
- while a = ARGV.shift
- case a
- when '--no-harm'
- @config.no_harm = true
- when /\A--prefix=/
- path = a.split(/=/, 2)[1]
- path = File.expand_path(path) unless path[0,1] == '/'
- @config.install_prefix = path
- else
- setup_rb_error "install: unknown option #{a}"
- end
- end
- end
-
- def print_usage(out)
- out.puts 'Typical Installation Procedure:'
- out.puts " $ ruby #{File.basename $0} config"
- out.puts " $ ruby #{File.basename $0} setup"
- out.puts " # ruby #{File.basename $0} install (may require root privilege)"
- out.puts
- out.puts 'Detailed Usage:'
- out.puts " ruby #{File.basename $0} <global option>"
- out.puts " ruby #{File.basename $0} [<global options>] <task> [<task options>]"
-
- fmt = " %-24s %s\n"
- out.puts
- out.puts 'Global options:'
- out.printf fmt, '-q,--quiet', 'suppress message outputs'
- out.printf fmt, ' --verbose', 'output messages verbosely'
- out.printf fmt, ' --help', 'print this message'
- out.printf fmt, ' --version', 'print version and quit'
- out.printf fmt, ' --copyright', 'print copyright and quit'
- out.puts
- out.puts 'Tasks:'
- TASKS.each do |name, desc|
- out.printf fmt, name, desc
- end
-
- fmt = " %-24s %s [%s]\n"
- out.puts
- out.puts 'Options for CONFIG or ALL:'
- @config.each do |item|
- out.printf fmt, item.help_opt, item.description, item.help_default
- end
- out.printf fmt, '--rbconfig=path', 'rbconfig.rb to load',"running ruby's"
- out.puts
- out.puts 'Options for INSTALL:'
- out.printf fmt, '--no-harm', 'only display what to do if given', 'off'
- out.printf fmt, '--prefix=path', 'install path prefix', ''
- out.puts
- end
-
- #
- # Task Handlers
- #
-
- def exec_config
- @installer.exec_config
- @config.save # must be final
- end
-
- def exec_setup
- @installer.exec_setup
- end
-
- def exec_install
- @installer.exec_install
- end
-
- def exec_test
- @installer.exec_test
- end
-
- def exec_show
- @config.each do |i|
- printf "%-20s %s\n", i.name, i.value if i.value?
- end
- end
-
- def exec_clean
- @installer.exec_clean
- end
-
- def exec_distclean
- @installer.exec_distclean
- end
-
-end # class ToplevelInstaller
-
-
-class ToplevelInstallerMulti < ToplevelInstaller
-
- include FileOperations
-
- def initialize(ardir_root, config)
- super
- @packages = directories_of("#{@ardir}/packages")
- raise 'no package exists' if @packages.empty?
- @root_installer = Installer.new(@config, @ardir, File.expand_path('.'))
- end
-
- def run_metaconfigs
- @config.load_script "#{@ardir}/metaconfig", self
- @packages.each do |name|
- @config.load_script "#{@ardir}/packages/#{name}/metaconfig"
- end
- end
-
- attr_reader :packages
-
- def packages=(list)
- raise 'package list is empty' if list.empty?
- list.each do |name|
- raise "directory packages/#{name} does not exist"\
- unless File.dir?("#{@ardir}/packages/#{name}")
- end
- @packages = list
- end
-
- def init_installers
- @installers = {}
- @packages.each do |pack|
- @installers[pack] = Installer.new(@config,
- "#{@ardir}/packages/#{pack}",
- "packages/#{pack}")
- end
- with = extract_selection(config('with'))
- without = extract_selection(config('without'))
- @selected = @installers.keys.select {|name|
- (with.empty? or with.include?(name)) \
- and not without.include?(name)
- }
- end
-
- def extract_selection(list)
- a = list.split(/,/)
- a.each do |name|
- setup_rb_error "no such package: #{name}" unless @installers.key?(name)
- end
- a
- end
-
- def print_usage(f)
- super
- f.puts 'Inluded packages:'
- f.puts ' ' + @packages.sort.join(' ')
- f.puts
- end
-
- #
- # Task Handlers
- #
-
- def exec_config
- run_hook 'pre-config'
- each_selected_installers {|inst| inst.exec_config }
- run_hook 'post-config'
- @config.save # must be final
- end
-
- def exec_setup
- run_hook 'pre-setup'
- each_selected_installers {|inst| inst.exec_setup }
- run_hook 'post-setup'
- end
-
- def exec_install
- run_hook 'pre-install'
- each_selected_installers {|inst| inst.exec_install }
- run_hook 'post-install'
- end
-
- def exec_test
- run_hook 'pre-test'
- each_selected_installers {|inst| inst.exec_test }
- run_hook 'post-test'
- end
-
- def exec_clean
- rm_f @config.savefile
- run_hook 'pre-clean'
- each_selected_installers {|inst| inst.exec_clean }
- run_hook 'post-clean'
- end
-
- def exec_distclean
- rm_f @config.savefile
- run_hook 'pre-distclean'
- each_selected_installers {|inst| inst.exec_distclean }
- run_hook 'post-distclean'
- end
-
- #
- # lib
- #
-
- def each_selected_installers
- Dir.mkdir 'packages' unless File.dir?('packages')
- @selected.each do |pack|
- $stderr.puts "Processing the package `#{pack}' ..." if verbose?
- Dir.mkdir "packages/#{pack}" unless File.dir?("packages/#{pack}")
- Dir.chdir "packages/#{pack}"
- yield @installers[pack]
- Dir.chdir '../..'
- end
- end
-
- def run_hook(id)
- @root_installer.run_hook id
- end
-
- # module FileOperations requires this
- def verbose?
- @config.verbose?
- end
-
- # module FileOperations requires this
- def no_harm?
- @config.no_harm?
- end
-
-end # class ToplevelInstallerMulti
-
-
-class Installer
-
- FILETYPES = %w( bin lib ext data conf man )
-
- include FileOperations
- include HookScriptAPI
-
- def initialize(config, srcroot, objroot)
- @config = config
- @srcdir = File.expand_path(srcroot)
- @objdir = File.expand_path(objroot)
- @currdir = '.'
- end
-
- def inspect
- "#<#{self.class} #{File.basename(@srcdir)}>"
- end
-
- def noop(rel)
- end
-
- #
- # Hook Script API base methods
- #
-
- def srcdir_root
- @srcdir
- end
-
- def objdir_root
- @objdir
- end
-
- def relpath
- @currdir
- end
-
- #
- # Config Access
- #
-
- # module FileOperations requires this
- def verbose?
- @config.verbose?
- end
-
- # module FileOperations requires this
- def no_harm?
- @config.no_harm?
- end
-
- def verbose_off
- begin
- save, @config.verbose = @config.verbose?, false
- yield
- ensure
- @config.verbose = save
- end
- end
-
- #
- # TASK config
- #
-
- def exec_config
- exec_task_traverse 'config'
- end
-
- alias config_dir_bin noop
- alias config_dir_lib noop
-
- def config_dir_ext(rel)
- extconf if extdir?(curr_srcdir())
- end
-
- alias config_dir_data noop
- alias config_dir_conf noop
- alias config_dir_man noop
-
- def extconf
- ruby "#{curr_srcdir()}/extconf.rb", *@config.config_opt
- end
-
- #
- # TASK setup
- #
-
- def exec_setup
- exec_task_traverse 'setup'
- end
-
- def setup_dir_bin(rel)
- files_of(curr_srcdir()).each do |fname|
- update_shebang_line "#{curr_srcdir()}/#{fname}"
- end
- end
-
- alias setup_dir_lib noop
-
- def setup_dir_ext(rel)
- make if extdir?(curr_srcdir())
- end
-
- alias setup_dir_data noop
- alias setup_dir_conf noop
- alias setup_dir_man noop
-
- def update_shebang_line(path)
- return if no_harm?
- return if config('shebang') == 'never'
- old = Shebang.load(path)
- if old
- $stderr.puts "warning: #{path}: Shebang line includes too many args. It is not portable and your program may not work." if old.args.size > 1
- new = new_shebang(old)
- return if new.to_s == old.to_s
- else
- return unless config('shebang') == 'all'
- new = Shebang.new(config('rubypath'))
- end
- $stderr.puts "updating shebang: #{File.basename(path)}" if verbose?
- open_atomic_writer(path) {|output|
- File.open(path, 'rb') {|f|
- f.gets if old # discard
- output.puts new.to_s
- output.print f.read
- }
- }
- end
-
- def new_shebang(old)
- if /\Aruby/ =~ File.basename(old.cmd)
- Shebang.new(config('rubypath'), old.args)
- elsif File.basename(old.cmd) == 'env' and old.args.first == 'ruby'
- Shebang.new(config('rubypath'), old.args[1..-1])
- else
- return old unless config('shebang') == 'all'
- Shebang.new(config('rubypath'))
- end
- end
-
- def open_atomic_writer(path, &block)
- tmpfile = File.basename(path) + '.tmp'
- begin
- File.open(tmpfile, 'wb', &block)
- File.rename tmpfile, File.basename(path)
- ensure
- File.unlink tmpfile if File.exist?(tmpfile)
- end
- end
-
- class Shebang
- def Shebang.load(path)
- line = nil
- File.open(path) {|f|
- line = f.gets
- }
- return nil unless /\A#!/ =~ line
- parse(line)
- end
-
- def Shebang.parse(line)
- cmd, *args = *line.strip.sub(/\A\#!/, '').split(' ')
- new(cmd, args)
- end
-
- def initialize(cmd, args = [])
- @cmd = cmd
- @args = args
- end
-
- attr_reader :cmd
- attr_reader :args
-
- def to_s
- "#! #{@cmd}" + (@args.empty? ? '' : " #{@args.join(' ')}")
- end
- end
-
- #
- # TASK install
- #
-
- def exec_install
- rm_f 'InstalledFiles'
- exec_task_traverse 'install'
- end
-
- def install_dir_bin(rel)
- install_files targetfiles(), "#{config('bindir')}/#{rel}", 0755
- end
-
- def install_dir_lib(rel)
- install_files libfiles(), "#{config('rbdir')}/#{rel}", 0644
- end
-
- def install_dir_ext(rel)
- return unless extdir?(curr_srcdir())
- install_files rubyextentions('.'),
- "#{config('sodir')}/#{File.dirname(rel)}",
- 0555
- end
-
- def install_dir_data(rel)
- install_files targetfiles(), "#{config('datadir')}/#{rel}", 0644
- end
-
- def install_dir_conf(rel)
- # FIXME: should not remove current config files
- # (rename previous file to .old/.org)
- install_files targetfiles(), "#{config('sysconfdir')}/#{rel}", 0644
- end
-
- def install_dir_man(rel)
- install_files targetfiles(), "#{config('mandir')}/#{rel}", 0644
- end
-
- def install_files(list, dest, mode)
- mkdir_p dest, @config.install_prefix
- list.each do |fname|
- install fname, dest, mode, @config.install_prefix
- end
- end
-
- def libfiles
- glob_reject(%w(*.y *.output), targetfiles())
- end
-
- def rubyextentions(dir)
- ents = glob_select("*.#{@config.dllext}", targetfiles())
- if ents.empty?
- setup_rb_error "no ruby extention exists: 'ruby #{$0} setup' first"
- end
- ents
- end
-
- def targetfiles
- mapdir(existfiles() - hookfiles())
- end
-
- def mapdir(ents)
- ents.map {|ent|
- if File.exist?(ent)
- then ent # objdir
- else "#{curr_srcdir()}/#{ent}" # srcdir
- end
- }
- end
-
- # picked up many entries from cvs-1.11.1/src/ignore.c
- JUNK_FILES = %w(
- core RCSLOG tags TAGS .make.state
- .nse_depinfo #* .#* cvslog.* ,* .del-* *.olb
- *~ *.old *.bak *.BAK *.orig *.rej _$* *$
-
- *.org *.in .*
- )
-
- def existfiles
- glob_reject(JUNK_FILES, (files_of(curr_srcdir()) | files_of('.')))
- end
-
- def hookfiles
- %w( pre-%s post-%s pre-%s.rb post-%s.rb ).map {|fmt|
- %w( config setup install clean ).map {|t| sprintf(fmt, t) }
- }.flatten
- end
-
- def glob_select(pat, ents)
- re = globs2re([pat])
- ents.select {|ent| re =~ ent }
- end
-
- def glob_reject(pats, ents)
- re = globs2re(pats)
- ents.reject {|ent| re =~ ent }
- end
-
- GLOB2REGEX = {
- '.' => '\.',
- '$' => '\$',
- '#' => '\#',
- '*' => '.*'
- }
-
- def globs2re(pats)
- /\A(?:#{
- pats.map {|pat| pat.gsub(/[\.\$\#\*]/) {|ch| GLOB2REGEX[ch] } }.join('|')
- })\z/
- end
-
- #
- # TASK test
- #
-
- TESTDIR = 'test'
-
- def exec_test
- unless File.directory?('test')
- $stderr.puts 'no test in this package' if verbose?
- return
- end
- $stderr.puts 'Running tests...' if verbose?
- begin
- require 'test/unit'
- rescue LoadError
- setup_rb_error 'test/unit cannot loaded. You need Ruby 1.8 or later to invoke this task.'
- end
- runner = Test::Unit::AutoRunner.new(true)
- runner.to_run << TESTDIR
- runner.run
- end
-
- #
- # TASK clean
- #
-
- def exec_clean
- exec_task_traverse 'clean'
- rm_f @config.savefile
- rm_f 'InstalledFiles'
- end
-
- alias clean_dir_bin noop
- alias clean_dir_lib noop
- alias clean_dir_data noop
- alias clean_dir_conf noop
- alias clean_dir_man noop
-
- def clean_dir_ext(rel)
- return unless extdir?(curr_srcdir())
- make 'clean' if File.file?('Makefile')
- end
-
- #
- # TASK distclean
- #
-
- def exec_distclean
- exec_task_traverse 'distclean'
- rm_f @config.savefile
- rm_f 'InstalledFiles'
- end
-
- alias distclean_dir_bin noop
- alias distclean_dir_lib noop
-
- def distclean_dir_ext(rel)
- return unless extdir?(curr_srcdir())
- make 'distclean' if File.file?('Makefile')
- end
-
- alias distclean_dir_data noop
- alias distclean_dir_conf noop
- alias distclean_dir_man noop
-
- #
- # Traversing
- #
-
- def exec_task_traverse(task)
- run_hook "pre-#{task}"
- FILETYPES.each do |type|
- if type == 'ext' and config('without-ext') == 'yes'
- $stderr.puts 'skipping ext/* by user option' if verbose?
- next
- end
- traverse task, type, "#{task}_dir_#{type}"
- end
- run_hook "post-#{task}"
- end
-
- def traverse(task, rel, mid)
- dive_into(rel) {
- run_hook "pre-#{task}"
- __send__ mid, rel.sub(%r[\A.*?(?:/|\z)], '')
- directories_of(curr_srcdir()).each do |d|
- traverse task, "#{rel}/#{d}", mid
- end
- run_hook "post-#{task}"
- }
- end
-
- def dive_into(rel)
- return unless File.dir?("#{@srcdir}/#{rel}")
-
- dir = File.basename(rel)
- Dir.mkdir dir unless File.dir?(dir)
- prevdir = Dir.pwd
- Dir.chdir dir
- $stderr.puts '---> ' + rel if verbose?
- @currdir = rel
- yield
- Dir.chdir prevdir
- $stderr.puts '<--- ' + rel if verbose?
- @currdir = File.dirname(rel)
- end
-
- def run_hook(id)
- path = [ "#{curr_srcdir()}/#{id}",
- "#{curr_srcdir()}/#{id}.rb" ].detect {|cand| File.file?(cand) }
- return unless path
- begin
- instance_eval File.read(path), path, 1
- rescue
- raise if $DEBUG
- setup_rb_error "hook #{path} failed:\n" + $!.message
- end
- end
-
-end # class Installer
-
-
-class SetupError < StandardError; end
-
-def setup_rb_error(msg)
- raise SetupError, msg
-end
-
-if $0 == __FILE__
- begin
- ToplevelInstaller.invoke
- rescue SetupError
- raise if $DEBUG
- $stderr.puts $!.message
- $stderr.puts "Try 'ruby #{$0} --help' for detailed usage."
- exit 1
- end
-end
diff --git a/vendor/plugins/googlecharts/spec/gchart_spec.rb b/vendor/plugins/googlecharts/spec/gchart_spec.rb
deleted file mode 100644
index 989471a..0000000
--- a/vendor/plugins/googlecharts/spec/gchart_spec.rb
+++ /dev/null
@@ -1,277 +0,0 @@
-require File.dirname(__FILE__) + '/spec_helper.rb'
-require File.dirname(__FILE__) + '/../lib/gchart'
-
-# Time to add your specs!
-# http://rspec.rubyforge.org/
-describe "generating a default Gchart" do
-
- before(:each) do
- @chart = Gchart.line
- end
-
- it "should include the Google URL" do
- @chart.include?("http://chart.apis.google.com/chart?").should be_true
- end
-
- it "should have a default size" do
- @chart.include?('chs=300x200').should be_true
- end
-
- it "should be able to have a custom size" do
- Gchart.line(:size => '400x600').include?('chs=400x600').should be_true
- Gchart.line(:width => 400, :height => 600).include?('chs=400x600').should be_true
- end
-
- it "should have a type" do
- @chart.include?('cht=lc').should be_true
- end
-
- it "should use the simple encoding by default with auto max value" do
- # 9 is the max value in simple encoding, 26 being our max value the 2nd encoded value should be 9
- Gchart.line(:data => [0, 26]).include?('chd=s:A9').should be_true
- Gchart.line(:data => [0, 26], :max_value => 26).should == Gchart.line(:data => [0, 26])
- end
-
- it "should support simple encoding with and without max_value" do
- Gchart.line(:data => [0, 26], :max_value => 26).include?('chd=s:A9').should be_true
- Gchart.line(:data => [0, 26], :max_value => false).include?('chd=s:Aa').should be_true
- end
-
- it "should support the extended encoding and encode properly" do
- Gchart.line(:data => [0, 10], :encoding => 'extended', :max_value => false).include?('chd=e:AA').should be_true
- Gchart.line(:encoding => 'extended',
- :max_value => false,
- :data => [[0,25,26,51,52,61,62,63], [64,89,90,115,4084]]
- ).include?('chd=e:AAAZAaAzA0A9A-A.,BABZBaBz.0').should be_true
- end
-
- it "should auto set the max value for extended encoding" do
- Gchart.line(:data => [0, 25], :encoding => 'extended', :max_value => false).include?('chd=e:AAAZ').should be_true
- # Extended encoding max value is '..'
- Gchart.line(:data => [0, 25], :encoding => 'extended').include?('chd=e:AA..').should be_true
- end
-
- it "should be able to have data with text encoding" do
- Gchart.line(:data => [10, 5.2, 4, 45, 78], :encoding => 'text').include?('chd=t:10,5.2,4,45,78').should be_true
- end
-
- it "should be able to have muliple set of data with text encoding" do
- Gchart.line(:data => [[10, 5.2, 4, 45, 78], [20, 40, 70, 15, 99]], :encoding => 'text').include?(Gchart.jstize('chd=t:10,5.2,4,45,78|20,40,70,15,99')).should be_true
- end
-
- it "should be able to receive a custom param" do
- Gchart.line(:custom => 'ceci_est_une_pipe').include?('ceci_est_une_pipe').should be_true
- end
-
- it "should be able to set label axis" do
- Gchart.line(:axis_with_labels => 'x,y,r').include?('chxt=x,y,r').should be_true
- Gchart.line(:axis_with_labels => ['x','y','r']).include?('chxt=x,y,r').should be_true
- end
-
- it "should be able to have axis labels" do
- Gchart.line(:axis_labels => ['Jan|July|Jan|July|Jan', '0|100', 'A|B|C', '2005|2006|2007']).include?(Gchart.jstize('chxl=0:|Jan|July|Jan|July|Jan|1:|0|100|2:|A|B|C|3:|2005|2006|2007')).should be_true
- Gchart.line(:axis_labels => ['Jan|July|Jan|July|Jan']).include?(Gchart.jstize('chxl=0:|Jan|July|Jan|July|Jan')).should be_true
- Gchart.line(:axis_labels => [['Jan','July','Jan','July','Jan']]).include?(Gchart.jstize('chxl=0:|Jan|July|Jan|July|Jan')).should be_true
- Gchart.line(:axis_labels => [['Jan','July','Jan','July','Jan'], ['0','100'], ['A','B','C'], ['2005','2006','2007']]).include?(Gchart.jstize('chxl=0:|Jan|July|Jan|July|Jan|1:|0|100|2:|A|B|C|3:|2005|2006|2007')).should be_true
- end
-
-end
-
-describe "generating different type of charts" do
-
- it "should be able to generate a line chart" do
- Gchart.line.should be_an_instance_of(String)
- Gchart.line.include?('cht=lc').should be_true
- end
-
- it "should be able to generate a line xy chart" do
- Gchart.line_xy.should be_an_instance_of(String)
- Gchart.line_xy.include?('cht=lxy').should be_true
- end
-
- it "should be able to generate a scatter chart" do
- Gchart.scatter.should be_an_instance_of(String)
- Gchart.scatter.include?('cht=s').should be_true
- end
-
- it "should be able to generate a bar chart" do
- Gchart.bar.should be_an_instance_of(String)
- Gchart.bar.include?('cht=bvs').should be_true
- end
-
- it "should be able to generate a Venn diagram" do
- Gchart.venn.should be_an_instance_of(String)
- Gchart.venn.include?('cht=v').should be_true
- end
-
- it "should be able to generate a Pie Chart" do
- Gchart.pie.should be_an_instance_of(String)
- Gchart.pie.include?('cht=p').should be_true
- end
-
- it "should not support other types" do
- Gchart.sexy.should == "sexy is not a supported chart format, please use one of the following: #{Gchart.supported_types}."
- end
-
-end
-
-describe "a bar graph" do
-
- it "should have a default vertical orientation" do
- Gchart.bar.include?('cht=bvs').should be_true
- end
-
- it "should be able to have a different orientation" do
- Gchart.bar(:orientation => 'vertical').include?('cht=bvs').should be_true
- Gchart.bar(:orientation => 'v').include?('cht=bvs').should be_true
- Gchart.bar(:orientation => 'h').include?('cht=bhs').should be_true
- Gchart.bar(:orientation => 'horizontal').include?('cht=bhs').should be_true
- Gchart.bar(:horizontal => false).include?('cht=bvs').should be_true
- end
-
- it "should be set to be stacked by default" do
- Gchart.bar.include?('cht=bvs').should be_true
- end
-
- it "should be able to stacked or grouped" do
- Gchart.bar(:stacked => true).include?('cht=bvs').should be_true
- Gchart.bar(:stacked => false).include?('cht=bvg').should be_true
- Gchart.bar(:grouped => true).include?('cht=bvg').should be_true
- Gchart.bar(:grouped => false).include?('cht=bvs').should be_true
- end
-
- it "should be able to have different bar colors" do
- Gchart.bar(:bar_colors => 'efefef,00ffff').include?('chco=').should be_true
- Gchart.bar(:bar_colors => 'efefef,00ffff').include?('chco=efefef,00ffff').should be_true
- # alias
- Gchart.bar(:bar_color => 'efefef').include?('chco=efefef').should be_true
- end
-
- it "should be able to have different bar colors when using an array of colors" do
- Gchart.bar(:bar_colors => ['efefef','00ffff']).include?('chco=efefef,00ffff').should be_true
- end
-
-end
-
-describe "a line chart" do
-
- before(:each) do
- @title = 'Chart Title'
- @legend = ['first data set label', 'n data set label']
- @chart = Gchart.line(:title => @title, :legend => @legend)
- end
-
- it 'should be able have a chart title' do
- @chart.include?("chtt=Chart+Title").should be_true
- end
-
- it "should be able to a custom color and size title" do
- Gchart.line(:title => @title, :title_color => 'FF0000').include?('chts=FF0000').should be_true
- Gchart.line(:title => @title, :title_size => '20').include?('chts=454545,20').should be_true
- end
-
- it "should be able to have multiple legends" do
- @chart.include?(Gchart.jstize("chdl=first+data+set+label|n+data+set+label")).should be_true
- end
-
- it "should be able to have one legend" do
- chart = Gchart.line(:legend => 'legend label')
- chart.include?("chdl=legend+label").should be_true
- end
-
- it "should be able to set the background fill" do
- Gchart.line(:bg => 'efefef').include?("chf=bg,s,efefef").should be_true
- Gchart.line(:bg => {:color => 'efefef', :type => 'solid'}).include?("chf=bg,s,efefef").should be_true
-
- Gchart.line(:bg => {:color => 'efefef', :type => 'gradient'}).include?("chf=bg,lg,0,efefef,0,ffffff,1").should be_true
- Gchart.line(:bg => {:color => 'efefef,0,ffffff,1', :type => 'gradient'}).include?("chf=bg,lg,0,efefef,0,ffffff,1").should be_true
- Gchart.line(:bg => {:color => 'efefef', :type => 'gradient', :angle => 90}).include?("chf=bg,lg,90,efefef,0,ffffff,1").should be_true
-
- Gchart.line(:bg => {:color => 'efefef', :type => 'stripes'}).include?("chf=bg,ls,90,efefef,0.2,ffffff,0.2").should be_true
- end
-
- it "should be able to set a graph fill" do
- Gchart.line(:graph_bg => 'efefef').include?("chf=c,s,efefef").should be_true
- Gchart.line(:graph_bg => {:color => 'efefef', :type => 'solid'}).include?("chf=c,s,efefef").should be_true
- Gchart.line(:graph_bg => {:color => 'efefef', :type => 'gradient'}).include?("chf=c,lg,0,efefef,0,ffffff,1").should be_true
- Gchart.line(:graph_bg => {:color => 'efefef,0,ffffff,1', :type => 'gradient'}).include?("chf=c,lg,0,efefef,0,ffffff,1").should be_true
- Gchart.line(:graph_bg => {:color => 'efefef', :type => 'gradient', :angle => 90}).include?("chf=c,lg,90,efefef,0,ffffff,1").should be_true
- end
-
- it "should be able to set both a graph and a background fill" do
- Gchart.line(:bg => 'efefef', :graph_bg => '76A4FB').include?("bg,s,efefef").should be_true
- Gchart.line(:bg => 'efefef', :graph_bg => '76A4FB').include?("c,s,76A4FB").should be_true
- Gchart.line(:bg => 'efefef', :graph_bg => '76A4FB').include?(Gchart.jstize("chf=c,s,76A4FB|bg,s,efefef")).should be_true
- end
-
- it "should be able to have different line colors" do
- Gchart.line(:line_colors => 'efefef|00ffff').include?(Gchart.jstize('chco=efefef|00ffff')).should be_true
- Gchart.line(:line_color => 'efefef|00ffff').include?(Gchart.jstize('chco=efefef|00ffff')).should be_true
- end
-
-end
-
-describe "a pie chart" do
-
- before(:each) do
- @title = 'Chart Title'
- @legend = ['first data set label', 'n data set label']
- @jstized_legend = Gchart.jstize(@legend.join('|'))
- @data = [12,8,40,15,5]
- @chart = Gchart.pie(:title => @title, :legend => @legend, :data => @data)
- end
-
- it "should create a pie" do
- @chart.include?('cht=p').should be_true
- end
-
- it "should be able to be in 3d" do
- Gchart.pie_3d(:title => @title, :legend => @legend, :data => @data).include?('cht=p3').should be_true
- end
-
- it "should be able to set labels by using the legend or labesl accessor" do
- Gchart.pie_3d(:title => @title, :legend => @legend, :data => @data).include?("chl=#{@jstized_legend}").should be_true
- Gchart.pie_3d(:title => @title, :labels => @legend, :data => @data).include?("chl=#{@jstized_legend}").should be_true
- Gchart.pie_3d(:title => @title, :labels => @legend, :data => @data).should == Gchart.pie_3d(:title => @title, :legend => @legend, :data => @data)
- end
-
-end
-
-describe 'exporting a chart' do
-
- it "should be available in the url format by default" do
- Gchart.line(:data => [0, 26], :format => 'url').should == Gchart.line(:data => [0, 26])
- end
-
- it "should be available as the img tag" do
- Gchart.line(:data => [0, 26], :format => 'img_tag').should match(/<img src=(.*)\/>/)
- end
-
- it "should be available as a file" do
- File.delete('chart.png') if File.exist?('chart.png')
- Gchart.line(:data => [0, 26], :format => 'file')
- File.exist?('chart.png').should be_true
- File.delete('chart.png') if File.exist?('chart.png')
- end
-
- it "should be available as a file using a custom file name" do
- File.delete('custom_file_name.png') if File.exist?('custom_file_name.png')
- Gchart.line(:data => [0, 26], :format => 'file', :filename => 'custom_file_name.png')
- File.exist?('custom_file_name.png').should be_true
- File.delete('custom_file_name.png') if File.exist?('custom_file_name.png')
- end
-
- it "should work even with multiple attrs" do
- File.delete('foo.png') if File.exist?('foo.png')
- Gchart.line(:size => '400x200',
- :data => [1,2,3,4,5],
- :axis_labels => [[1,2,3,4, 5], %w[foo bar]],
- :axis_with_labels => 'x,r',
- :format => "file",
- :filename => "foo.png"
- )
- File.exist?('foo.png').should be_true
- File.delete('foo.png') if File.exist?('foo.png')
- end
-
-end \ No newline at end of file
diff --git a/vendor/plugins/googlecharts/spec/spec.opts b/vendor/plugins/googlecharts/spec/spec.opts
deleted file mode 100644
index cf6add7..0000000
--- a/vendor/plugins/googlecharts/spec/spec.opts
+++ /dev/null
@@ -1 +0,0 @@
---colour \ No newline at end of file
diff --git a/vendor/plugins/googlecharts/spec/spec_helper.rb b/vendor/plugins/googlecharts/spec/spec_helper.rb
deleted file mode 100644
index f1ca062..0000000
--- a/vendor/plugins/googlecharts/spec/spec_helper.rb
+++ /dev/null
@@ -1,7 +0,0 @@
-begin
- require 'spec'
-rescue LoadError
- require 'rubygems'
- gem 'rspec'
- require 'spec'
-end \ No newline at end of file
diff --git a/vendor/plugins/googlecharts/tasks/deployment.rake b/vendor/plugins/googlecharts/tasks/deployment.rake
deleted file mode 100644
index 2f43742..0000000
--- a/vendor/plugins/googlecharts/tasks/deployment.rake
+++ /dev/null
@@ -1,34 +0,0 @@
-desc 'Release the website and new gem version'
-task :deploy => [:check_version, :website, :release] do
- puts "Remember to create SVN tag:"
- puts "svn copy svn+ssh://#{rubyforge_username}@rubyforge.org/var/svn/#{PATH}/trunk " +
- "svn+ssh://#{rubyforge_username}@rubyforge.org/var/svn/#{PATH}/tags/REL-#{VERS} "
- puts "Suggested comment:"
- puts "Tagging release #{CHANGES}"
-end
-
-desc 'Runs tasks website_generate and install_gem as a local deployment of the gem'
-task :local_deploy => [:website_generate, :install_gem]
-
-task :check_version do
- unless ENV['VERSION']
- puts 'Must pass a VERSION=x.y.z release version'
- exit
- end
- unless ENV['VERSION'] == VERS
- puts "Please update your version.rb to match the release version, currently #{VERS}"
- exit
- end
-end
-
-desc 'Install the package as a gem, without generating documentation(ri/rdoc)'
-task :install_gem_no_doc => [:clean, :package] do
- sh "#{'sudo ' unless Hoe::WINDOZE }gem install pkg/*.gem --no-rdoc --no-ri"
-end
-
-namespace :manifest do
- desc 'Recreate Manifest.txt to include ALL files'
- task :refresh do
- `rake check_manifest | patch -p0 > Manifest.txt`
- end
-end \ No newline at end of file
diff --git a/vendor/plugins/googlecharts/tasks/environment.rake b/vendor/plugins/googlecharts/tasks/environment.rake
deleted file mode 100644
index 691ed3b..0000000
--- a/vendor/plugins/googlecharts/tasks/environment.rake
+++ /dev/null
@@ -1,7 +0,0 @@
-task :ruby_env do
- RUBY_APP = if RUBY_PLATFORM =~ /java/
- "jruby"
- else
- "ruby"
- end unless defined? RUBY_APP
-end
diff --git a/vendor/plugins/googlecharts/tasks/rspec.rake b/vendor/plugins/googlecharts/tasks/rspec.rake
deleted file mode 100644
index b256d1c..0000000
--- a/vendor/plugins/googlecharts/tasks/rspec.rake
+++ /dev/null
@@ -1,21 +0,0 @@
-begin
- require 'spec'
-rescue LoadError
- require 'rubygems'
- require 'spec'
-end
-begin
- require 'spec/rake/spectask'
-rescue LoadError
- puts <<-EOS
-To use rspec for testing you must install rspec gem:
- gem install rspec
-EOS
- exit(0)
-end
-
-desc "Run the specs under spec/models"
-Spec::Rake::SpecTask.new do |t|
- t.spec_opts = ['--options', "spec/spec.opts"]
- t.spec_files = FileList['spec/*_spec.rb']
-end
diff --git a/vendor/plugins/googlecharts/tasks/website.rake b/vendor/plugins/googlecharts/tasks/website.rake
deleted file mode 100644
index 93e03fa..0000000
--- a/vendor/plugins/googlecharts/tasks/website.rake
+++ /dev/null
@@ -1,17 +0,0 @@
-desc 'Generate website files'
-task :website_generate => :ruby_env do
- (Dir['website/**/*.txt'] - Dir['website/version*.txt']).each do |txt|
- sh %{ #{RUBY_APP} script/txt2html #{txt} > #{txt.gsub(/txt$/,'html')} }
- end
-end
-
-desc 'Upload website files to rubyforge'
-task :website_upload do
- host = "#{rubyforge_username}@rubyforge.org"
- remote_dir = "/var/www/gforge-projects/#{PATH}/"
- local_dir = 'website'
- sh %{rsync -aCv #{local_dir}/ #{host}:#{remote_dir}}
-end
-
-desc 'Generate and upload website files'
-task :website => [:website_generate, :website_upload, :publish_docs]
diff --git a/vendor/plugins/googlecharts/website/index.html b/vendor/plugins/googlecharts/website/index.html
deleted file mode 100644
index bde2417..0000000
--- a/vendor/plugins/googlecharts/website/index.html
+++ /dev/null
@@ -1,601 +0,0 @@
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
-"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
-<head>
- <link rel="stylesheet" href="stylesheets/screen.css" type="text/css" media="screen" />
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
- <title>
- Googlecharts
- </title>
- <script src="javascripts/rounded_corners_lite.inc.js" type="text/javascript"></script>
-<style>
-
-</style>
- <script type="text/javascript">
- window.onload = function() {
- settings = {
- tl: { radius: 10 },
- tr: { radius: 10 },
- bl: { radius: 10 },
- br: { radius: 10 },
- antiAlias: true,
- autoPad: true,
- validTags: ["div"]
- }
- var versionBox = new curvyCorners(settings, document.getElementById("version"));
- versionBox.applyCornersToAll();
- }
- </script>
-</head>
-<body>
-<div id="main">
-
- <h1>Googlecharts</h1>
- <div id="version" class="clickable" onclick='document.location = "http://rubyforge.org/projects/googlecharts"; return false'>
- <p>Get Version</p>
- <a href="http://rubyforge.org/projects/googlecharts" class="numbers">1.1.0</a>
- </div>
- <h2>&#x2192; &#8216;Sexy Charts using Google <span class="caps">API</span> &#38; Ruby&#8217;</h2>
-
-
- <h2>What</h2>
-
-
- <pre><code>A nice and simple wrapper for <a href="http://code.google.com/apis/chart/">Google Chart API</a></code></pre>
-
-
- <h2>Installing</h2>
-
-
- <p><pre class='syntax'><span class="ident">sudo</span> <span class="ident">gem</span> <span class="ident">install</span> <span class="ident">googlecharts</span></pre></p>
-
-
- <h2>The basics</h2>
-
-
- <p>This gem supports the following types of charts:</p>
-
-
- <p><img src="http://chart.apis.google.com/chart?cht=lc&#38;chs=200x125&#38;chd=s:helloWorld&#38;chxt=x,y&#38;chxl=0:|Mar|Apr|May|June|July|1:||50+Kb" title="Line" alt="Line" /> Gchart.line()</p>
-
-
- <p><img src="http://chart.apis.google.com/chart?cht=lxy&#38;chs=200x125&#38;chd=t:0,30,60,70,90,95,100|20,30,40,50,60,70,80|10,30,40,45,52|100,90,40,20,10|-1|5,33,50,55,7&#38;chco=3072F3,ff0000,00aaaa&#38;chls=2,4,1&#38;chm=s,FF0000,0,-1,5|s,0000ff,1,-1,5|s,00aa00,2,-1,5" title="line_xy" alt="line_xy" /> Gchart.line_xy()</p>
-
-
- <p><img src="http://chart.apis.google.com/chart?cht=s&#38;chd=s:984sttvuvkQIBLKNCAIi,DEJPgq0uov17zwopQODS,AFLPTXaflptx159gsDrn&#38;chxt=x,y&#38;chxl=0:|0|2|3|4|5|6|7|8|9|10|1:|0|25|50|75|100&#38;chs=200x125" title="scatter" alt="scatter" /> Gchart.scatter()</p>
-
-
- <p><img src="http://chart.apis.google.com/chart?cht=bvg&#38;chs=200x125&#38;chd=s:hello,world&#38;chco=cc0000,00aa00" title="bar" alt="bar" /> Gchart.bar()</p>
-
-
- <p><img src="http://chart.apis.google.com/chart?cht=v&#38;chs=200x100&#38;chd=t:100,80,60,30,30,30,10" title="venn" alt="venn" /> Gchart.venn()</p>
-
-
- <p><img src="http://chart.apis.google.com/chart?cht=p&#38;chd=s:world5&#38;chs=200x125&#38;chl=A|B|C|D|E|Fe" title="pie" alt="pie" /> Gchart.pie()</p>
-
-
- <p><img src="http://chart.apis.google.com/chart?cht=p3&#38;chd=s:Uf9a&#38;chs=200x100&#38;chl=A|B|C|D" title="pie_3d" alt="pie_3d" /> Gchart.pie_3d()</p>
-
-
- <h2>Demonstration of usage</h2>
-
-
-install:
-<code>sudo gem install googlecharts</code>
-
- <p>require:
-<pre class='syntax'><span class="ident">require</span> <span class="punct">'</span><span class="string">gchart</span><span class="punct">'</span></pre></p>
-
-
- <p><pre class='syntax'><span class="constant">Gchart</span><span class="punct">.</span><span class="ident">line</span><span class="punct">(</span> <span class="symbol">:size</span> <span class="punct">=&gt;</span> <span class="punct">'</span><span class="string">200x300</span><span class="punct">',</span>
- <span class="symbol">:title</span> <span class="punct">=&gt;</span> <span class="punct">&quot;</span><span class="string">example title</span><span class="punct">&quot;,</span>
- <span class="symbol">:bg</span> <span class="punct">=&gt;</span> <span class="punct">'</span><span class="string">efefef</span><span class="punct">',</span>
- <span class="symbol">:legend</span> <span class="punct">=&gt;</span> <span class="punct">['</span><span class="string">first data set label</span><span class="punct">',</span> <span class="punct">'</span><span class="string">second data set label</span><span class="punct">'],</span>
- <span class="symbol">:data</span> <span class="punct">=&gt;</span> <span class="punct">[</span><span class="number">10</span><span class="punct">,</span> <span class="number">30</span><span class="punct">,</span> <span class="number">120</span><span class="punct">,</span> <span class="number">45</span><span class="punct">,</span> <span class="number">72</span><span class="punct">])</span></pre></p>
-
-
-<hr />
-
-
- <p><strong>simple line chart</strong>
-<pre class='syntax'>
- <span class="constant">Gchart</span><span class="punct">.</span><span class="ident">line</span><span class="punct">(</span><span class="symbol">:data</span> <span class="punct">=&gt;</span> <span class="punct">[</span><span class="number">0</span><span class="punct">,</span> <span class="number">40</span><span class="punct">,</span> <span class="number">10</span><span class="punct">,</span> <span class="number">70</span><span class="punct">,</span> <span class="number">20</span><span class="punct">])</span>
-</pre></p>
-
-
- <p>Generate the following url: http://chart.apis.google.com/chart?chs=300&#215;200&#38;chd=s:AiI9R&#38;cht=lc</p>
-
-
- <p>Inserted in an image tag, it will look like that:</p>
-
-
- <p><img src="http://chart.apis.google.com/chart?chs=300x200&#38;chd=s:AiI9R&#38;cht=lc" title="simple line chart" alt="simple line chart" /></p>
-
-
- <p><strong>multiple line charts</strong>
-<pre class='syntax'>
- <span class="constant">Gchart</span><span class="punct">.</span><span class="ident">line</span><span class="punct">(</span><span class="symbol">:data</span> <span class="punct">=&gt;</span> <span class="punct">[[</span><span class="number">0</span><span class="punct">,</span> <span class="number">40</span><span class="punct">,</span> <span class="number">10</span><span class="punct">,</span> <span class="number">70</span><span class="punct">,</span> <span class="number">20</span><span class="punct">],[</span><span class="number">41</span><span class="punct">,</span> <span class="number">10</span><span class="punct">,</span> <span class="number">80</span><span class="punct">,</span> <span class="number">50</span><span class="punct">]])</span>
-</pre></p>
-
-
- <p><img src="http://chart.apis.google.com/chart?cht=lc&#38;chs=300x200&#38;chd=s:AeH1P,fH9m" title="multiple lines chart" alt="multiple lines chart" /></p>
-
-
- <p><strong>set line colors</strong></p>
-
-
- <p><pre class='syntax'>
- <span class="constant">Gchart</span><span class="punct">.</span><span class="ident">line</span><span class="punct">(</span><span class="symbol">:data</span> <span class="punct">=&gt;</span> <span class="punct">[[</span><span class="number">0</span><span class="punct">,</span> <span class="number">40</span><span class="punct">,</span> <span class="number">10</span><span class="punct">,</span> <span class="number">70</span><span class="punct">,</span> <span class="number">20</span><span class="punct">],[</span><span class="number">41</span><span class="punct">,</span> <span class="number">10</span><span class="punct">,</span> <span class="number">80</span><span class="punct">,</span> <span class="number">50</span><span class="punct">]],</span> <span class="symbol">:line_colors</span> <span class="punct">=&gt;</span> <span class="punct">&quot;</span><span class="string">FF0000,00FF00</span><span class="punct">&quot;)</span>
-</pre></p>
-
-
- <p><img src="http://chart.apis.google.com/chart?cht=lc&#38;chs=300x200&#38;chd=s:AeH1P,fH9m&#38;chco=FF0000,00FF00" title="line colors" alt="line colors" /></p>
-
-
- <p><a href="http://code.google.com/apis/chart/#chart_colors">more info about color settings</a></p>
-
-
- <p><strong>bar chart</strong></p>
-
-
- <p><pre class='syntax'>
- <span class="constant">Gchart</span><span class="punct">.</span><span class="ident">bar</span><span class="punct">(</span><span class="symbol">:data</span> <span class="punct">=&gt;</span> <span class="punct">[</span><span class="number">300</span><span class="punct">,</span> <span class="number">100</span><span class="punct">,</span> <span class="number">30</span><span class="punct">,</span> <span class="number">200</span><span class="punct">])</span>
-</pre>
-<img src="http://chart.apis.google.com/chart?cht=bvs&#38;chs=300x200&#38;chd=s:9UGo" title="bars" alt="bars" /></p>
-
-
- <p><strong>set the bar chart orientation</strong></p>
-
-
- <p><pre class='syntax'>
- <span class="constant">Gchart</span><span class="punct">.</span><span class="ident">bar</span><span class="punct">(</span><span class="symbol">:data</span> <span class="punct">=&gt;</span> <span class="punct">[</span><span class="number">300</span><span class="punct">,</span> <span class="number">100</span><span class="punct">,</span> <span class="number">30</span><span class="punct">,</span> <span class="number">200</span><span class="punct">],</span> <span class="symbol">:orientation</span> <span class="punct">=&gt;</span> <span class="punct">'</span><span class="string">horizontal</span><span class="punct">')</span>
-</pre>
-<img src="http://chart.apis.google.com/chart?cht=bhs&#38;chs=300x200&#38;chd=s:9UGo" title="bars" alt="bars" /></p>
-
-
- <p><strong>multiple bars chart</strong></p>
-
-
- <p><pre class='syntax'>
- <span class="constant">Gchart</span><span class="punct">.</span><span class="ident">bar</span><span class="punct">(</span><span class="symbol">:data</span> <span class="punct">=&gt;</span> <span class="punct">[[</span><span class="number">300</span><span class="punct">,</span> <span class="number">100</span><span class="punct">,</span> <span class="number">30</span><span class="punct">,</span> <span class="number">200</span><span class="punct">],</span> <span class="punct">[</span><span class="number">100</span><span class="punct">,</span> <span class="number">200</span><span class="punct">,</span> <span class="number">300</span><span class="punct">,</span> <span class="number">10</span><span class="punct">]])</span>
-</pre></p>
-
-
- <p><img src="http://chart.apis.google.com/chart?cht=bvs&#38;chs=300x200&#38;chd=s:9UGo,Uo9C" title="stacked multiple bars" alt="stacked multiple bars" /></p>
-
-
- <p>The problem is that by default the bars are stacked, so we need to set the colors:</p>
-
-
- <p><pre class='syntax'>
- <span class="constant">Gchart</span><span class="punct">.</span><span class="ident">bar</span><span class="punct">(</span><span class="symbol">:data</span> <span class="punct">=&gt;</span> <span class="punct">[[</span><span class="number">300</span><span class="punct">,</span> <span class="number">100</span><span class="punct">,</span> <span class="number">30</span><span class="punct">,</span> <span class="number">200</span><span class="punct">],</span> <span class="punct">[</span><span class="number">100</span><span class="punct">,</span> <span class="number">200</span><span class="punct">,</span> <span class="number">300</span><span class="punct">,</span> <span class="number">10</span><span class="punct">]],</span> <span class="symbol">:bar_colors</span> <span class="punct">=&gt;</span> <span class="punct">'</span><span class="string">FF0000,00FF00</span><span class="punct">')</span>
-</pre></p>
-
-
- <p>If you prefer you can use this other syntax:</p>
-
-
- <p><pre class='syntax'>
- <span class="constant">Gchart</span><span class="punct">.</span><span class="ident">bar</span><span class="punct">(</span><span class="symbol">:data</span> <span class="punct">=&gt;</span> <span class="punct">[[</span><span class="number">300</span><span class="punct">,</span> <span class="number">100</span><span class="punct">,</span> <span class="number">30</span><span class="punct">,</span> <span class="number">200</span><span class="punct">],</span> <span class="punct">[</span><span class="number">100</span><span class="punct">,</span> <span class="number">200</span><span class="punct">,</span> <span class="number">300</span><span class="punct">,</span> <span class="number">10</span><span class="punct">]],</span> <span class="symbol">:bar_colors</span> <span class="punct">=&gt;</span> <span class="punct">['</span><span class="string">FF0000</span><span class="punct">',</span> <span class="punct">'</span><span class="string">00FF00</span><span class="punct">'])</span>
-</pre></p>
-
-
- <p><img src="http://chart.apis.google.com/chart?cht=bvs&#38;chs=300x200&#38;chd=s:9UGo,Uo9C&#38;chco=FF0000,00FF00" title="colors" alt="colors" /></p>
-
-
- <p>The problem now, is that we can&#8217;t see the first value of the second dataset since it&#8217;s lower than the first value of the first dataset. Let&#8217;s unstack the bars:</p>
-
-
- <p><pre class='syntax'>
- <span class="constant">Gchart</span><span class="punct">.</span><span class="ident">bar</span><span class="punct">(</span> <span class="symbol">:data</span> <span class="punct">=&gt;</span> <span class="punct">[[</span><span class="number">300</span><span class="punct">,</span> <span class="number">100</span><span class="punct">,</span> <span class="number">30</span><span class="punct">,</span> <span class="number">200</span><span class="punct">],</span> <span class="punct">[</span><span class="number">100</span><span class="punct">,</span> <span class="number">200</span><span class="punct">,</span> <span class="number">300</span><span class="punct">,</span> <span class="number">10</span><span class="punct">]],</span>
- <span class="symbol">:bar_colors</span> <span class="punct">=&gt;</span> <span class="punct">'</span><span class="string">FF0000,00FF00</span><span class="punct">',</span>
- <span class="symbol">:stacked</span> <span class="punct">=&gt;</span> <span class="constant">false</span> <span class="punct">)</span>
-</pre></p>
-
-
- <p><img src="http://chart.apis.google.com/chart?cht=bvg&#38;chs=300x200&#38;chd=s:9UGo,Uo9C&#38;chco=FF0000,00FF00" title="grouped bars" alt="grouped bars" /></p>
-
-
- <p><strong>pie chart</strong></p>
-
-
- <p><pre class='syntax'>
- <span class="constant">Gchart</span><span class="punct">.</span><span class="ident">pie</span><span class="punct">(</span><span class="symbol">:data</span> <span class="punct">=&gt;</span> <span class="punct">[</span><span class="number">20</span><span class="punct">,</span> <span class="number">35</span><span class="punct">,</span> <span class="number">45</span><span class="punct">])</span>
-</pre>
-<img src="http://chart.apis.google.com/chart?cht=p&#38;chs=300x200&#38;chd=s:bv9" title="Pie Chart" alt="Pie Chart" /></p>
-
-
- <p><strong>3D pie chart</strong></p>
-
-
- <p><pre class='syntax'>
- <span class="constant">Gchart</span><span class="punct">.</span><span class="ident">pie_3d</span><span class="punct">(</span><span class="symbol">:data</span> <span class="punct">=&gt;</span> <span class="punct">[</span><span class="number">20</span><span class="punct">,</span> <span class="number">35</span><span class="punct">,</span> <span class="number">45</span><span class="punct">])</span>
-</pre>
-<img src="http://chart.apis.google.com/chart?cht=p3&#38;chs=300x200&#38;chd=s:bv9" title="Pie Chart" alt="Pie Chart" /></p>
-
-
- <p><strong>venn diagram</strong></p>
-
-
- <p><a href="http://code.google.com/apis/chart/#venn">Google documentation</a></p>
-
-
-Data set:
- <ul>
- <li>the first three values specify the relative sizes of three circles, A, B, and C</li>
- <li>the fourth value specifies the area of A intersecting B</li>
- <li>the fifth value specifies the area of B intersecting C</li>
- <li>the sixth value specifies the area of C intersecting A</li>
- <li>the seventh value specifies the area of A intersecting B intersecting C</li>
- </ul>
-
-
- <p><pre class='syntax'>
- <span class="constant">Gchart</span><span class="punct">.</span><span class="ident">venn</span><span class="punct">(</span><span class="symbol">:data</span> <span class="punct">=&gt;</span> <span class="punct">[</span><span class="number">100</span><span class="punct">,</span> <span class="number">80</span><span class="punct">,</span> <span class="number">60</span><span class="punct">,</span> <span class="number">30</span><span class="punct">,</span> <span class="number">30</span><span class="punct">,</span> <span class="number">30</span><span class="punct">,</span> <span class="number">10</span><span class="punct">])</span>
-</pre>
-<img src="http://chart.apis.google.com/chart?cht=v&#38;chs=300x200&#38;chd=s:9wkSSSG" title="Venn" alt="Venn" /></p>
-
-
- <p><strong>scatter plot</strong></p>
-
-
- <p><a href="http://code.google.com/apis/chart/#scatter_plot">Google Documentation</a></p>
-
-
- <p>Supply two data sets, the first data set specifies x coordinates, the second set specifies y coordinates, the third set the data point size.</p>
-
-
- <p><pre class='syntax'>
- <span class="constant">Gchart</span><span class="punct">.</span><span class="ident">scatter</span><span class="punct">(</span><span class="symbol">:data</span> <span class="punct">=&gt;</span> <span class="punct">[[</span><span class="number">1</span><span class="punct">,</span> <span class="number">2</span><span class="punct">,</span> <span class="number">3</span><span class="punct">,</span> <span class="number">4</span><span class="punct">,</span> <span class="number">5</span><span class="punct">],</span> <span class="punct">[</span><span class="number">1</span><span class="punct">,</span> <span class="number">2</span><span class="punct">,</span> <span class="number">3</span><span class="punct">,</span> <span class="number">4</span> <span class="punct">,</span><span class="number">5</span><span class="punct">],</span> <span class="punct">[</span><span class="number">5</span><span class="punct">,</span> <span class="number">4</span><span class="punct">,</span> <span class="number">3</span><span class="punct">,</span> <span class="number">2</span><span class="punct">,</span> <span class="number">1</span><span class="punct">]])</span>
-</pre></p>
-
-
- <p><img src="http://chart.apis.google.com/chart?cht=s&#38;chs=300x200&#38;chd=s:MYkw9,MYkw9,9wkYM" title="scatter" alt="scatter" /></p>
-
-
-<hr />
-
-
- <p><strong>set a chart title</strong></p>
-
-
- <p><pre class='syntax'>
- <span class="constant">Gchart</span><span class="punct">.</span><span class="ident">bar</span><span class="punct">(</span><span class="symbol">:title</span> <span class="punct">=&gt;</span> <span class="punct">&quot;</span><span class="string">Recent Chart Sexyness</span><span class="punct">&quot;,</span> <span class="symbol">:data</span> <span class="punct">=&gt;</span> <span class="punct">[</span><span class="number">15</span><span class="punct">,</span> <span class="number">30</span><span class="punct">,</span> <span class="number">10</span><span class="punct">,</span> <span class="number">20</span><span class="punct">,</span> <span class="number">100</span><span class="punct">,</span> <span class="number">20</span><span class="punct">,</span> <span class="number">40</span><span class="punct">,</span> <span class="number">100</span><span class="punct">])</span>
-</pre></p>
-
-
- <p><img src="http://chart.apis.google.com/chart?cht=bvs&#38;chs=300x200&#38;chd=s:JSGM9MY9&#38;chtt=Recent+Chart+Sexyness" title="chart title" alt="chart title" /></p>
-
-
- <p><strong>set the title size</strong></p>
-
-
- <p><pre class='syntax'>
- <span class="constant">Gchart</span><span class="punct">.</span><span class="ident">bar</span><span class="punct">(</span><span class="symbol">:title</span> <span class="punct">=&gt;</span> <span class="punct">&quot;</span><span class="string">Recent Chart Sexyness</span><span class="punct">&quot;,</span> <span class="symbol">:title_size</span> <span class="punct">=&gt;</span> <span class="number">20</span><span class="punct">,</span> <span class="symbol">:data</span> <span class="punct">=&gt;</span> <span class="punct">[</span><span class="number">15</span><span class="punct">,</span> <span class="number">30</span><span class="punct">,</span> <span class="number">10</span><span class="punct">,</span> <span class="number">20</span><span class="punct">,</span> <span class="number">100</span><span class="punct">,</span> <span class="number">20</span><span class="punct">,</span> <span class="number">40</span><span class="punct">,</span> <span class="number">100</span><span class="punct">])</span>
-</pre></p>
-
-
- <p><img src="http://chart.apis.google.com/chart?cht=bvs&#38;chs=300x200&#38;chd=s:JSGM9MY9&#38;chtt=Recent+Chart+Sexyness&#38;chts=454545,20" title="title size" alt="title size" /></p>
-
-
- <p><strong>set the title color</strong></p>
-
-
- <p><pre class='syntax'>
- <span class="constant">Gchart</span><span class="punct">.</span><span class="ident">bar</span><span class="punct">(</span><span class="symbol">:title</span> <span class="punct">=&gt;</span> <span class="punct">&quot;</span><span class="string">Recent Chart Sexyness</span><span class="punct">&quot;,</span> <span class="symbol">:title_color</span> <span class="punct">=&gt;</span> <span class="punct">'</span><span class="string">FF0000</span><span class="punct">',</span> <span class="symbol">:data</span> <span class="punct">=&gt;</span> <span class="punct">[</span><span class="number">15</span><span class="punct">,</span> <span class="number">30</span><span class="punct">,</span> <span class="number">10</span><span class="punct">,</span> <span class="number">20</span><span class="punct">,</span> <span class="number">100</span><span class="punct">,</span> <span class="number">20</span><span class="punct">,</span> <span class="number">40</span><span class="punct">,</span> <span class="number">100</span><span class="punct">])</span>
-</pre></p>
-
-
- <p><img src="http://chart.apis.google.com/chart?cht=bvs&#38;chs=300x200&#38;chd=s:JSGM9MY9&#38;chtt=Recent+Chart+Sexyness&#38;chts=FF0000" title="Title color" alt="Title color" /></p>
-
-
- <p><strong>set the chart&#8217;s size</strong></p>
-
-
- <p><pre class='syntax'>
- <span class="constant">Gchart</span><span class="punct">.</span><span class="ident">bar</span><span class="punct">(</span> <span class="symbol">:title</span> <span class="punct">=&gt;</span> <span class="punct">&quot;</span><span class="string">Recent Chart Sexyness</span><span class="punct">&quot;,</span>
- <span class="symbol">:data</span> <span class="punct">=&gt;</span> <span class="punct">[</span><span class="number">15</span><span class="punct">,</span> <span class="number">30</span><span class="punct">,</span> <span class="number">10</span><span class="punct">,</span> <span class="number">20</span><span class="punct">,</span> <span class="number">100</span><span class="punct">,</span> <span class="number">20</span><span class="punct">,</span> <span class="number">40</span><span class="punct">,</span> <span class="number">100</span><span class="punct">],</span>
- <span class="symbol">:size</span> <span class="punct">=&gt;</span> <span class="punct">'</span><span class="string">600x400</span><span class="punct">')</span>
-</pre></p>
-
-
- <p><img src="http://chart.apis.google.com/chart?cht=bvs&#38;chs=600x400&#38;chd=s:JSGM9MY9&#38;chtt=Recent+Chart+Sexyness" title="size" alt="size" /></p>
-
-
- <p><strong>set the image background color</strong></p>
-
-
- <p><pre class='syntax'>
- <span class="constant">Gchart</span><span class="punct">.</span><span class="ident">bar</span><span class="punct">(</span> <span class="symbol">:title</span> <span class="punct">=&gt;</span> <span class="punct">&quot;</span><span class="string">Matt's Mojo</span><span class="punct">&quot;,</span>
- <span class="symbol">:data</span> <span class="punct">=&gt;</span> <span class="punct">[</span><span class="number">15</span><span class="punct">,</span> <span class="number">30</span><span class="punct">,</span> <span class="number">10</span><span class="punct">,</span> <span class="number">20</span><span class="punct">,</span> <span class="number">100</span><span class="punct">,</span> <span class="number">20</span><span class="punct">,</span> <span class="number">40</span><span class="punct">,</span> <span class="number">100</span><span class="punct">,</span> <span class="number">90</span><span class="punct">,</span> <span class="number">100</span><span class="punct">,</span> <span class="number">80</span><span class="punct">],</span>
- <span class="symbol">:background</span> <span class="punct">=&gt;</span> <span class="punct">'</span><span class="string">FF9994</span><span class="punct">')</span>
-</pre></p>
-
-
- <p><img src="http://chart.apis.google.com/chart?chf=bg,s,FF9994&#38;cht=bvs&#38;chs=300x200&#38;chd=s:JSGM9MY929w&#38;chtt=Matt's+Mojo" title="Background" alt="Background" /></p>
-
-
- <p><strong>set the chart background color</strong></p>
-
-
- <p><pre class='syntax'>
- <span class="constant">Gchart</span><span class="punct">.</span><span class="ident">bar</span><span class="punct">(</span> <span class="symbol">:title</span> <span class="punct">=&gt;</span> <span class="punct">&quot;</span><span class="string">Matt's Mojo</span><span class="punct">&quot;,</span>
- <span class="symbol">:data</span> <span class="punct">=&gt;</span> <span class="punct">[</span><span class="number">15</span><span class="punct">,</span> <span class="number">30</span><span class="punct">,</span> <span class="number">10</span><span class="punct">,</span> <span class="number">20</span><span class="punct">,</span> <span class="number">100</span><span class="punct">,</span> <span class="number">20</span><span class="punct">,</span> <span class="number">40</span><span class="punct">,</span> <span class="number">100</span><span class="punct">,</span> <span class="number">90</span><span class="punct">,</span> <span class="number">100</span><span class="punct">,</span> <span class="number">80</span><span class="punct">],</span>
- <span class="symbol">:background</span> <span class="punct">=&gt;</span> <span class="punct">'</span><span class="string">FF9994</span><span class="punct">',</span> <span class="symbol">:chart_background</span> <span class="punct">=&gt;</span> <span class="punct">'</span><span class="string">000000</span><span class="punct">')</span>
-</pre></p>
-
-
- <p><img src="http://chart.apis.google.com/chart?chf=c,s,000000|bg,s,FF9994&#38;cht=bvs&#38;chs=300x200&#38;chd=s:JSGM9MY929w&#38;chtt=Matt's+Mojo" title="chart background" alt="chart background" /></p>
-
-
- <p><strong>Set bar/line colors</strong></p>
-
-
- <p><pre class='syntax'>
- <span class="constant">Gchart</span><span class="punct">.</span><span class="ident">bar</span><span class="punct">(</span> <span class="symbol">:title</span> <span class="punct">=&gt;</span> <span class="punct">&quot;</span><span class="string">Matt's Mojo</span><span class="punct">&quot;,</span>
- <span class="symbol">:data</span> <span class="punct">=&gt;</span> <span class="punct">[</span><span class="number">15</span><span class="punct">,</span> <span class="number">30</span><span class="punct">,</span> <span class="number">10</span><span class="punct">,</span> <span class="number">20</span><span class="punct">,</span> <span class="number">100</span><span class="punct">,</span> <span class="number">20</span><span class="punct">,</span> <span class="number">40</span><span class="punct">,</span> <span class="number">100</span><span class="punct">,</span> <span class="number">90</span><span class="punct">,</span> <span class="number">100</span><span class="punct">,</span> <span class="number">80</span><span class="punct">],</span>
- <span class="symbol">:bar_colors</span> <span class="punct">=&gt;</span> <span class="punct">'</span><span class="string">76A4FB</span><span class="punct">',</span>
- <span class="symbol">:background</span> <span class="punct">=&gt;</span> <span class="punct">'</span><span class="string">EEEEEE</span><span class="punct">',</span> <span class="symbol">:chart_background</span> <span class="punct">=&gt;</span> <span class="punct">'</span><span class="string">CCCCCC</span><span class="punct">')</span>
-</pre></p>
-
-
- <p><img src="http://chart.apis.google.com/chart?chf=c,s,CCCCCC|bg,s,EEEEEE&#38;cht=bvs&#38;chs=300x200&#38;chd=s:JSGM9MY929w&#38;chco=76A4FB&#38;chtt=Matt's+Mojo" title="bar colors" alt="bar colors" /></p>
-
-
- <p><pre class='syntax'>
- <span class="constant">Gchart</span><span class="punct">.</span><span class="ident">line</span><span class="punct">(</span> <span class="symbol">:title</span> <span class="punct">=&gt;</span> <span class="punct">&quot;</span><span class="string">Matt's Mojo</span><span class="punct">&quot;,</span>
- <span class="symbol">:data</span> <span class="punct">=&gt;</span> <span class="punct">[</span><span class="number">15</span><span class="punct">,</span> <span class="number">30</span><span class="punct">,</span> <span class="number">10</span><span class="punct">,</span> <span class="number">20</span><span class="punct">,</span> <span class="number">100</span><span class="punct">,</span> <span class="number">20</span><span class="punct">,</span> <span class="number">40</span><span class="punct">,</span> <span class="number">100</span><span class="punct">,</span> <span class="number">90</span><span class="punct">,</span> <span class="number">100</span><span class="punct">,</span> <span class="number">80</span><span class="punct">],</span>
- <span class="symbol">:line_colors</span> <span class="punct">=&gt;</span> <span class="punct">'</span><span class="string">76A4FB</span><span class="punct">')</span>
-</pre></p>
-
-
- <p><img src="http://chart.apis.google.com/chart?cht=lc&#38;chs=300x200&#38;chd=s:JSGM9MY929w&#38;chco=76A4FB&#38;chtt=Matt's+Mojo" title="line colors" alt="line colors" /></p>
-
-
- <p><strong>legend / labels</strong></p>
-
-
- <p><pre class='syntax'>
- <span class="constant">Gchart</span><span class="punct">.</span><span class="ident">bar</span><span class="punct">(</span> <span class="symbol">:title</span> <span class="punct">=&gt;</span> <span class="punct">&quot;</span><span class="string">Matt vs Rob</span><span class="punct">&quot;,</span>
- <span class="symbol">:data</span> <span class="punct">=&gt;</span> <span class="punct">[[</span><span class="number">300</span><span class="punct">,</span> <span class="number">100</span><span class="punct">,</span> <span class="number">30</span><span class="punct">,</span> <span class="number">200</span><span class="punct">],</span> <span class="punct">[</span><span class="number">100</span><span class="punct">,</span> <span class="number">200</span><span class="punct">,</span> <span class="number">300</span><span class="punct">,</span> <span class="number">10</span><span class="punct">]],</span>
- <span class="symbol">:bar_colors</span> <span class="punct">=&gt;</span> <span class="punct">'</span><span class="string">FF0000,00FF00</span><span class="punct">',</span>
- <span class="symbol">:stacked</span> <span class="punct">=&gt;</span> <span class="constant">false</span><span class="punct">,</span> <span class="symbol">:size</span> <span class="punct">=&gt;</span> <span class="punct">'</span><span class="string">400x200</span><span class="punct">',</span>
- <span class="symbol">:legend</span> <span class="punct">=&gt;</span> <span class="punct">[&quot;</span><span class="string">Matt's Mojo</span><span class="punct">&quot;,</span> <span class="punct">&quot;</span><span class="string">Rob's Mojo</span><span class="punct">&quot;]</span> <span class="punct">)</span>
-</pre>
-<img src="http://chart.apis.google.com/chart?cht=bvg&#38;chdl=Matt's+Mojo|Rob's+Mojo&#38;chs=400x200&#38;chd=s:9UGo,Uo9C&#38;chco=FF0000,00FF00&#38;chtt=Matt+vs+Rob" title="legend" alt="legend" /></p>
-
-
- <p><pre class='syntax'>
- <span class="constant">Gchart</span><span class="punct">.</span><span class="ident">line</span><span class="punct">(</span> <span class="symbol">:title</span> <span class="punct">=&gt;</span> <span class="punct">&quot;</span><span class="string">Matt vs Rob</span><span class="punct">&quot;,</span>
- <span class="symbol">:data</span> <span class="punct">=&gt;</span> <span class="punct">[[</span><span class="number">300</span><span class="punct">,</span> <span class="number">100</span><span class="punct">,</span> <span class="number">30</span><span class="punct">,</span> <span class="number">200</span><span class="punct">],</span> <span class="punct">[</span><span class="number">100</span><span class="punct">,</span> <span class="number">200</span><span class="punct">,</span> <span class="number">300</span><span class="punct">,</span> <span class="number">10</span><span class="punct">]],</span>
- <span class="symbol">:bar_colors</span> <span class="punct">=&gt;</span> <span class="punct">['</span><span class="string">FF0000</span><span class="punct">','</span><span class="string">00FF00</span><span class="punct">'],</span>
- <span class="symbol">:stacked</span> <span class="punct">=&gt;</span> <span class="constant">false</span><span class="punct">,</span> <span class="symbol">:size</span> <span class="punct">=&gt;</span> <span class="punct">'</span><span class="string">400x200</span><span class="punct">',</span>
- <span class="symbol">:legend</span> <span class="punct">=&gt;</span> <span class="punct">[&quot;</span><span class="string">Matt's Mojo</span><span class="punct">&quot;,</span> <span class="punct">&quot;</span><span class="string">Rob's Mojo</span><span class="punct">&quot;]</span> <span class="punct">)</span>
-</pre>
-<img src="http://chart.apis.google.com/chart?cht=lc&#38;chdl=Matt's+Mojo|Rob's+Mojo&#38;chs=400x200&#38;chd=s:9UGo,Uo9C&#38;chco=FF0000,00FF00&#38;chtt=Matt+vs+Rob" title="line legend" alt="line legend" /></p>
-
-
- <p><pre class='syntax'>
- <span class="constant">Gchart</span><span class="punct">.</span><span class="ident">pie_3d</span><span class="punct">(</span> <span class="symbol">:title</span> <span class="punct">=&gt;</span> <span class="punct">'</span><span class="string">ruby_fu</span><span class="punct">',</span> <span class="symbol">:size</span> <span class="punct">=&gt;</span> <span class="punct">'</span><span class="string">400x200</span><span class="punct">',</span>
- <span class="symbol">:data</span> <span class="punct">=&gt;</span> <span class="punct">[</span><span class="number">10</span><span class="punct">,</span> <span class="number">45</span><span class="punct">,</span> <span class="number">45</span><span class="punct">],</span> <span class="symbol">:labels</span> <span class="punct">=&gt;</span> <span class="punct">[&quot;</span><span class="string">DHH</span><span class="punct">&quot;,</span> <span class="punct">&quot;</span><span class="string">Rob</span><span class="punct">&quot;,</span> <span class="punct">&quot;</span><span class="string">Matt</span><span class="punct">&quot;]</span> <span class="punct">)</span>
-</pre></p>
-
-
- <p><img src="http://chart.apis.google.com/chart?cht=p3&#38;chl=DHH|Rob|Matt&#38;chs=400x200&#38;chd=s:N99&#38;chtt=ruby_fu" title="labels" alt="labels" /></p>
-
-
- <p><strong>Display axis labels</strong></p>
-
-
- <p><pre class='syntax'>
- <span class="constant">Gchart</span><span class="punct">.</span><span class="ident">line</span><span class="punct">(</span> <span class="symbol">:data</span> <span class="punct">=&gt;</span> <span class="punct">[</span><span class="number">300</span><span class="punct">,</span> <span class="number">100</span><span class="punct">,</span> <span class="number">30</span><span class="punct">,</span> <span class="number">200</span><span class="punct">,</span> <span class="number">100</span><span class="punct">,</span> <span class="number">200</span><span class="punct">,</span> <span class="number">300</span><span class="punct">,</span> <span class="number">10</span><span class="punct">],</span> <span class="symbol">:axis_with_labels</span> <span class="punct">=&gt;</span> <span class="punct">'</span><span class="string">x,y,r</span><span class="punct">')</span>
-</pre></p>
-
-
- <p>or you can use the other syntax:</p>
-
-
- <p><pre class='syntax'>
- <span class="constant">Gchart</span><span class="punct">.</span><span class="ident">line</span><span class="punct">(</span> <span class="symbol">:data</span> <span class="punct">=&gt;</span> <span class="punct">[</span><span class="number">300</span><span class="punct">,</span> <span class="number">100</span><span class="punct">,</span> <span class="number">30</span><span class="punct">,</span> <span class="number">200</span><span class="punct">,</span> <span class="number">100</span><span class="punct">,</span> <span class="number">200</span><span class="punct">,</span> <span class="number">300</span><span class="punct">,</span> <span class="number">10</span><span class="punct">],</span> <span class="symbol">:axis_with_labels</span> <span class="punct">=&gt;</span> <span class="punct">['</span><span class="string">x</span><span class="punct">','</span><span class="string">y</span><span class="punct">','</span><span class="string">r</span><span class="punct">'])</span>
-</pre></p>
-
-
- <p><img src="http://chart.apis.google.com/chart?cht=lc&#38;chs=300x200&#38;chxt=x,y,r&#38;chd=s:9UGoUo9C" title="axis with labels" alt="axis with labels" /></p>
-
-
- <p><pre class='syntax'>
- <span class="constant">Gchart</span><span class="punct">.</span><span class="ident">line</span><span class="punct">(</span> <span class="symbol">:data</span> <span class="punct">=&gt;</span> <span class="punct">[</span><span class="number">300</span><span class="punct">,</span> <span class="number">100</span><span class="punct">,</span> <span class="number">30</span><span class="punct">,</span> <span class="number">200</span><span class="punct">,</span> <span class="number">100</span><span class="punct">,</span> <span class="number">200</span><span class="punct">,</span> <span class="number">300</span><span class="punct">,</span> <span class="number">10</span><span class="punct">],</span> <span class="symbol">:axis_with_labels</span> <span class="punct">=&gt;</span> <span class="punct">'</span><span class="string">x</span><span class="punct">',</span>
- <span class="symbol">:axis_labels</span> <span class="punct">=&gt;</span> <span class="punct">['</span><span class="string">Jan|July|Jan|July|Jan</span><span class="punct">'])</span>
-</pre></p>
-
-
- <p>or you can use the other syntax:</p>
-
-
- <p><pre class='syntax'>
- <span class="constant">Gchart</span><span class="punct">.</span><span class="ident">line</span><span class="punct">(</span> <span class="symbol">:data</span> <span class="punct">=&gt;</span> <span class="punct">[</span><span class="number">300</span><span class="punct">,</span> <span class="number">100</span><span class="punct">,</span> <span class="number">30</span><span class="punct">,</span> <span class="number">200</span><span class="punct">,</span> <span class="number">100</span><span class="punct">,</span> <span class="number">200</span><span class="punct">,</span> <span class="number">300</span><span class="punct">,</span> <span class="number">10</span><span class="punct">],</span> <span class="symbol">:axis_with_labels</span> <span class="punct">=&gt;</span> <span class="punct">'</span><span class="string">x</span><span class="punct">',</span>
- <span class="symbol">:axis_labels</span> <span class="punct">=&gt;</span> <span class="punct">['</span><span class="string">Jan</span><span class="punct">','</span><span class="string">July</span><span class="punct">','</span><span class="string">Jan</span><span class="punct">','</span><span class="string">July</span><span class="punct">','</span><span class="string">Jan</span><span class="punct">'])</span>
-</pre></p>
-
-
- <p><img src="http://chart.apis.google.com/chart?cht=lc&#38;chxl=0:|Jan|July|Jan|July|Jan&#38;chs=300x200&#38;chxt=x&#38;chd=s:9UGoUo9C" title="x labels" alt="x labels" /></p>
-
-
- <p><strong>multiple axis labels</strong></p>
-
-
- <p><pre class='syntax'>
- <span class="constant">Gchart</span><span class="punct">.</span><span class="ident">line</span><span class="punct">(</span> <span class="symbol">:data</span> <span class="punct">=&gt;</span> <span class="punct">[</span><span class="number">300</span><span class="punct">,</span> <span class="number">100</span><span class="punct">,</span> <span class="number">30</span><span class="punct">,</span> <span class="number">200</span><span class="punct">,</span> <span class="number">100</span><span class="punct">,</span> <span class="number">200</span><span class="punct">,</span> <span class="number">300</span><span class="punct">,</span> <span class="number">10</span><span class="punct">],</span> <span class="symbol">:axis_with_labels</span> <span class="punct">=&gt;</span> <span class="punct">'</span><span class="string">x,r</span><span class="punct">',</span>
- <span class="symbol">:axis_labels</span> <span class="punct">=&gt;</span> <span class="punct">['</span><span class="string">Jan|July|Jan|July|Jan</span><span class="punct">',</span> <span class="punct">'</span><span class="string">2005|2006|2007</span><span class="punct">'])</span>
-</pre></p>
-
-
- <p>or</p>
-
-
- <p><pre class='syntax'>
- <span class="constant">Gchart</span><span class="punct">.</span><span class="ident">line</span><span class="punct">(</span> <span class="symbol">:data</span> <span class="punct">=&gt;</span> <span class="punct">[</span><span class="number">300</span><span class="punct">,</span> <span class="number">100</span><span class="punct">,</span> <span class="number">30</span><span class="punct">,</span> <span class="number">200</span><span class="punct">,</span> <span class="number">100</span><span class="punct">,</span> <span class="number">200</span><span class="punct">,</span> <span class="number">300</span><span class="punct">,</span> <span class="number">10</span><span class="punct">],</span> <span class="symbol">:axis_with_labels</span> <span class="punct">=&gt;</span> <span class="punct">'</span><span class="string">x,r</span><span class="punct">',</span>
- <span class="symbol">:axis_labels</span> <span class="punct">=&gt;</span> <span class="punct">[['</span><span class="string">Jan</span><span class="punct">','</span><span class="string">July</span><span class="punct">','</span><span class="string">Jan</span><span class="punct">','</span><span class="string">July</span><span class="punct">','</span><span class="string">Jan</span><span class="punct">'],</span> <span class="punct">['</span><span class="string">2005</span><span class="punct">','</span><span class="string">2006</span><span class="punct">','</span><span class="string">2007</span><span class="punct">']])</span>
-</pre></p>
-
-
- <p><img src="http://chart.apis.google.com/chart?cht=lc&#38;chxl=0:|Jan|July|Jan|July|Jan|1:|2005|2006|2007&#38;chs=300x200&#38;chxt=x,r&#38;chd=s:9UGoUo9C" title="multiple axis labels" alt="multiple axis labels" /></p>
-
-
- <p>(This syntax will probably be improved in the future)</p>
-
-
- <p><strong>custom params</strong></p>
-
-
- <p>I certainly didn&#8217;t cover the entire <span class="caps">API</span>, if you want to add your own params:</p>
-
-
- <p><pre class='syntax'>
- <span class="constant">Gchart</span><span class="punct">.</span><span class="ident">line</span><span class="punct">(</span> <span class="ident">custom</span> <span class="punct">=&gt;</span> <span class="punct">'</span><span class="string">chd=s:93zyvneTTOMJMLIJFHEAECFJGHDBFCFIERcgnpy45879,IJKNUWUWYdnswz047977315533zy1246872tnkgcaZQONHCECAAAAEII&amp;chls=3,6,3|1,1,0</span><span class="punct">')</span>
-</pre></p>
-
-
- <p><img src="http://chart.apis.google.com/chart?cht=lc&#38;chs=300x200&#38;chd=s:93zyvneTTOMJMLIJFHEAECFJGHDBFCFIERcgnpy45879,IJKNUWUWYdnswz047977315533zy1246872tnkgcaZQONHCECAAAAEII&#38;chls=3,6,3|1,1,0" title="Custom" alt="Custom" /></p>
-
-
-<hr />
-
-
- <p><strong>Save the chart as a file</strong></p>
-
-
- <p>You might prefer to save the chart instead of using the url, not a problem:</p>
-
-
- <p><pre class='syntax'>
- <span class="constant">Gchart</span><span class="punct">.</span><span class="ident">line</span><span class="punct">(</span><span class="symbol">:data</span> <span class="punct">=&gt;</span> <span class="punct">[</span><span class="number">0</span><span class="punct">,</span> <span class="number">26</span><span class="punct">],</span> <span class="symbol">:format</span> <span class="punct">=&gt;</span> <span class="punct">'</span><span class="string">file</span><span class="punct">')</span>
-</pre></p>
-
-
- <p>You might want to specify the path and/or the filename used to save your chart:</p>
-
-
- <p><pre class='syntax'>
- <span class="constant">Gchart</span><span class="punct">.</span><span class="ident">line</span><span class="punct">(</span><span class="symbol">:data</span> <span class="punct">=&gt;</span> <span class="punct">[</span><span class="number">0</span><span class="punct">,</span> <span class="number">26</span><span class="punct">],</span> <span class="symbol">:format</span> <span class="punct">=&gt;</span> <span class="punct">'</span><span class="string">file</span><span class="punct">',</span> <span class="symbol">:filename</span> <span class="punct">=&gt;</span> <span class="punct">'</span><span class="string">custom_filename.png</span><span class="punct">')</span>
-</pre></p>
-
-
- <p><strong>Insert as an image tag</strong></p>
-
-
- <p>Because, I&#8217;m lazy, I also added a custom format:</p>
-
-
- <p><pre class='syntax'>
- <span class="constant">Gchart</span><span class="punct">.</span><span class="ident">line</span><span class="punct">(</span><span class="symbol">:data</span> <span class="punct">=&gt;</span> <span class="punct">[</span><span class="number">0</span><span class="punct">,</span> <span class="number">26</span><span class="punct">],</span> <span class="symbol">:format</span> <span class="punct">=&gt;</span> <span class="punct">'</span><span class="string">img_tag</span><span class="punct">')</span>
-</pre></p>
-
-
- <p>&lt;img src=&#8217;http://chart.apis.google.com/chart?chs=300&#215;200&#38;chd=s:A9&#38;cht=lc&#8217;/&gt;</p>
-
-
-<hr />
-
-
- <p><strong>Encoding</strong></p>
-
-
- <p>Google Chart <span class="caps">API</span> offers <a href="http://code.google.com/apis/chart/#chart_data">3 types of data encoding</a></p>
-
-
- <ul>
- <li>simple</li>
- <li>text</li>
- <li>extended</li>
- </ul>
-
-
- <p>By default this library uses the simple encoding, if you need a different type of encoding, you can change it really easily:</p>
-
-
- <p>default / simple: chd=s:9UGoUo9C
-<pre class='syntax'>
- <span class="constant">Gchart</span><span class="punct">.</span><span class="ident">line</span><span class="punct">(</span> <span class="symbol">:data</span> <span class="punct">=&gt;</span> <span class="punct">[</span><span class="number">300</span><span class="punct">,</span> <span class="number">100</span><span class="punct">,</span> <span class="number">30</span><span class="punct">,</span> <span class="number">200</span><span class="punct">,</span> <span class="number">100</span><span class="punct">,</span> <span class="number">200</span><span class="punct">,</span> <span class="number">300</span><span class="punct">,</span> <span class="number">10</span><span class="punct">]</span> <span class="punct">)</span>
-</pre></p>
-
-
- <p>extended: chd=e:..VVGZqqVVqq..CI
-<pre class='syntax'>
- <span class="constant">Gchart</span><span class="punct">.</span><span class="ident">line</span><span class="punct">(</span> <span class="symbol">:data</span> <span class="punct">=&gt;</span> <span class="punct">[</span><span class="number">300</span><span class="punct">,</span> <span class="number">100</span><span class="punct">,</span> <span class="number">30</span><span class="punct">,</span> <span class="number">200</span><span class="punct">,</span> <span class="number">100</span><span class="punct">,</span> <span class="number">200</span><span class="punct">,</span> <span class="number">300</span><span class="punct">,</span> <span class="number">10</span><span class="punct">],</span> <span class="symbol">:encoding</span> <span class="punct">=&gt;</span> <span class="punct">'</span><span class="string">extended</span><span class="punct">'</span> <span class="punct">)</span>
-</pre></p>
-
-
- <p>text: chd=t:300,100,30,200,100,200,300,10
-<pre class='syntax'>
- <span class="constant">Gchart</span><span class="punct">.</span><span class="ident">line</span><span class="punct">(</span> <span class="symbol">:data</span> <span class="punct">=&gt;</span> <span class="punct">[</span><span class="number">300</span><span class="punct">,</span> <span class="number">100</span><span class="punct">,</span> <span class="number">30</span><span class="punct">,</span> <span class="number">200</span><span class="punct">,</span> <span class="number">100</span><span class="punct">,</span> <span class="number">200</span><span class="punct">,</span> <span class="number">300</span><span class="punct">,</span> <span class="number">10</span><span class="punct">],</span> <span class="symbol">:encoding</span> <span class="punct">=&gt;</span> <span class="punct">'</span><span class="string">text</span><span class="punct">'</span> <span class="punct">)</span>
-</pre></p>
-
-
- <p>(note that the text encoding doesn&#8217;t use a max value and therefore should be under 100)</p>
-
-
- <p><strong>Max value</strong></p>
-
-
- <p>Simple and extended encoding support the max value option.</p>
-
-
- <p>The max value option is a simple way of scaling your graph. The data is converted in chart value with the highest chart value being the highest point on the graph. By default, the calculation is done for you. However you can specify your own maximum or not use a maximum at all.</p>
-
-
- <p><pre class='syntax'>
- <span class="constant">Gchart</span><span class="punct">.</span><span class="ident">line</span><span class="punct">(</span> <span class="symbol">:data</span> <span class="punct">=&gt;</span> <span class="punct">[</span><span class="number">300</span><span class="punct">,</span> <span class="number">100</span><span class="punct">,</span> <span class="number">30</span><span class="punct">,</span> <span class="number">200</span><span class="punct">,</span> <span class="number">100</span><span class="punct">,</span> <span class="number">200</span><span class="punct">,</span> <span class="number">300</span><span class="punct">,</span> <span class="number">10</span><span class="punct">]</span> <span class="punct">)</span>
-</pre></p>
-
-
- <p><img src="http://chart.apis.google.com/chart?cht=lc&#38;chs=300x200&#38;chd=s:9UGoUo9C" title="Title" alt="Title" /></p>
-
-
- <p><pre class='syntax'>
- <span class="constant">Gchart</span><span class="punct">.</span><span class="ident">line</span><span class="punct">(</span> <span class="symbol">:data</span> <span class="punct">=&gt;</span> <span class="punct">[</span><span class="number">300</span><span class="punct">,</span> <span class="number">100</span><span class="punct">,</span> <span class="number">30</span><span class="punct">,</span> <span class="number">200</span><span class="punct">,</span> <span class="number">100</span><span class="punct">,</span> <span class="number">200</span><span class="punct">,</span> <span class="number">300</span><span class="punct">,</span> <span class="number">10</span><span class="punct">],</span> <span class="symbol">:max_value</span> <span class="punct">=&gt;</span> <span class="number">500</span> <span class="punct">)</span>
-</pre></p>
-
-
- <p><img src="http://chart.apis.google.com/chart?cht=lc&#38;chs=300x200&#38;chd=s:kMDYMYkB" title="max 500" alt="max 500" /></p>
-
-
- <p><pre class='syntax'>
- <span class="constant">Gchart</span><span class="punct">.</span><span class="ident">line</span><span class="punct">(</span> <span class="symbol">:data</span> <span class="punct">=&gt;</span> <span class="punct">[</span><span class="number">100</span><span class="punct">,</span> <span class="number">20</span><span class="punct">,</span> <span class="number">30</span><span class="punct">,</span> <span class="number">20</span><span class="punct">,</span> <span class="number">10</span><span class="punct">,</span> <span class="number">14</span><span class="punct">,</span> <span class="number">30</span><span class="punct">,</span> <span class="number">10</span><span class="punct">],</span> <span class="symbol">:max_value</span> <span class="punct">=&gt;</span> <span class="constant">false</span> <span class="punct">)</span>
-</pre></p>
-
-
- <p><img src="http://chart.apis.google.com/chart?cht=lc&#38;chs=300x200&#38;chd=s:_UeUKOeK" title="real size" alt="real size" /></p>
-
-
- <h2>Repository</h2>
-
-
- <p>The trunk repository is <code>svn://rubyforge.org/var/svn/Gchart/trunk</code> for anonymous access.</p>
-
-
- <h2>License</h2>
-
-
- <p>This code is free to use under the terms of the <span class="caps">MIT</span> license.</p>
-
-
- <h2>Contact</h2>
-
-
- <p>Comments are welcome. Send an email to <a href="mailto:mattaimonetti@gmail.com">Matt Aimonetti</a></p>
- <p class="coda">
- <a href="mattaimonetti@gmail.com">Matt Aimonetti</a>, 19th December 2007<br>
- Theme extended from <a href="http://rb2js.rubyforge.org/">Paul Battley</a>
- </p>
-</div>
-
-<script src="http://www.google-analytics.com/urchin.js" type="text/javascript">
-</script>
-<script type="text/javascript">
-_uacct = "UA-179809-11";
-urchinTracker();
-</script>
-
-</body>
-</html>
diff --git a/vendor/plugins/googlecharts/website/index.txt b/vendor/plugins/googlecharts/website/index.txt
deleted file mode 100644
index 21f7617..0000000
--- a/vendor/plugins/googlecharts/website/index.txt
+++ /dev/null
@@ -1,417 +0,0 @@
-h1. Googlecharts
-
-h2. &#x2192; 'Sexy Charts using Google API & Ruby'
-
-
-h2. What
-
- A nice and simple wrapper for "Google Chart API":http://code.google.com/apis/chart/
-
-h2. Installing
-
-<pre syntax="ruby">sudo gem install googlecharts</pre>
-
-h2. The basics
-
-This gem supports the following types of charts:
-
-!http://chart.apis.google.com/chart?cht=lc&chs=200x125&chd=s:helloWorld&chxt=x,y&chxl=0:|Mar|Apr|May|June|July|1:||50+Kb(Line)! Gchart.line()
-
-!http://chart.apis.google.com/chart?cht=lxy&chs=200x125&chd=t:0,30,60,70,90,95,100|20,30,40,50,60,70,80|10,30,40,45,52|100,90,40,20,10|-1|5,33,50,55,7&chco=3072F3,ff0000,00aaaa&chls=2,4,1&chm=s,FF0000,0,-1,5|s,0000ff,1,-1,5|s,00aa00,2,-1,5(line_xy)! Gchart.line_xy()
-
-!http://chart.apis.google.com/chart?cht=s&chd=s:984sttvuvkQIBLKNCAIi,DEJPgq0uov17zwopQODS,AFLPTXaflptx159gsDrn&chxt=x,y&chxl=0:|0|2|3|4|5|6|7|8|9|10|1:|0|25|50|75|100&chs=200x125(scatter)! Gchart.scatter()
-
-!http://chart.apis.google.com/chart?cht=bvg&chs=200x125&chd=s:hello,world&chco=cc0000,00aa00(bar)! Gchart.bar()
-
-!http://chart.apis.google.com/chart?cht=v&chs=200x100&chd=t:100,80,60,30,30,30,10(venn)! Gchart.venn()
-
-!http://chart.apis.google.com/chart?cht=p&chd=s:world5&chs=200x125&chl=A|B|C|D|E|Fe(pie)! Gchart.pie()
-
-!http://chart.apis.google.com/chart?cht=p3&chd=s:Uf9a&chs=200x100&chl=A|B|C|D(pie_3d)! Gchart.pie_3d()
-
-
-h2. Demonstration of usage
-
-install:
-<code>sudo gem install googlecharts</code>
-
-require:
-<pre syntax="ruby">require 'gchart'</pre>
-
-<pre syntax="ruby">Gchart.line( :size => '200x300',
- :title => "example title",
- :bg => 'efefef',
- :legend => ['first data set label', 'second data set label'],
- :data => [10, 30, 120, 45, 72])</pre>
-
----
-
-*simple line chart*
-<pre syntax="ruby">
- Gchart.line(:data => [0, 40, 10, 70, 20])
-</pre>
-
-Generate the following url: http://chart.apis.google.com/chart?chs=300x200&chd=s:AiI9R&cht=lc
-
-Inserted in an image tag, it will look like that:
-
-!http://chart.apis.google.com/chart?chs=300x200&chd=s:AiI9R&cht=lc(simple line chart)!
-
-*multiple line charts*
-<pre syntax="ruby">
- Gchart.line(:data => [[0, 40, 10, 70, 20],[41, 10, 80, 50]])
-</pre>
-
-!http://chart.apis.google.com/chart?cht=lc&chs=300x200&chd=s:AeH1P,fH9m(multiple lines chart)!
-
-*set line colors*
-
-<pre syntax="ruby">
- Gchart.line(:data => [[0, 40, 10, 70, 20],[41, 10, 80, 50]], :line_colors => "FF0000,00FF00")
-</pre>
-
-!http://chart.apis.google.com/chart?cht=lc&chs=300x200&chd=s:AeH1P,fH9m&chco=FF0000,00FF00(line colors)!
-
-"more info about color settings":http://code.google.com/apis/chart/#chart_colors
-
-*bar chart*
-
-<pre syntax="ruby">
- Gchart.bar(:data => [300, 100, 30, 200])
-</pre>
-!http://chart.apis.google.com/chart?cht=bvs&chs=300x200&chd=s:9UGo(bars)!
-
-*set the bar chart orientation*
-
-<pre syntax="ruby">
- Gchart.bar(:data => [300, 100, 30, 200], :orientation => 'horizontal')
-</pre>
-!http://chart.apis.google.com/chart?cht=bhs&chs=300x200&chd=s:9UGo(bars)!
-
-*multiple bars chart*
-
-<pre syntax="ruby">
- Gchart.bar(:data => [[300, 100, 30, 200], [100, 200, 300, 10]])
-</pre>
-
-!http://chart.apis.google.com/chart?cht=bvs&chs=300x200&chd=s:9UGo,Uo9C(stacked multiple bars)!
-
-The problem is that by default the bars are stacked, so we need to set the colors:
-
-<pre syntax="ruby">
- Gchart.bar(:data => [[300, 100, 30, 200], [100, 200, 300, 10]], :bar_colors => 'FF0000,00FF00')
-</pre>
-
-If you prefer you can use this other syntax:
-
-<pre syntax="ruby">
- Gchart.bar(:data => [[300, 100, 30, 200], [100, 200, 300, 10]], :bar_colors => ['FF0000', '00FF00'])
-</pre>
-
-!http://chart.apis.google.com/chart?cht=bvs&chs=300x200&chd=s:9UGo,Uo9C&chco=FF0000,00FF00(colors)!
-
-The problem now, is that we can't see the first value of the second dataset since it's lower than the first value of the first dataset. Let's unstack the bars:
-
-<pre syntax="ruby">
- Gchart.bar( :data => [[300, 100, 30, 200], [100, 200, 300, 10]],
- :bar_colors => 'FF0000,00FF00',
- :stacked => false )
-</pre>
-
-!http://chart.apis.google.com/chart?cht=bvg&chs=300x200&chd=s:9UGo,Uo9C&chco=FF0000,00FF00(grouped bars)!
-
-
-*pie chart*
-
-<pre syntax="ruby">
- Gchart.pie(:data => [20, 35, 45])
-</pre>
-!http://chart.apis.google.com/chart?cht=p&chs=300x200&chd=s:bv9(Pie Chart)!
-
-*3D pie chart*
-
-<pre syntax="ruby">
- Gchart.pie_3d(:data => [20, 35, 45])
-</pre>
-!http://chart.apis.google.com/chart?cht=p3&chs=300x200&chd=s:bv9(Pie Chart)!
-
-*venn diagram*
-
-"Google documentation":http://code.google.com/apis/chart/#venn
-
-Data set:
-* the first three values specify the relative sizes of three circles, A, B, and C
-* the fourth value specifies the area of A intersecting B
-* the fifth value specifies the area of B intersecting C
-* the sixth value specifies the area of C intersecting A
-* the seventh value specifies the area of A intersecting B intersecting C
-
-<pre syntax="ruby">
- Gchart.venn(:data => [100, 80, 60, 30, 30, 30, 10])
-</pre>
-!http://chart.apis.google.com/chart?cht=v&chs=300x200&chd=s:9wkSSSG(Venn)!
-
-*scatter plot*
-
-"Google Documentation":http://code.google.com/apis/chart/#scatter_plot
-
-Supply two data sets, the first data set specifies x coordinates, the second set specifies y coordinates, the third set the data point size.
-
-<pre syntax="ruby">
- Gchart.scatter(:data => [[1, 2, 3, 4, 5], [1, 2, 3, 4 ,5], [5, 4, 3, 2, 1]])
-</pre>
-
-!http://chart.apis.google.com/chart?cht=s&chs=300x200&chd=s:MYkw9,MYkw9,9wkYM(scatter)!
-
----
-
-*set a chart title*
-
-<pre syntax="ruby">
- Gchart.bar(:title => "Recent Chart Sexyness", :data => [15, 30, 10, 20, 100, 20, 40, 100])
-</pre>
-
-!http://chart.apis.google.com/chart?cht=bvs&chs=300x200&chd=s:JSGM9MY9&chtt=Recent+Chart+Sexyness(chart title)!
-
-*set the title size*
-
-<pre syntax="ruby">
- Gchart.bar(:title => "Recent Chart Sexyness", :title_size => 20, :data => [15, 30, 10, 20, 100, 20, 40, 100])
-</pre>
-
-!http://chart.apis.google.com/chart?cht=bvs&chs=300x200&chd=s:JSGM9MY9&chtt=Recent+Chart+Sexyness&chts=454545,20(title size)!
-
-*set the title color*
-
-<pre syntax="ruby">
- Gchart.bar(:title => "Recent Chart Sexyness", :title_color => 'FF0000', :data => [15, 30, 10, 20, 100, 20, 40, 100])
-</pre>
-
-!http://chart.apis.google.com/chart?cht=bvs&chs=300x200&chd=s:JSGM9MY9&chtt=Recent+Chart+Sexyness&chts=FF0000(Title color)!
-
-*set the chart's size*
-
-<pre syntax="ruby">
- Gchart.bar( :title => "Recent Chart Sexyness",
- :data => [15, 30, 10, 20, 100, 20, 40, 100],
- :size => '600x400')
-</pre>
-
-!http://chart.apis.google.com/chart?cht=bvs&chs=600x400&chd=s:JSGM9MY9&chtt=Recent+Chart+Sexyness(size)!
-
-*set the image background color*
-
-<pre syntax="ruby">
- Gchart.bar( :title => "Matt's Mojo",
- :data => [15, 30, 10, 20, 100, 20, 40, 100, 90, 100, 80],
- :background => 'FF9994')
-</pre>
-
-!http://chart.apis.google.com/chart?chf=bg,s,FF9994&cht=bvs&chs=300x200&chd=s:JSGM9MY929w&chtt=Matt's+Mojo(Background)!
-
-*set the chart background color*
-
-<pre syntax="ruby">
- Gchart.bar( :title => "Matt's Mojo",
- :data => [15, 30, 10, 20, 100, 20, 40, 100, 90, 100, 80],
- :background => 'FF9994', :chart_background => '000000')
-</pre>
-
-!http://chart.apis.google.com/chart?chf=c,s,000000|bg,s,FF9994&cht=bvs&chs=300x200&chd=s:JSGM9MY929w&chtt=Matt's+Mojo(chart background)!
-
-*Set bar/line colors*
-
-<pre syntax="ruby">
- Gchart.bar( :title => "Matt's Mojo",
- :data => [15, 30, 10, 20, 100, 20, 40, 100, 90, 100, 80],
- :bar_colors => '76A4FB',
- :background => 'EEEEEE', :chart_background => 'CCCCCC')
-</pre>
-
-!http://chart.apis.google.com/chart?chf=c,s,CCCCCC|bg,s,EEEEEE&cht=bvs&chs=300x200&chd=s:JSGM9MY929w&chco=76A4FB&chtt=Matt's+Mojo(bar colors)!
-
-<pre syntax="ruby">
- Gchart.line( :title => "Matt's Mojo",
- :data => [15, 30, 10, 20, 100, 20, 40, 100, 90, 100, 80],
- :line_colors => '76A4FB')
-</pre>
-
-!http://chart.apis.google.com/chart?cht=lc&chs=300x200&chd=s:JSGM9MY929w&chco=76A4FB&chtt=Matt's+Mojo(line colors)!
-
-*legend / labels*
-
-<pre syntax="ruby">
- Gchart.bar( :title => "Matt vs Rob",
- :data => [[300, 100, 30, 200], [100, 200, 300, 10]],
- :bar_colors => 'FF0000,00FF00',
- :stacked => false, :size => '400x200',
- :legend => ["Matt's Mojo", "Rob's Mojo"] )
-</pre>
-!http://chart.apis.google.com/chart?cht=bvg&chdl=Matt's+Mojo|Rob's+Mojo&chs=400x200&chd=s:9UGo,Uo9C&chco=FF0000,00FF00&chtt=Matt+vs+Rob(legend)!
-
-<pre syntax="ruby">
- Gchart.line( :title => "Matt vs Rob",
- :data => [[300, 100, 30, 200], [100, 200, 300, 10]],
- :bar_colors => ['FF0000','00FF00'],
- :stacked => false, :size => '400x200',
- :legend => ["Matt's Mojo", "Rob's Mojo"] )
-</pre>
-!http://chart.apis.google.com/chart?cht=lc&chdl=Matt's+Mojo|Rob's+Mojo&chs=400x200&chd=s:9UGo,Uo9C&chco=FF0000,00FF00&chtt=Matt+vs+Rob(line legend)!
-
-
-<pre syntax="ruby">
- Gchart.pie_3d( :title => 'ruby_fu', :size => '400x200',
- :data => [10, 45, 45], :labels => ["DHH", "Rob", "Matt"] )
-</pre>
-
-!http://chart.apis.google.com/chart?cht=p3&chl=DHH|Rob|Matt&chs=400x200&chd=s:N99&chtt=ruby_fu(labels)!
-
-*Display axis labels*
-
-<pre syntax="ruby">
- Gchart.line( :data => [300, 100, 30, 200, 100, 200, 300, 10], :axis_with_labels => 'x,y,r')
-</pre>
-
-or you can use the other syntax:
-
-<pre syntax="ruby">
- Gchart.line( :data => [300, 100, 30, 200, 100, 200, 300, 10], :axis_with_labels => ['x','y','r'])
-</pre>
-
-!http://chart.apis.google.com/chart?cht=lc&chs=300x200&chxt=x,y,r&chd=s:9UGoUo9C(axis with labels)!
-
-<pre syntax="ruby">
- Gchart.line( :data => [300, 100, 30, 200, 100, 200, 300, 10], :axis_with_labels => 'x',
- :axis_labels => ['Jan|July|Jan|July|Jan'])
-</pre>
-
-or you can use the other syntax:
-
-<pre syntax="ruby">
- Gchart.line( :data => [300, 100, 30, 200, 100, 200, 300, 10], :axis_with_labels => 'x',
- :axis_labels => ['Jan','July','Jan','July','Jan'])
-</pre>
-
-!http://chart.apis.google.com/chart?cht=lc&chxl=0:|Jan|July|Jan|July|Jan&chs=300x200&chxt=x&chd=s:9UGoUo9C(x labels)!
-
-*multiple axis labels*
-
-<pre syntax="ruby">
- Gchart.line( :data => [300, 100, 30, 200, 100, 200, 300, 10], :axis_with_labels => 'x,r',
- :axis_labels => ['Jan|July|Jan|July|Jan', '2005|2006|2007'])
-</pre>
-
-or
-
-<pre syntax="ruby">
- Gchart.line( :data => [300, 100, 30, 200, 100, 200, 300, 10], :axis_with_labels => 'x,r',
- :axis_labels => [['Jan','July','Jan','July','Jan'], ['2005','2006','2007']])
-</pre>
-
-!http://chart.apis.google.com/chart?cht=lc&chxl=0:|Jan|July|Jan|July|Jan|1:|2005|2006|2007&chs=300x200&chxt=x,r&chd=s:9UGoUo9C(multiple axis labels)!
-
-(This syntax will probably be improved in the future)
-
-*custom params*
-
-I certainly didn't cover the entire API, if you want to add your own params:
-
-<pre syntax="ruby">
- Gchart.line( custom => 'chd=s:93zyvneTTOMJMLIJFHEAECFJGHDBFCFIERcgnpy45879,IJKNUWUWYdnswz047977315533zy1246872tnkgcaZQONHCECAAAAEII&chls=3,6,3|1,1,0')
-</pre>
-
-!http://chart.apis.google.com/chart?cht=lc&chs=300x200&chd=s:93zyvneTTOMJMLIJFHEAECFJGHDBFCFIERcgnpy45879,IJKNUWUWYdnswz047977315533zy1246872tnkgcaZQONHCECAAAAEII&chls=3,6,3|1,1,0(Custom)!
-
----
-
-*Save the chart as a file*
-
-You might prefer to save the chart instead of using the url, not a problem:
-
-<pre syntax="ruby">
- Gchart.line(:data => [0, 26], :format => 'file')
-</pre>
-
-You might want to specify the path and/or the filename used to save your chart:
-
-<pre syntax="ruby">
- Gchart.line(:data => [0, 26], :format => 'file', :filename => 'custom_filename.png')
-</pre>
-
-*Insert as an image tag*
-
-Because, I'm lazy, I also added a custom format:
-
-<pre syntax="ruby">
- Gchart.line(:data => [0, 26], :format => 'img_tag')
-</pre>
-
-&lt;img src='http://chart.apis.google.com/chart?chs=300x200&chd=s:A9&cht=lc'/&gt;
-
----
-
-*Encoding*
-
-Google Chart API offers "3 types of data encoding":http://code.google.com/apis/chart/#chart_data
-
- * simple
- * text
- * extended
-
-By default this library uses the simple encoding, if you need a different type of encoding, you can change it really easily:
-
-default / simple: chd=s:9UGoUo9C
-<pre syntax="ruby">
- Gchart.line( :data => [300, 100, 30, 200, 100, 200, 300, 10] )
-</pre>
-
-extended: chd=e:..VVGZqqVVqq..CI
-<pre syntax="ruby">
- Gchart.line( :data => [300, 100, 30, 200, 100, 200, 300, 10], :encoding => 'extended' )
-</pre>
-
-text: chd=t:300,100,30,200,100,200,300,10
-<pre syntax="ruby">
- Gchart.line( :data => [300, 100, 30, 200, 100, 200, 300, 10], :encoding => 'text' )
-</pre>
-
-(note that the text encoding doesn't use a max value and therefore should be under 100)
-
-*Max value*
-
-Simple and extended encoding support the max value option.
-
-The max value option is a simple way of scaling your graph. The data is converted in chart value with the highest chart value being the highest point on the graph. By default, the calculation is done for you. However you can specify your own maximum or not use a maximum at all.
-
-<pre syntax="ruby">
- Gchart.line( :data => [300, 100, 30, 200, 100, 200, 300, 10] )
-</pre>
-
-!http://chart.apis.google.com/chart?cht=lc&chs=300x200&chd=s:9UGoUo9C(Title)!
-
-<pre syntax="ruby">
- Gchart.line( :data => [300, 100, 30, 200, 100, 200, 300, 10], :max_value => 500 )
-</pre>
-
-!http://chart.apis.google.com/chart?cht=lc&chs=300x200&chd=s:kMDYMYkB(max 500)!
-
-<pre syntax="ruby">
- Gchart.line( :data => [100, 20, 30, 20, 10, 14, 30, 10], :max_value => false )
-</pre>
-
-!http://chart.apis.google.com/chart?cht=lc&chs=300x200&chd=s:_UeUKOeK(real size)!
-
-
-
-h2. Repository
-
-The trunk repository is <code>svn://rubyforge.org/var/svn/Gchart/trunk</code> for anonymous access.
-
-h2. License
-
-This code is free to use under the terms of the MIT license.
-
-h2. Contact
-
-Comments are welcome. Send an email to "Matt Aimonetti":mailto:mattaimonetti@gmail.com
-
diff --git a/vendor/plugins/googlecharts/website/javascripts/rounded_corners_lite.inc.js b/vendor/plugins/googlecharts/website/javascripts/rounded_corners_lite.inc.js
deleted file mode 100644
index afc3ea3..0000000
--- a/vendor/plugins/googlecharts/website/javascripts/rounded_corners_lite.inc.js
+++ /dev/null
@@ -1,285 +0,0 @@
-
- /****************************************************************
- * *
- * curvyCorners *
- * ------------ *
- * *
- * This script generates rounded corners for your divs. *
- * *
- * Version 1.2.9 *
- * Copyright (c) 2006 Cameron Cooke *
- * By: Cameron Cooke and Tim Hutchison. *
- * *
- * *
- * Website: http://www.curvycorners.net *
- * Email: info@totalinfinity.com *
- * Forum: http://www.curvycorners.net/forum/ *
- * *
- * *
- * This library is free software; you can redistribute *
- * it and/or modify it under the terms of the GNU *
- * Lesser General Public License as published by the *
- * Free Software Foundation; either version 2.1 of the *
- * License, or (at your option) any later version. *
- * *
- * This library is distributed in the hope that it will *
- * be useful, but WITHOUT ANY WARRANTY; without even the *
- * implied warranty of MERCHANTABILITY or FITNESS FOR A *
- * PARTICULAR PURPOSE. See the GNU Lesser General Public *
- * License for more details. *
- * *
- * You should have received a copy of the GNU Lesser *
- * General Public License along with this library; *
- * Inc., 59 Temple Place, Suite 330, Boston, *
- * MA 02111-1307 USA *
- * *
- ****************************************************************/
-
-var isIE = navigator.userAgent.toLowerCase().indexOf("msie") > -1; var isMoz = document.implementation && document.implementation.createDocument; var isSafari = ((navigator.userAgent.toLowerCase().indexOf('safari')!=-1)&&(navigator.userAgent.toLowerCase().indexOf('mac')!=-1))?true:false; function curvyCorners()
-{ if(typeof(arguments[0]) != "object") throw newCurvyError("First parameter of curvyCorners() must be an object."); if(typeof(arguments[1]) != "object" && typeof(arguments[1]) != "string") throw newCurvyError("Second parameter of curvyCorners() must be an object or a class name."); if(typeof(arguments[1]) == "string")
-{ var startIndex = 0; var boxCol = getElementsByClass(arguments[1]);}
-else
-{ var startIndex = 1; var boxCol = arguments;}
-var curvyCornersCol = new Array(); if(arguments[0].validTags)
-var validElements = arguments[0].validTags; else
-var validElements = ["div"]; for(var i = startIndex, j = boxCol.length; i < j; i++)
-{ var currentTag = boxCol[i].tagName.toLowerCase(); if(inArray(validElements, currentTag) !== false)
-{ curvyCornersCol[curvyCornersCol.length] = new curvyObject(arguments[0], boxCol[i]);}
-}
-this.objects = curvyCornersCol; this.applyCornersToAll = function()
-{ for(var x = 0, k = this.objects.length; x < k; x++)
-{ this.objects[x].applyCorners();}
-}
-}
-function curvyObject()
-{ this.box = arguments[1]; this.settings = arguments[0]; this.topContainer = null; this.bottomContainer = null; this.masterCorners = new Array(); this.contentDIV = null; var boxHeight = get_style(this.box, "height", "height"); var boxWidth = get_style(this.box, "width", "width"); var borderWidth = get_style(this.box, "borderTopWidth", "border-top-width"); var borderColour = get_style(this.box, "borderTopColor", "border-top-color"); var boxColour = get_style(this.box, "backgroundColor", "background-color"); var backgroundImage = get_style(this.box, "backgroundImage", "background-image"); var boxPosition = get_style(this.box, "position", "position"); var boxPadding = get_style(this.box, "paddingTop", "padding-top"); this.boxHeight = parseInt(((boxHeight != "" && boxHeight != "auto" && boxHeight.indexOf("%") == -1)? boxHeight.substring(0, boxHeight.indexOf("px")) : this.box.scrollHeight)); this.boxWidth = parseInt(((boxWidth != "" && boxWidth != "auto" && boxWidth.indexOf("%") == -1)? boxWidth.substring(0, boxWidth.indexOf("px")) : this.box.scrollWidth)); this.borderWidth = parseInt(((borderWidth != "" && borderWidth.indexOf("px") !== -1)? borderWidth.slice(0, borderWidth.indexOf("px")) : 0)); this.boxColour = format_colour(boxColour); this.boxPadding = parseInt(((boxPadding != "" && boxPadding.indexOf("px") !== -1)? boxPadding.slice(0, boxPadding.indexOf("px")) : 0)); this.borderColour = format_colour(borderColour); this.borderString = this.borderWidth + "px" + " solid " + this.borderColour; this.backgroundImage = ((backgroundImage != "none")? backgroundImage : ""); this.boxContent = this.box.innerHTML; if(boxPosition != "absolute") this.box.style.position = "relative"; this.box.style.padding = "0px"; if(isIE && boxWidth == "auto" && boxHeight == "auto") this.box.style.width = "100%"; if(this.settings.autoPad == true && this.boxPadding > 0)
-this.box.innerHTML = ""; this.applyCorners = function()
-{ for(var t = 0; t < 2; t++)
-{ switch(t)
-{ case 0:
-if(this.settings.tl || this.settings.tr)
-{ var newMainContainer = document.createElement("DIV"); newMainContainer.style.width = "100%"; newMainContainer.style.fontSize = "1px"; newMainContainer.style.overflow = "hidden"; newMainContainer.style.position = "absolute"; newMainContainer.style.paddingLeft = this.borderWidth + "px"; newMainContainer.style.paddingRight = this.borderWidth + "px"; var topMaxRadius = Math.max(this.settings.tl ? this.settings.tl.radius : 0, this.settings.tr ? this.settings.tr.radius : 0); newMainContainer.style.height = topMaxRadius + "px"; newMainContainer.style.top = 0 - topMaxRadius + "px"; newMainContainer.style.left = 0 - this.borderWidth + "px"; this.topContainer = this.box.appendChild(newMainContainer);}
-break; case 1:
-if(this.settings.bl || this.settings.br)
-{ var newMainContainer = document.createElement("DIV"); newMainContainer.style.width = "100%"; newMainContainer.style.fontSize = "1px"; newMainContainer.style.overflow = "hidden"; newMainContainer.style.position = "absolute"; newMainContainer.style.paddingLeft = this.borderWidth + "px"; newMainContainer.style.paddingRight = this.borderWidth + "px"; var botMaxRadius = Math.max(this.settings.bl ? this.settings.bl.radius : 0, this.settings.br ? this.settings.br.radius : 0); newMainContainer.style.height = botMaxRadius + "px"; newMainContainer.style.bottom = 0 - botMaxRadius + "px"; newMainContainer.style.left = 0 - this.borderWidth + "px"; this.bottomContainer = this.box.appendChild(newMainContainer);}
-break;}
-}
-if(this.topContainer) this.box.style.borderTopWidth = "0px"; if(this.bottomContainer) this.box.style.borderBottomWidth = "0px"; var corners = ["tr", "tl", "br", "bl"]; for(var i in corners)
-{ if(i > -1 < 4)
-{ var cc = corners[i]; if(!this.settings[cc])
-{ if(((cc == "tr" || cc == "tl") && this.topContainer != null) || ((cc == "br" || cc == "bl") && this.bottomContainer != null))
-{ var newCorner = document.createElement("DIV"); newCorner.style.position = "relative"; newCorner.style.fontSize = "1px"; newCorner.style.overflow = "hidden"; if(this.backgroundImage == "")
-newCorner.style.backgroundColor = this.boxColour; else
-newCorner.style.backgroundImage = this.backgroundImage; switch(cc)
-{ case "tl":
-newCorner.style.height = topMaxRadius - this.borderWidth + "px"; newCorner.style.marginRight = this.settings.tr.radius - (this.borderWidth*2) + "px"; newCorner.style.borderLeft = this.borderString; newCorner.style.borderTop = this.borderString; newCorner.style.left = -this.borderWidth + "px"; break; case "tr":
-newCorner.style.height = topMaxRadius - this.borderWidth + "px"; newCorner.style.marginLeft = this.settings.tl.radius - (this.borderWidth*2) + "px"; newCorner.style.borderRight = this.borderString; newCorner.style.borderTop = this.borderString; newCorner.style.backgroundPosition = "-" + (topMaxRadius + this.borderWidth) + "px 0px"; newCorner.style.left = this.borderWidth + "px"; break; case "bl":
-newCorner.style.height = botMaxRadius - this.borderWidth + "px"; newCorner.style.marginRight = this.settings.br.radius - (this.borderWidth*2) + "px"; newCorner.style.borderLeft = this.borderString; newCorner.style.borderBottom = this.borderString; newCorner.style.left = -this.borderWidth + "px"; newCorner.style.backgroundPosition = "-" + (this.borderWidth) + "px -" + (this.boxHeight + (botMaxRadius + this.borderWidth)) + "px"; break; case "br":
-newCorner.style.height = botMaxRadius - this.borderWidth + "px"; newCorner.style.marginLeft = this.settings.bl.radius - (this.borderWidth*2) + "px"; newCorner.style.borderRight = this.borderString; newCorner.style.borderBottom = this.borderString; newCorner.style.left = this.borderWidth + "px"
-newCorner.style.backgroundPosition = "-" + (botMaxRadius + this.borderWidth) + "px -" + (this.boxHeight + (botMaxRadius + this.borderWidth)) + "px"; break;}
-}
-}
-else
-{ if(this.masterCorners[this.settings[cc].radius])
-{ var newCorner = this.masterCorners[this.settings[cc].radius].cloneNode(true);}
-else
-{ var newCorner = document.createElement("DIV"); newCorner.style.height = this.settings[cc].radius + "px"; newCorner.style.width = this.settings[cc].radius + "px"; newCorner.style.position = "absolute"; newCorner.style.fontSize = "1px"; newCorner.style.overflow = "hidden"; var borderRadius = parseInt(this.settings[cc].radius - this.borderWidth); for(var intx = 0, j = this.settings[cc].radius; intx < j; intx++)
-{ if((intx +1) >= borderRadius)
-var y1 = -1; else
-var y1 = (Math.floor(Math.sqrt(Math.pow(borderRadius, 2) - Math.pow((intx+1), 2))) - 1); if(borderRadius != j)
-{ if((intx) >= borderRadius)
-var y2 = -1; else
-var y2 = Math.ceil(Math.sqrt(Math.pow(borderRadius,2) - Math.pow(intx, 2))); if((intx+1) >= j)
-var y3 = -1; else
-var y3 = (Math.floor(Math.sqrt(Math.pow(j ,2) - Math.pow((intx+1), 2))) - 1);}
-if((intx) >= j)
-var y4 = -1; else
-var y4 = Math.ceil(Math.sqrt(Math.pow(j ,2) - Math.pow(intx, 2))); if(y1 > -1) this.drawPixel(intx, 0, this.boxColour, 100, (y1+1), newCorner, -1, this.settings[cc].radius); if(borderRadius != j)
-{ for(var inty = (y1 + 1); inty < y2; inty++)
-{ if(this.settings.antiAlias)
-{ if(this.backgroundImage != "")
-{ var borderFract = (pixelFraction(intx, inty, borderRadius) * 100); if(borderFract < 30)
-{ this.drawPixel(intx, inty, this.borderColour, 100, 1, newCorner, 0, this.settings[cc].radius);}
-else
-{ this.drawPixel(intx, inty, this.borderColour, 100, 1, newCorner, -1, this.settings[cc].radius);}
-}
-else
-{ var pixelcolour = BlendColour(this.boxColour, this.borderColour, pixelFraction(intx, inty, borderRadius)); this.drawPixel(intx, inty, pixelcolour, 100, 1, newCorner, 0, this.settings[cc].radius, cc);}
-}
-}
-if(this.settings.antiAlias)
-{ if(y3 >= y2)
-{ if (y2 == -1) y2 = 0; this.drawPixel(intx, y2, this.borderColour, 100, (y3 - y2 + 1), newCorner, 0, 0);}
-}
-else
-{ if(y3 >= y1)
-{ this.drawPixel(intx, (y1 + 1), this.borderColour, 100, (y3 - y1), newCorner, 0, 0);}
-}
-var outsideColour = this.borderColour;}
-else
-{ var outsideColour = this.boxColour; var y3 = y1;}
-if(this.settings.antiAlias)
-{ for(var inty = (y3 + 1); inty < y4; inty++)
-{ this.drawPixel(intx, inty, outsideColour, (pixelFraction(intx, inty , j) * 100), 1, newCorner, ((this.borderWidth > 0)? 0 : -1), this.settings[cc].radius);}
-}
-}
-this.masterCorners[this.settings[cc].radius] = newCorner.cloneNode(true);}
-if(cc != "br")
-{ for(var t = 0, k = newCorner.childNodes.length; t < k; t++)
-{ var pixelBar = newCorner.childNodes[t]; var pixelBarTop = parseInt(pixelBar.style.top.substring(0, pixelBar.style.top.indexOf("px"))); var pixelBarLeft = parseInt(pixelBar.style.left.substring(0, pixelBar.style.left.indexOf("px"))); var pixelBarHeight = parseInt(pixelBar.style.height.substring(0, pixelBar.style.height.indexOf("px"))); if(cc == "tl" || cc == "bl"){ pixelBar.style.left = this.settings[cc].radius -pixelBarLeft -1 + "px";}
-if(cc == "tr" || cc == "tl"){ pixelBar.style.top = this.settings[cc].radius -pixelBarHeight -pixelBarTop + "px";}
-switch(cc)
-{ case "tr":
-pixelBar.style.backgroundPosition = "-" + Math.abs((this.boxWidth - this.settings[cc].radius + this.borderWidth) + pixelBarLeft) + "px -" + Math.abs(this.settings[cc].radius -pixelBarHeight -pixelBarTop - this.borderWidth) + "px"; break; case "tl":
-pixelBar.style.backgroundPosition = "-" + Math.abs((this.settings[cc].radius -pixelBarLeft -1) - this.borderWidth) + "px -" + Math.abs(this.settings[cc].radius -pixelBarHeight -pixelBarTop - this.borderWidth) + "px"; break; case "bl":
-pixelBar.style.backgroundPosition = "-" + Math.abs((this.settings[cc].radius -pixelBarLeft -1) - this.borderWidth) + "px -" + Math.abs((this.boxHeight + this.settings[cc].radius + pixelBarTop) -this.borderWidth) + "px"; break;}
-}
-}
-}
-if(newCorner)
-{ switch(cc)
-{ case "tl":
-if(newCorner.style.position == "absolute") newCorner.style.top = "0px"; if(newCorner.style.position == "absolute") newCorner.style.left = "0px"; if(this.topContainer) this.topContainer.appendChild(newCorner); break; case "tr":
-if(newCorner.style.position == "absolute") newCorner.style.top = "0px"; if(newCorner.style.position == "absolute") newCorner.style.right = "0px"; if(this.topContainer) this.topContainer.appendChild(newCorner); break; case "bl":
-if(newCorner.style.position == "absolute") newCorner.style.bottom = "0px"; if(newCorner.style.position == "absolute") newCorner.style.left = "0px"; if(this.bottomContainer) this.bottomContainer.appendChild(newCorner); break; case "br":
-if(newCorner.style.position == "absolute") newCorner.style.bottom = "0px"; if(newCorner.style.position == "absolute") newCorner.style.right = "0px"; if(this.bottomContainer) this.bottomContainer.appendChild(newCorner); break;}
-}
-}
-}
-var radiusDiff = new Array(); radiusDiff["t"] = Math.abs(this.settings.tl.radius - this.settings.tr.radius)
-radiusDiff["b"] = Math.abs(this.settings.bl.radius - this.settings.br.radius); for(z in radiusDiff)
-{ if(z == "t" || z == "b")
-{ if(radiusDiff[z])
-{ var smallerCornerType = ((this.settings[z + "l"].radius < this.settings[z + "r"].radius)? z +"l" : z +"r"); var newFiller = document.createElement("DIV"); newFiller.style.height = radiusDiff[z] + "px"; newFiller.style.width = this.settings[smallerCornerType].radius+ "px"
-newFiller.style.position = "absolute"; newFiller.style.fontSize = "1px"; newFiller.style.overflow = "hidden"; newFiller.style.backgroundColor = this.boxColour; switch(smallerCornerType)
-{ case "tl":
-newFiller.style.bottom = "0px"; newFiller.style.left = "0px"; newFiller.style.borderLeft = this.borderString; this.topContainer.appendChild(newFiller); break; case "tr":
-newFiller.style.bottom = "0px"; newFiller.style.right = "0px"; newFiller.style.borderRight = this.borderString; this.topContainer.appendChild(newFiller); break; case "bl":
-newFiller.style.top = "0px"; newFiller.style.left = "0px"; newFiller.style.borderLeft = this.borderString; this.bottomContainer.appendChild(newFiller); break; case "br":
-newFiller.style.top = "0px"; newFiller.style.right = "0px"; newFiller.style.borderRight = this.borderString; this.bottomContainer.appendChild(newFiller); break;}
-}
-var newFillerBar = document.createElement("DIV"); newFillerBar.style.position = "relative"; newFillerBar.style.fontSize = "1px"; newFillerBar.style.overflow = "hidden"; newFillerBar.style.backgroundColor = this.boxColour; newFillerBar.style.backgroundImage = this.backgroundImage; switch(z)
-{ case "t":
-if(this.topContainer)
-{ if(this.settings.tl.radius && this.settings.tr.radius)
-{ newFillerBar.style.height = topMaxRadius - this.borderWidth + "px"; newFillerBar.style.marginLeft = this.settings.tl.radius - this.borderWidth + "px"; newFillerBar.style.marginRight = this.settings.tr.radius - this.borderWidth + "px"; newFillerBar.style.borderTop = this.borderString; if(this.backgroundImage != "")
-newFillerBar.style.backgroundPosition = "-" + (topMaxRadius + this.borderWidth) + "px 0px"; this.topContainer.appendChild(newFillerBar);}
-this.box.style.backgroundPosition = "0px -" + (topMaxRadius - this.borderWidth) + "px";}
-break; case "b":
-if(this.bottomContainer)
-{ if(this.settings.bl.radius && this.settings.br.radius)
-{ newFillerBar.style.height = botMaxRadius - this.borderWidth + "px"; newFillerBar.style.marginLeft = this.settings.bl.radius - this.borderWidth + "px"; newFillerBar.style.marginRight = this.settings.br.radius - this.borderWidth + "px"; newFillerBar.style.borderBottom = this.borderString; if(this.backgroundImage != "")
-newFillerBar.style.backgroundPosition = "-" + (botMaxRadius + this.borderWidth) + "px -" + (this.boxHeight + (topMaxRadius + this.borderWidth)) + "px"; this.bottomContainer.appendChild(newFillerBar);}
-}
-break;}
-}
-}
-if(this.settings.autoPad == true && this.boxPadding > 0)
-{ var contentContainer = document.createElement("DIV"); contentContainer.style.position = "relative"; contentContainer.innerHTML = this.boxContent; contentContainer.className = "autoPadDiv"; var topPadding = Math.abs(topMaxRadius - this.boxPadding); var botPadding = Math.abs(botMaxRadius - this.boxPadding); if(topMaxRadius < this.boxPadding)
-contentContainer.style.paddingTop = topPadding + "px"; if(botMaxRadius < this.boxPadding)
-contentContainer.style.paddingBottom = botMaxRadius + "px"; contentContainer.style.paddingLeft = this.boxPadding + "px"; contentContainer.style.paddingRight = this.boxPadding + "px"; this.contentDIV = this.box.appendChild(contentContainer);}
-}
-this.drawPixel = function(intx, inty, colour, transAmount, height, newCorner, image, cornerRadius)
-{ var pixel = document.createElement("DIV"); pixel.style.height = height + "px"; pixel.style.width = "1px"; pixel.style.position = "absolute"; pixel.style.fontSize = "1px"; pixel.style.overflow = "hidden"; var topMaxRadius = Math.max(this.settings["tr"].radius, this.settings["tl"].radius); if(image == -1 && this.backgroundImage != "")
-{ pixel.style.backgroundImage = this.backgroundImage; pixel.style.backgroundPosition = "-" + (this.boxWidth - (cornerRadius - intx) + this.borderWidth) + "px -" + ((this.boxHeight + topMaxRadius + inty) -this.borderWidth) + "px";}
-else
-{ pixel.style.backgroundColor = colour;}
-if (transAmount != 100)
-setOpacity(pixel, transAmount); pixel.style.top = inty + "px"; pixel.style.left = intx + "px"; newCorner.appendChild(pixel);}
-}
-function insertAfter(parent, node, referenceNode)
-{ parent.insertBefore(node, referenceNode.nextSibling);}
-function BlendColour(Col1, Col2, Col1Fraction)
-{ var red1 = parseInt(Col1.substr(1,2),16); var green1 = parseInt(Col1.substr(3,2),16); var blue1 = parseInt(Col1.substr(5,2),16); var red2 = parseInt(Col2.substr(1,2),16); var green2 = parseInt(Col2.substr(3,2),16); var blue2 = parseInt(Col2.substr(5,2),16); if(Col1Fraction > 1 || Col1Fraction < 0) Col1Fraction = 1; var endRed = Math.round((red1 * Col1Fraction) + (red2 * (1 - Col1Fraction))); if(endRed > 255) endRed = 255; if(endRed < 0) endRed = 0; var endGreen = Math.round((green1 * Col1Fraction) + (green2 * (1 - Col1Fraction))); if(endGreen > 255) endGreen = 255; if(endGreen < 0) endGreen = 0; var endBlue = Math.round((blue1 * Col1Fraction) + (blue2 * (1 - Col1Fraction))); if(endBlue > 255) endBlue = 255; if(endBlue < 0) endBlue = 0; return "#" + IntToHex(endRed)+ IntToHex(endGreen)+ IntToHex(endBlue);}
-function IntToHex(strNum)
-{ base = strNum / 16; rem = strNum % 16; base = base - (rem / 16); baseS = MakeHex(base); remS = MakeHex(rem); return baseS + '' + remS;}
-function MakeHex(x)
-{ if((x >= 0) && (x <= 9))
-{ return x;}
-else
-{ switch(x)
-{ case 10: return "A"; case 11: return "B"; case 12: return "C"; case 13: return "D"; case 14: return "E"; case 15: return "F";}
-}
-}
-function pixelFraction(x, y, r)
-{ var pixelfraction = 0; var xvalues = new Array(1); var yvalues = new Array(1); var point = 0; var whatsides = ""; var intersect = Math.sqrt((Math.pow(r,2) - Math.pow(x,2))); if ((intersect >= y) && (intersect < (y+1)))
-{ whatsides = "Left"; xvalues[point] = 0; yvalues[point] = intersect - y; point = point + 1;}
-var intersect = Math.sqrt((Math.pow(r,2) - Math.pow(y+1,2))); if ((intersect >= x) && (intersect < (x+1)))
-{ whatsides = whatsides + "Top"; xvalues[point] = intersect - x; yvalues[point] = 1; point = point + 1;}
-var intersect = Math.sqrt((Math.pow(r,2) - Math.pow(x+1,2))); if ((intersect >= y) && (intersect < (y+1)))
-{ whatsides = whatsides + "Right"; xvalues[point] = 1; yvalues[point] = intersect - y; point = point + 1;}
-var intersect = Math.sqrt((Math.pow(r,2) - Math.pow(y,2))); if ((intersect >= x) && (intersect < (x+1)))
-{ whatsides = whatsides + "Bottom"; xvalues[point] = intersect - x; yvalues[point] = 0;}
-switch (whatsides)
-{ case "LeftRight":
-pixelfraction = Math.min(yvalues[0],yvalues[1]) + ((Math.max(yvalues[0],yvalues[1]) - Math.min(yvalues[0],yvalues[1]))/2); break; case "TopRight":
-pixelfraction = 1-(((1-xvalues[0])*(1-yvalues[1]))/2); break; case "TopBottom":
-pixelfraction = Math.min(xvalues[0],xvalues[1]) + ((Math.max(xvalues[0],xvalues[1]) - Math.min(xvalues[0],xvalues[1]))/2); break; case "LeftBottom":
-pixelfraction = (yvalues[0]*xvalues[1])/2; break; default:
-pixelfraction = 1;}
-return pixelfraction;}
-function rgb2Hex(rgbColour)
-{ try{ var rgbArray = rgb2Array(rgbColour); var red = parseInt(rgbArray[0]); var green = parseInt(rgbArray[1]); var blue = parseInt(rgbArray[2]); var hexColour = "#" + IntToHex(red) + IntToHex(green) + IntToHex(blue);}
-catch(e){ alert("There was an error converting the RGB value to Hexadecimal in function rgb2Hex");}
-return hexColour;}
-function rgb2Array(rgbColour)
-{ var rgbValues = rgbColour.substring(4, rgbColour.indexOf(")")); var rgbArray = rgbValues.split(", "); return rgbArray;}
-function setOpacity(obj, opacity)
-{ opacity = (opacity == 100)?99.999:opacity; if(isSafari && obj.tagName != "IFRAME")
-{ var rgbArray = rgb2Array(obj.style.backgroundColor); var red = parseInt(rgbArray[0]); var green = parseInt(rgbArray[1]); var blue = parseInt(rgbArray[2]); obj.style.backgroundColor = "rgba(" + red + ", " + green + ", " + blue + ", " + opacity/100 + ")";}
-else if(typeof(obj.style.opacity) != "undefined")
-{ obj.style.opacity = opacity/100;}
-else if(typeof(obj.style.MozOpacity) != "undefined")
-{ obj.style.MozOpacity = opacity/100;}
-else if(typeof(obj.style.filter) != "undefined")
-{ obj.style.filter = "alpha(opacity:" + opacity + ")";}
-else if(typeof(obj.style.KHTMLOpacity) != "undefined")
-{ obj.style.KHTMLOpacity = opacity/100;}
-}
-function inArray(array, value)
-{ for(var i = 0; i < array.length; i++){ if (array[i] === value) return i;}
-return false;}
-function inArrayKey(array, value)
-{ for(key in array){ if(key === value) return true;}
-return false;}
-function addEvent(elm, evType, fn, useCapture) { if (elm.addEventListener) { elm.addEventListener(evType, fn, useCapture); return true;}
-else if (elm.attachEvent) { var r = elm.attachEvent('on' + evType, fn); return r;}
-else { elm['on' + evType] = fn;}
-}
-function removeEvent(obj, evType, fn, useCapture){ if (obj.removeEventListener){ obj.removeEventListener(evType, fn, useCapture); return true;} else if (obj.detachEvent){ var r = obj.detachEvent("on"+evType, fn); return r;} else { alert("Handler could not be removed");}
-}
-function format_colour(colour)
-{ var returnColour = "#ffffff"; if(colour != "" && colour != "transparent")
-{ if(colour.substr(0, 3) == "rgb")
-{ returnColour = rgb2Hex(colour);}
-else if(colour.length == 4)
-{ returnColour = "#" + colour.substring(1, 2) + colour.substring(1, 2) + colour.substring(2, 3) + colour.substring(2, 3) + colour.substring(3, 4) + colour.substring(3, 4);}
-else
-{ returnColour = colour;}
-}
-return returnColour;}
-function get_style(obj, property, propertyNS)
-{ try
-{ if(obj.currentStyle)
-{ var returnVal = eval("obj.currentStyle." + property);}
-else
-{ if(isSafari && obj.style.display == "none")
-{ obj.style.display = ""; var wasHidden = true;}
-var returnVal = document.defaultView.getComputedStyle(obj, '').getPropertyValue(propertyNS); if(isSafari && wasHidden)
-{ obj.style.display = "none";}
-}
-}
-catch(e)
-{ }
-return returnVal;}
-function getElementsByClass(searchClass, node, tag)
-{ var classElements = new Array(); if(node == null)
-node = document; if(tag == null)
-tag = '*'; var els = node.getElementsByTagName(tag); var elsLen = els.length; var pattern = new RegExp("(^|\s)"+searchClass+"(\s|$)"); for (i = 0, j = 0; i < elsLen; i++)
-{ if(pattern.test(els[i].className))
-{ classElements[j] = els[i]; j++;}
-}
-return classElements;}
-function newCurvyError(errorMessage)
-{ return new Error("curvyCorners Error:\n" + errorMessage)
-}
diff --git a/vendor/plugins/googlecharts/website/stylesheets/screen.css b/vendor/plugins/googlecharts/website/stylesheets/screen.css
deleted file mode 100644
index 2c84cd0..0000000
--- a/vendor/plugins/googlecharts/website/stylesheets/screen.css
+++ /dev/null
@@ -1,138 +0,0 @@
-body {
- background-color: #E1D1F1;
- font-family: "Georgia", sans-serif;
- font-size: 16px;
- line-height: 1.6em;
- padding: 1.6em 0 0 0;
- color: #333;
-}
-h1, h2, h3, h4, h5, h6 {
- color: #444;
-}
-h1 {
- font-family: sans-serif;
- font-weight: normal;
- font-size: 4em;
- line-height: 0.8em;
- letter-spacing: -0.1ex;
- margin: 5px;
-}
-li {
- padding: 0;
- margin: 0;
- list-style-type: square;
-}
-a {
- color: #5E5AFF;
- background-color: #DAC;
- font-weight: normal;
- text-decoration: underline;
-}
-blockquote {
- font-size: 90%;
- font-style: italic;
- border-left: 1px solid #111;
- padding-left: 1em;
-}
-.caps {
- font-size: 80%;
-}
-
-#main {
- width: 45em;
- padding: 0;
- margin: 0 auto;
-}
-.coda {
- text-align: right;
- color: #77f;
- font-size: smaller;
-}
-
-table {
- font-size: 90%;
- line-height: 1.4em;
- color: #ff8;
- background-color: #111;
- padding: 2px 10px 2px 10px;
- border-style: dashed;
-}
-
-th {
- color: #fff;
-}
-
-td {
- padding: 2px 10px 2px 10px;
-}
-
-.success {
- color: #0CC52B;
-}
-
-.failed {
- color: #E90A1B;
-}
-
-.unknown {
- color: #995000;
-}
-pre, code {
- font-family: monospace;
- font-size: 90%;
- line-height: 1.4em;
- color: #ff8;
- background-color: #111;
- padding: 2px 10px 2px 10px;
-}
-.comment { color: #aaa; font-style: italic; }
-.keyword { color: #eff; font-weight: bold; }
-.punct { color: #eee; font-weight: bold; }
-.symbol { color: #0bb; }
-.string { color: #6b4; }
-.ident { color: #ff8; }
-.constant { color: #66f; }
-.regex { color: #ec6; }
-.number { color: #F99; }
-.expr { color: #227; }
-
-#version {
- float: right;
- text-align: right;
- font-family: sans-serif;
- font-weight: normal;
- background-color: #B3ABFF;
- color: #141331;
- padding: 15px 20px 10px 20px;
- margin: 0 auto;
- margin-top: 15px;
- border: 3px solid #141331;
-}
-
-#version .numbers {
- display: block;
- font-size: 4em;
- line-height: 0.8em;
- letter-spacing: -0.1ex;
- margin-bottom: 15px;
-}
-
-#version p {
- text-decoration: none;
- color: #141331;
- background-color: #B3ABFF;
- margin: 0;
- padding: 0;
-}
-
-#version a {
- text-decoration: none;
- color: #141331;
- background-color: #B3ABFF;
-}
-
-.clickable {
- cursor: pointer;
- cursor: hand;
-}
-
diff --git a/vendor/plugins/googlecharts/website/template.rhtml b/vendor/plugins/googlecharts/website/template.rhtml
deleted file mode 100644
index cad593b..0000000
--- a/vendor/plugins/googlecharts/website/template.rhtml
+++ /dev/null
@@ -1,53 +0,0 @@
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
-"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
-<head>
- <link rel="stylesheet" href="stylesheets/screen.css" type="text/css" media="screen" />
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
- <title>
- <%= title %>
- </title>
- <script src="javascripts/rounded_corners_lite.inc.js" type="text/javascript"></script>
-<style>
-
-</style>
- <script type="text/javascript">
- window.onload = function() {
- settings = {
- tl: { radius: 10 },
- tr: { radius: 10 },
- bl: { radius: 10 },
- br: { radius: 10 },
- antiAlias: true,
- autoPad: true,
- validTags: ["div"]
- }
- var versionBox = new curvyCorners(settings, document.getElementById("version"));
- versionBox.applyCornersToAll();
- }
- </script>
-</head>
-<body>
-<div id="main">
-
- <h1><%= title %></h1>
- <div id="version" class="clickable" onclick='document.location = "<%= download %>"; return false'>
- <p>Get Version</p>
- <a href="<%= download %>" class="numbers"><%= version %></a>
- </div>
- <%= body %>
- <p class="coda">
- <a href="mattaimonetti@gmail.com">Matt Aimonetti</a>, <%= modified.pretty %><br>
- Theme extended from <a href="http://rb2js.rubyforge.org/">Paul Battley</a>
- </p>
-</div>
-
-<script src="http://www.google-analytics.com/urchin.js" type="text/javascript">
-</script>
-<script type="text/javascript">
-_uacct = "UA-179809-11";
-urchinTracker();
-</script>
-
-</body>
-</html>
diff --git a/vendor/plugins/gruff/History.txt b/vendor/plugins/gruff/History.txt
new file mode 100644
index 0000000..517ee3e
--- /dev/null
+++ b/vendor/plugins/gruff/History.txt
@@ -0,0 +1,98 @@
+== 0.3.2
+
+* Include init.rb for use as a Rails plugin.
+
+
+== 0.3.1
+
+* Fixed missing bullet graph bug (experimental, will be in a future release).
+
+== 0.3.0
+
+* Fixed bug where pie graphs weren't drawing their label correctly.
+
+== 0.2.9
+
+* Patch to make SideBar accurate instead of stacked [Marik]
+* Will be extracting net, pie, stacked, and side-stacked to separate gem
+ in next release.
+
+== 0.2.8
+
+* New accumulator bar graph (experimental)
+* Better mini graphs
+* Bug fixes
+
+== 0.2.7
+
+* Regenerated Manifest.txt
+* Added scene sample to package
+* Added mini side_bar (EXPERIMENTAL)
+* Added @zero_degree option to Gruff::Pie so first slice can start somewhere other than 3 o'clock
+* Increased size of numbers in Gruff::Mini::Pie
+* Added legend_box_size accessor
+
+== 0.2.6
+
+* Fixed missing side_bar.rb in Manifest.txt
+
+== 0.2.5
+
+* New mini graph types (Experimental)
+* Marker lines can be different color than text labels
+* Theme definition cleanup
+
+== 0.2.4
+
+* Added option to hide line numbers
+* Fixed code that was causing warnings
+
+== 0.2.3
+
+* Cleaned up measurements so the graph expands to fill the available space
+* Added x-axis and y-axis label options
+
+== 0.1.2
+
+* minimum_value and maximum_value can be set after data() to manually scale the graph
+* Fixed infinite loop bug when values are all equal
+* Added experimental net and spider graphs
+* Added non-linear scene graph for a simple interface to complex layered graphs
+* Initial refactoring of tests
+* A host of other bug fixes
+
+== 0.0.8
+
+* NEW Sidestacked Bar Graphs. [Alun Eyre]
+* baseline_value larger than data will now show correctly. [Mike Perham]
+* hide_dots and hide_lines are now options for line graphs.
+
+== 0.0.6
+
+* Fixed hang when no data is passed.
+
+== 0.0.4
+
+* Added bar graphs
+* Added area graphs
+* Added pie graphs
+* Added render_image_background for using images as background on a theme
+* Fixed small size legend centering issue
+* Added initial line marker rounding to significant digits (Christian Winkler)
+* Line graphs line width is scaled with number of points being drawn (Christian Winkler)
+
+== 0.0.3
+
+* Added option to draw line graphs without the lines (points only), thanks to Eric Hodel
+* Removed font-minimum check so graphs look better at 300px width
+
+== 0.0.2
+
+* Fixed to_blob (thanks to Carlos Villela)
+* Added bar graphs (initial functionality...will be enhanced)
+* Removed rendered test output from gem
+
+== 0.0.1
+
+* Initial release.
+* Line graphs only. Other graph styles coming soon.
diff --git a/vendor/plugins/googlecharts/License.txt b/vendor/plugins/gruff/MIT-LICENSE
index 8f67a70..097f8c9 100644
--- a/vendor/plugins/googlecharts/License.txt
+++ b/vendor/plugins/gruff/MIT-LICENSE
@@ -1,4 +1,4 @@
-Copyright (c) 2007 Matt Aimonetti
+Copyright (c) 2005 Geoffrey Grosenbach boss@topfunky.com
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
@@ -17,4 +17,5 @@ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. \ No newline at end of file
+WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
diff --git a/vendor/plugins/gruff/Manifest.txt b/vendor/plugins/gruff/Manifest.txt
new file mode 100644
index 0000000..15771d1
--- /dev/null
+++ b/vendor/plugins/gruff/Manifest.txt
@@ -0,0 +1,76 @@
+History.txt
+MIT-LICENSE
+Manifest.txt
+README.txt
+Rakefile
+assets/bubble.png
+assets/city_scene/background/0000.png
+assets/city_scene/background/0600.png
+assets/city_scene/background/2000.png
+assets/city_scene/clouds/cloudy.png
+assets/city_scene/clouds/partly_cloudy.png
+assets/city_scene/clouds/stormy.png
+assets/city_scene/grass/default.png
+assets/city_scene/haze/true.png
+assets/city_scene/number_sample/1.png
+assets/city_scene/number_sample/2.png
+assets/city_scene/number_sample/default.png
+assets/city_scene/sky/0000.png
+assets/city_scene/sky/0200.png
+assets/city_scene/sky/0400.png
+assets/city_scene/sky/0600.png
+assets/city_scene/sky/0800.png
+assets/city_scene/sky/1000.png
+assets/city_scene/sky/1200.png
+assets/city_scene/sky/1400.png
+assets/city_scene/sky/1500.png
+assets/city_scene/sky/1700.png
+assets/city_scene/sky/2000.png
+assets/pc306715.jpg
+assets/plastik/blue.png
+assets/plastik/green.png
+assets/plastik/red.png
+init.rb
+lib/gruff.rb
+lib/gruff/accumulator_bar.rb
+lib/gruff/area.rb
+lib/gruff/bar.rb
+lib/gruff/bar_conversion.rb
+lib/gruff/base.rb
+lib/gruff/deprecated.rb
+lib/gruff/line.rb
+lib/gruff/mini/bar.rb
+lib/gruff/mini/legend.rb
+lib/gruff/mini/pie.rb
+lib/gruff/mini/side_bar.rb
+lib/gruff/net.rb
+lib/gruff/photo_bar.rb
+lib/gruff/pie.rb
+lib/gruff/scene.rb
+lib/gruff/side_bar.rb
+lib/gruff/side_stacked_bar.rb
+lib/gruff/spider.rb
+lib/gruff/stacked_area.rb
+lib/gruff/stacked_bar.rb
+lib/gruff/stacked_mixin.rb
+rails_generators/gruff/gruff_generator.rb
+rails_generators/gruff/templates/controller.rb
+rails_generators/gruff/templates/functional_test.rb
+test/gruff_test_case.rb
+test/test_accumulator_bar.rb
+test/test_area.rb
+test/test_bar.rb
+test/test_base.rb
+test/test_legend.rb
+test/test_line.rb
+test/test_mini_bar.rb
+test/test_mini_pie.rb
+test/test_mini_side_bar.rb
+test/test_net.rb
+test/test_photo.rb
+test/test_pie.rb
+test/test_scene.rb
+test/test_side_bar.rb
+test/test_sidestacked_bar.rb
+test/test_spider.rb
+test/test_stacked_bar.rb
diff --git a/vendor/plugins/gruff/README.txt b/vendor/plugins/gruff/README.txt
new file mode 100644
index 0000000..d973eb2
--- /dev/null
+++ b/vendor/plugins/gruff/README.txt
@@ -0,0 +1,40 @@
+== Gruff Graphs
+
+A library for making beautiful graphs.
+
+== Samples
+
+http://nubyonrails.com/pages/gruff
+
+== Documentation
+
+http://gruff.rubyforge.org
+
+See the test suite in test/line_test.rb for examples.
+
+== Rails Plugin
+
+Gruff is easy to use with Rails.
+
+ gem install gruff
+ cd vendor/plugins && gem unpack gruff
+
+== WARNING
+
+This is beta-quality software. It works well according to my tests, but the API may change and other features will be added.
+
+== Source
+
+The source for this project is now kept at GitHub:
+
+http://github.com/topfunky/gruff/tree/master
+
+== CONTRIBUTE
+
+Patches appreciated, especially if they are in Git format (with metadata so your name shows up in the commit logs).
+
+Use these instructions:
+
+http://gweezlebur.com/2008/2/1/so-you-want-to-contribute-to-merb-core-part-1
+
+http://gweezlebur.com/2008/2/9/contributing-to-merb-part-2
diff --git a/vendor/plugins/gruff/Rakefile b/vendor/plugins/gruff/Rakefile
new file mode 100644
index 0000000..dafbd86
--- /dev/null
+++ b/vendor/plugins/gruff/Rakefile
@@ -0,0 +1,54 @@
+require 'rubygems'
+require 'hoe'
+$:.unshift(File.dirname(__FILE__) + "/lib")
+require 'gruff'
+
+Hoe.new('Gruff', Gruff::VERSION) do |p|
+ p.name = "gruff"
+ p.author = "Geoffrey Grosenbach"
+ p.description = "Beautiful graphs for one or multiple datasets. Can be used on websites or in documents."
+ p.email = 'boss@topfunky.com'
+ p.summary = "Beautiful graphs for one or multiple datasets."
+ p.url = "http://nubyonrails.com/pages/gruff"
+ p.clean_globs = ['test/output/*.png']
+ p.changes = p.paragraphs_of('History.txt', 0..1).join("\n\n")
+ p.remote_rdoc_dir = '' # Release to root
+end
+
+desc "Simple require on packaged files to make sure they are all there"
+task :verify => :package do
+ # An error message will be displayed if files are missing
+ if system %(ruby -e "require 'pkg/gruff-#{Gruff::VERSION}/lib/gruff'")
+ puts "\nThe library files are present"
+ end
+end
+
+task :release => :verify
+
+namespace :test do
+
+ desc "Run mini tests"
+ task :mini => :clean do
+ Dir['test/test_mini*'].each do |file|
+ system "ruby #{file}"
+ end
+
+ end
+
+end
+
+##
+# Catch unmatched tasks and run them as a unit test.
+#
+# Makes it possible to do
+#
+# rake pie
+#
+# To run the +test/test_pie+ and +test/test_mini_pie+ files.
+
+rule '' do |t|
+ # Rake::Task["clean"].invoke
+ Dir["test/test_*#{t.name}*.rb"].each do |filename|
+ system "ruby #{filename}"
+ end
+end
diff --git a/vendor/plugins/gruff/assets/bubble.png b/vendor/plugins/gruff/assets/bubble.png
new file mode 100644
index 0000000..f1a44e6
--- /dev/null
+++ b/vendor/plugins/gruff/assets/bubble.png
Binary files differ
diff --git a/vendor/plugins/gruff/assets/city_scene/background/0000.png b/vendor/plugins/gruff/assets/city_scene/background/0000.png
new file mode 100644
index 0000000..fe1d790
--- /dev/null
+++ b/vendor/plugins/gruff/assets/city_scene/background/0000.png
Binary files differ
diff --git a/vendor/plugins/gruff/assets/city_scene/background/0600.png b/vendor/plugins/gruff/assets/city_scene/background/0600.png
new file mode 100644
index 0000000..a345866
--- /dev/null
+++ b/vendor/plugins/gruff/assets/city_scene/background/0600.png
Binary files differ
diff --git a/vendor/plugins/gruff/assets/city_scene/background/2000.png b/vendor/plugins/gruff/assets/city_scene/background/2000.png
new file mode 100644
index 0000000..fe1d790
--- /dev/null
+++ b/vendor/plugins/gruff/assets/city_scene/background/2000.png
Binary files differ
diff --git a/vendor/plugins/gruff/assets/city_scene/clouds/cloudy.png b/vendor/plugins/gruff/assets/city_scene/clouds/cloudy.png
new file mode 100644
index 0000000..94dbbc2
--- /dev/null
+++ b/vendor/plugins/gruff/assets/city_scene/clouds/cloudy.png
Binary files differ
diff --git a/vendor/plugins/gruff/assets/city_scene/clouds/partly_cloudy.png b/vendor/plugins/gruff/assets/city_scene/clouds/partly_cloudy.png
new file mode 100644
index 0000000..d073e8e
--- /dev/null
+++ b/vendor/plugins/gruff/assets/city_scene/clouds/partly_cloudy.png
Binary files differ
diff --git a/vendor/plugins/gruff/assets/city_scene/clouds/stormy.png b/vendor/plugins/gruff/assets/city_scene/clouds/stormy.png
new file mode 100644
index 0000000..b542ba1
--- /dev/null
+++ b/vendor/plugins/gruff/assets/city_scene/clouds/stormy.png
Binary files differ
diff --git a/vendor/plugins/gruff/assets/city_scene/grass/default.png b/vendor/plugins/gruff/assets/city_scene/grass/default.png
new file mode 100644
index 0000000..7002fa3
--- /dev/null
+++ b/vendor/plugins/gruff/assets/city_scene/grass/default.png
Binary files differ
diff --git a/vendor/plugins/gruff/assets/city_scene/haze/true.png b/vendor/plugins/gruff/assets/city_scene/haze/true.png
new file mode 100644
index 0000000..27122bd
--- /dev/null
+++ b/vendor/plugins/gruff/assets/city_scene/haze/true.png
Binary files differ
diff --git a/vendor/plugins/gruff/assets/city_scene/number_sample/1.png b/vendor/plugins/gruff/assets/city_scene/number_sample/1.png
new file mode 100644
index 0000000..1786fa5
--- /dev/null
+++ b/vendor/plugins/gruff/assets/city_scene/number_sample/1.png
Binary files differ
diff --git a/vendor/plugins/gruff/assets/city_scene/number_sample/2.png b/vendor/plugins/gruff/assets/city_scene/number_sample/2.png
new file mode 100644
index 0000000..be500fc
--- /dev/null
+++ b/vendor/plugins/gruff/assets/city_scene/number_sample/2.png
Binary files differ
diff --git a/vendor/plugins/gruff/assets/city_scene/number_sample/default.png b/vendor/plugins/gruff/assets/city_scene/number_sample/default.png
new file mode 100644
index 0000000..7442b46
--- /dev/null
+++ b/vendor/plugins/gruff/assets/city_scene/number_sample/default.png
Binary files differ
diff --git a/vendor/plugins/gruff/assets/city_scene/sky/0000.png b/vendor/plugins/gruff/assets/city_scene/sky/0000.png
new file mode 100644
index 0000000..1786fa5
--- /dev/null
+++ b/vendor/plugins/gruff/assets/city_scene/sky/0000.png
Binary files differ
diff --git a/vendor/plugins/gruff/assets/city_scene/sky/0200.png b/vendor/plugins/gruff/assets/city_scene/sky/0200.png
new file mode 100644
index 0000000..be500fc
--- /dev/null
+++ b/vendor/plugins/gruff/assets/city_scene/sky/0200.png
Binary files differ
diff --git a/vendor/plugins/gruff/assets/city_scene/sky/0400.png b/vendor/plugins/gruff/assets/city_scene/sky/0400.png
new file mode 100644
index 0000000..7442b46
--- /dev/null
+++ b/vendor/plugins/gruff/assets/city_scene/sky/0400.png
Binary files differ
diff --git a/vendor/plugins/gruff/assets/city_scene/sky/0600.png b/vendor/plugins/gruff/assets/city_scene/sky/0600.png
new file mode 100644
index 0000000..a50ea7a
--- /dev/null
+++ b/vendor/plugins/gruff/assets/city_scene/sky/0600.png
Binary files differ
diff --git a/vendor/plugins/gruff/assets/city_scene/sky/0800.png b/vendor/plugins/gruff/assets/city_scene/sky/0800.png
new file mode 100644
index 0000000..cfd0039
--- /dev/null
+++ b/vendor/plugins/gruff/assets/city_scene/sky/0800.png
Binary files differ
diff --git a/vendor/plugins/gruff/assets/city_scene/sky/1000.png b/vendor/plugins/gruff/assets/city_scene/sky/1000.png
new file mode 100644
index 0000000..842535f
--- /dev/null
+++ b/vendor/plugins/gruff/assets/city_scene/sky/1000.png
Binary files differ
diff --git a/vendor/plugins/gruff/assets/city_scene/sky/1200.png b/vendor/plugins/gruff/assets/city_scene/sky/1200.png
new file mode 100644
index 0000000..2834156
--- /dev/null
+++ b/vendor/plugins/gruff/assets/city_scene/sky/1200.png
Binary files differ
diff --git a/vendor/plugins/gruff/assets/city_scene/sky/1400.png b/vendor/plugins/gruff/assets/city_scene/sky/1400.png
new file mode 100644
index 0000000..795c05a
--- /dev/null
+++ b/vendor/plugins/gruff/assets/city_scene/sky/1400.png
Binary files differ
diff --git a/vendor/plugins/gruff/assets/city_scene/sky/1500.png b/vendor/plugins/gruff/assets/city_scene/sky/1500.png
new file mode 100644
index 0000000..1cd0c14
--- /dev/null
+++ b/vendor/plugins/gruff/assets/city_scene/sky/1500.png
Binary files differ
diff --git a/vendor/plugins/gruff/assets/city_scene/sky/1700.png b/vendor/plugins/gruff/assets/city_scene/sky/1700.png
new file mode 100644
index 0000000..ddb9178
--- /dev/null
+++ b/vendor/plugins/gruff/assets/city_scene/sky/1700.png
Binary files differ
diff --git a/vendor/plugins/gruff/assets/city_scene/sky/2000.png b/vendor/plugins/gruff/assets/city_scene/sky/2000.png
new file mode 100644
index 0000000..767bde7
--- /dev/null
+++ b/vendor/plugins/gruff/assets/city_scene/sky/2000.png
Binary files differ
diff --git a/vendor/plugins/gruff/assets/pc306715.jpg b/vendor/plugins/gruff/assets/pc306715.jpg
new file mode 100644
index 0000000..6cbe85a
--- /dev/null
+++ b/vendor/plugins/gruff/assets/pc306715.jpg
Binary files differ
diff --git a/vendor/plugins/gruff/assets/plastik/blue.png b/vendor/plugins/gruff/assets/plastik/blue.png
new file mode 100644
index 0000000..8e7e4c9
--- /dev/null
+++ b/vendor/plugins/gruff/assets/plastik/blue.png
Binary files differ
diff --git a/vendor/plugins/gruff/assets/plastik/green.png b/vendor/plugins/gruff/assets/plastik/green.png
new file mode 100644
index 0000000..5fb1444
--- /dev/null
+++ b/vendor/plugins/gruff/assets/plastik/green.png
Binary files differ
diff --git a/vendor/plugins/gruff/assets/plastik/red.png b/vendor/plugins/gruff/assets/plastik/red.png
new file mode 100644
index 0000000..82ca767
--- /dev/null
+++ b/vendor/plugins/gruff/assets/plastik/red.png
Binary files differ
diff --git a/vendor/plugins/gruff/init.rb b/vendor/plugins/gruff/init.rb
new file mode 100644
index 0000000..6b78f4a
--- /dev/null
+++ b/vendor/plugins/gruff/init.rb
@@ -0,0 +1,2 @@
+# For Rails
+require 'gruff'
diff --git a/vendor/plugins/gruff/lib/gruff.rb b/vendor/plugins/gruff/lib/gruff.rb
new file mode 100644
index 0000000..a3e7ee4
--- /dev/null
+++ b/vendor/plugins/gruff/lib/gruff.rb
@@ -0,0 +1,27 @@
+# Extra full path added to fix loading errors on some installations.
+
+%w(
+ base
+ area
+ bar
+ line
+ pie
+ spider
+ net
+ stacked_area
+ stacked_bar
+ side_stacked_bar
+ side_bar
+ accumulator_bar
+
+ scene
+
+ mini/legend
+ mini/bar
+ mini/pie
+ mini/side_bar
+).each do |filename|
+ require File.dirname(__FILE__) + "/gruff/#{filename}"
+end
+
+# TODO bullet \ No newline at end of file
diff --git a/vendor/plugins/gruff/lib/gruff/accumulator_bar.rb b/vendor/plugins/gruff/lib/gruff/accumulator_bar.rb
new file mode 100644
index 0000000..310e193
--- /dev/null
+++ b/vendor/plugins/gruff/lib/gruff/accumulator_bar.rb
@@ -0,0 +1,27 @@
+require File.dirname(__FILE__) + '/base'
+
+##
+# A special bar graph that shows a single dataset as a set of
+# stacked bars. The bottom bar shows the running total and
+# the top bar shows the new value being added to the array.
+
+class Gruff::AccumulatorBar < Gruff::StackedBar
+
+ def draw
+ raise(Gruff::IncorrectNumberOfDatasetsException) unless @data.length == 1
+
+ accumulator_array = []
+ index = 0
+
+ increment_array = @data.first[DATA_VALUES_INDEX].inject([]) {|memo, value|
+ memo << ((index > 0) ? (value + memo.max) : value)
+ accumulator_array << memo[index] - value
+ index += 1
+ memo
+ }
+ data "Accumulator", accumulator_array
+
+ super
+ end
+
+end
diff --git a/vendor/plugins/gruff/lib/gruff/area.rb b/vendor/plugins/gruff/lib/gruff/area.rb
new file mode 100644
index 0000000..323aff1
--- /dev/null
+++ b/vendor/plugins/gruff/lib/gruff/area.rb
@@ -0,0 +1,58 @@
+
+require File.dirname(__FILE__) + '/base'
+
+class Gruff::Area < Gruff::Base
+
+ def draw
+ super
+
+ return unless @has_data
+
+ @x_increment = @graph_width / (@column_count - 1).to_f
+ @d = @d.stroke 'transparent'
+
+ @norm_data.each do |data_row|
+ poly_points = Array.new
+ prev_x = prev_y = 0.0
+ @d = @d.fill data_row[DATA_COLOR_INDEX]
+
+ data_row[1].each_with_index do |data_point, index|
+ # Use incremented x and scaled y
+ new_x = @graph_left + (@x_increment * index)
+ new_y = @graph_top + (@graph_height - data_point * @graph_height)
+
+ if prev_x > 0 and prev_y > 0 then
+ poly_points << new_x
+ poly_points << new_y
+
+ #@d = @d.polyline(prev_x, prev_y, new_x, new_y)
+ else
+ poly_points << @graph_left
+ poly_points << @graph_bottom - 1
+ poly_points << new_x
+ poly_points << new_y
+
+ #@d = @d.polyline(@graph_left, @graph_bottom, new_x, new_y)
+ end
+
+ draw_label(new_x, index)
+
+ prev_x = new_x
+ prev_y = new_y
+ end
+
+ # Add closing points, draw polygon
+ poly_points << @graph_right
+ poly_points << @graph_bottom - 1
+ poly_points << @graph_left
+ poly_points << @graph_bottom - 1
+
+ @d = @d.polyline(*poly_points)
+
+ end
+
+ @d.draw(@base_image)
+ end
+
+
+end
diff --git a/vendor/plugins/gruff/lib/gruff/bar.rb b/vendor/plugins/gruff/lib/gruff/bar.rb
new file mode 100644
index 0000000..fffdd8d
--- /dev/null
+++ b/vendor/plugins/gruff/lib/gruff/bar.rb
@@ -0,0 +1,83 @@
+require File.dirname(__FILE__) + '/base'
+require File.dirname(__FILE__) + '/bar_conversion'
+
+class Gruff::Bar < Gruff::Base
+
+ def draw
+ # Labels will be centered over the left of the bar if
+ # there are more labels than columns. This is basically the same
+ # as where it would be for a line graph.
+ @center_labels_over_point = (@labels.keys.length > @column_count ? true : false)
+
+ super
+ return unless @has_data
+
+ draw_bars
+ end
+
+protected
+
+ def draw_bars
+ # Setup spacing.
+ #
+ # Columns sit side-by-side.
+ spacing_factor = 0.9 # space between the bars
+ @bar_width = @graph_width / (@column_count * @data.length).to_f
+
+ @d = @d.stroke_opacity 0.0
+
+ # Setup the BarConversion Object
+ conversion = Gruff::BarConversion.new()
+ conversion.graph_height = @graph_height
+ conversion.graph_top = @graph_top
+
+ # Set up the right mode [1,2,3] see BarConversion for further explanation
+ if @minimum_value >= 0 then
+ # all bars go from zero to positiv
+ conversion.mode = 1
+ else
+ # all bars go from 0 to negativ
+ if @maximum_value <= 0 then
+ conversion.mode = 2
+ else
+ # bars either go from zero to negativ or to positiv
+ conversion.mode = 3
+ conversion.spread = @spread
+ conversion.minimum_value = @minimum_value
+ conversion.zero = -@minimum_value/@spread
+ end
+ end
+
+ # iterate over all normalised data
+ @norm_data.each_with_index do |data_row, row_index|
+
+ data_row[1].each_with_index do |data_point, point_index|
+ # Use incremented x and scaled y
+ # x
+ left_x = @graph_left + (@bar_width * (row_index + point_index + ((@data.length - 1) * point_index)))
+ right_x = left_x + @bar_width * spacing_factor
+ # y
+ conv = []
+ conversion.getLeftYRightYscaled( data_point, conv )
+
+ # create new bar
+ @d = @d.fill data_row[DATA_COLOR_INDEX]
+ @d = @d.rectangle(left_x, conv[0], right_x, conv[1])
+
+ # Calculate center based on bar_width and current row
+ label_center = @graph_left +
+ (@data.length * @bar_width * point_index) +
+ (@data.length * @bar_width / 2.0)
+ # Subtract half a bar width to center left if requested
+ draw_label(label_center - (@center_labels_over_point ? @bar_width / 2.0 : 0.0), point_index)
+ end
+
+ end
+
+ # Draw the last label if requested
+ draw_label(@graph_right, @column_count) if @center_labels_over_point
+
+ @d.draw(@base_image)
+ end
+
+end
diff --git a/vendor/plugins/gruff/lib/gruff/bar_conversion.rb b/vendor/plugins/gruff/lib/gruff/bar_conversion.rb
new file mode 100644
index 0000000..880daca
--- /dev/null
+++ b/vendor/plugins/gruff/lib/gruff/bar_conversion.rb
@@ -0,0 +1,46 @@
+##
+# Original Author: David Stokar
+#
+# This class perfoms the y coordinats conversion for the bar class.
+#
+# There are three cases:
+#
+# 1. Bars all go from zero in positive direction
+# 2. Bars all go from zero to negative direction
+# 3. Bars either go from zero to positive or from zero to negative
+#
+class Gruff::BarConversion
+ attr_writer :mode
+ attr_writer :zero
+ attr_writer :graph_top
+ attr_writer :graph_height
+ attr_writer :minimum_value
+ attr_writer :spread
+
+ def getLeftYRightYscaled( data_point, result )
+ case @mode
+ when 1 then # Case one
+ # minimum value >= 0 ( only positiv values )
+ result[0] = @graph_top + @graph_height*(1 - data_point) + 1
+ result[1] = @graph_top + @graph_height - 1
+ when 2 then # Case two
+ # only negativ values
+ result[0] = @graph_top + 1
+ result[1] = @graph_top + @graph_height*(1 - data_point) - 1
+ when 3 then # Case three
+ # positiv and negativ values
+ val = data_point-@minimum_value/@spread
+ if ( data_point >= @zero ) then
+ result[0] = @graph_top + @graph_height*(1 - (val-@zero)) + 1
+ result[1] = @graph_top + @graph_height*(1 - @zero) - 1
+ else
+ result[0] = @graph_top + @graph_height*(1 - (val-@zero)) + 1
+ result[1] = @graph_top + @graph_height*(1 - @zero) - 1
+ end
+ else
+ result[0] = 0.0
+ result[1] = 0.0
+ end
+ end
+
+end
diff --git a/vendor/plugins/gruff/lib/gruff/base.rb b/vendor/plugins/gruff/lib/gruff/base.rb
new file mode 100644
index 0000000..586d3cf
--- /dev/null
+++ b/vendor/plugins/gruff/lib/gruff/base.rb
@@ -0,0 +1,1073 @@
+require 'rubygems'
+require 'RMagick'
+
+require File.dirname(__FILE__) + '/deprecated'
+
+# = Gruff. Graphs.
+#
+# Author:: Geoffrey Grosenbach boss@topfunky.com
+#
+# Originally Created:: October 23, 2005
+#
+# Extra thanks to Tim Hunter for writing RMagick, and also contributions by
+# Jarkko Laine, Mike Perham, Andreas Schwarz, Alun Eyre, Guillaume Theoret,
+# David Stokar, Paul Rogers, Dave Woodward, Frank Oxener, Kevin Clark, Cies
+# Breijs, Richard Cowin, and a cast of thousands.
+#
+# See Gruff::Base#theme= for setting themes.
+module Gruff
+
+ # This is the version of Gruff you are using.
+ VERSION = '0.3.2'
+
+ class Base
+
+ include Magick
+ include Deprecated
+
+ # Draw extra lines showing where the margins and text centers are
+ DEBUG = false
+
+ # Used for navigating the array of data to plot
+ DATA_LABEL_INDEX = 0
+ DATA_VALUES_INDEX = 1
+ DATA_COLOR_INDEX = 2
+
+ # Space around text elements. Mostly used for vertical spacing
+ LEGEND_MARGIN = TITLE_MARGIN = LABEL_MARGIN = 10.0
+
+ DEFAULT_TARGET_WIDTH = 800
+
+ # Blank space above the graph
+ attr_accessor :top_margin
+
+ # Blank space below the graph
+ attr_accessor :bottom_margin
+
+ # Blank space to the right of the graph
+ attr_accessor :right_margin
+
+ # Blank space to the left of the graph
+ attr_accessor :left_margin
+
+ # A hash of names for the individual columns, where the key is the array
+ # index for the column this label represents.
+ #
+ # Not all columns need to be named.
+ #
+ # Example: 0 => 2005, 3 => 2006, 5 => 2007, 7 => 2008
+ attr_accessor :labels
+
+ # Used internally for spacing.
+ #
+ # By default, labels are centered over the point they represent.
+ attr_accessor :center_labels_over_point
+
+ # Used internally for horizontal graph types.
+ attr_accessor :has_left_labels
+
+ # A label for the bottom of the graph
+ attr_accessor :x_axis_label
+
+ # A label for the left side of the graph
+ attr_accessor :y_axis_label
+
+ # attr_accessor :x_axis_increment
+
+ # Manually set increment of the horizontal marking lines
+ attr_accessor :y_axis_increment
+
+ # Get or set the list of colors that will be used to draw the bars or lines.
+ attr_accessor :colors
+
+ # The large title of the graph displayed at the top
+ attr_accessor :title
+
+ # Font used for titles, labels, etc. Works best if you provide the full
+ # path to the TTF font file. RMagick must be built with the Freetype
+ # libraries for this to work properly.
+ #
+ # Tries to find Bitstream Vera (Vera.ttf) in the location specified by
+ # ENV['MAGICK_FONT_PATH']. Uses default RMagick font otherwise.
+ #
+ # The font= method below fulfills the role of the writer, so we only need
+ # a reader here.
+ attr_reader :font
+
+ attr_accessor :font_color
+
+ # Prevent drawing of line markers
+ attr_accessor :hide_line_markers
+
+ # Prevent drawing of the legend
+ attr_accessor :hide_legend
+
+ # Prevent drawing of the title
+ attr_accessor :hide_title
+
+ # Prevent drawing of line numbers
+ attr_accessor :hide_line_numbers
+
+ # Message shown when there is no data. Fits up to 20 characters. Defaults
+ # to "No Data."
+ attr_accessor :no_data_message
+
+ # The font size of the large title at the top of the graph
+ attr_accessor :title_font_size
+
+ # Optionally set the size of the font. Based on an 800x600px graph.
+ # Default is 20.
+ #
+ # Will be scaled down if graph is smaller than 800px wide.
+ attr_accessor :legend_font_size
+
+ # The font size of the labels around the graph
+ attr_accessor :marker_font_size
+
+ # The color of the auxiliary lines
+ attr_accessor :marker_color
+
+ # The number of horizontal lines shown for reference
+ attr_accessor :marker_count
+
+ # You can manually set a minimum value instead of having the values
+ # guessed for you.
+ #
+ # Set it after you have given all your data to the graph object.
+ attr_accessor :minimum_value
+
+ # You can manually set a maximum value, such as a percentage-based graph
+ # that always goes to 100.
+ #
+ # If you use this, you must set it after you have given all your data to
+ # the graph object.
+ attr_accessor :maximum_value
+
+ # Set to false if you don't want the data to be sorted with largest avg
+ # values at the back.
+ attr_accessor :sort
+
+ # Experimental
+ attr_accessor :additional_line_values
+
+ # Experimental
+ attr_accessor :stacked
+
+ # Optionally set the size of the colored box by each item in the legend.
+ # Default is 20.0
+ #
+ # Will be scaled down if graph is smaller than 800px wide.
+ attr_accessor :legend_box_size
+
+ # If one numerical argument is given, the graph is drawn at 4/3 ratio
+ # according to the given width (800 results in 800x600, 400 gives 400x300,
+ # etc.).
+ #
+ # Or, send a geometry string for other ratios ('800x400', '400x225').
+ #
+ # Looks for Bitstream Vera as the default font. Expects an environment var
+ # of MAGICK_FONT_PATH to be set. (Uses RMagick's default font otherwise.)
+ def initialize(target_width=DEFAULT_TARGET_WIDTH)
+ @top_margin = @bottom_margin = @left_margin = @right_margin = 20.0
+
+ if not Numeric === target_width
+ geometric_width, geometric_height = target_width.split('x')
+ @columns = geometric_width.to_f
+ @rows = geometric_height.to_f
+ else
+ @columns = target_width.to_f
+ @rows = target_width.to_f * 0.75
+ end
+
+ initialize_ivars
+
+ reset_themes
+ theme_keynote
+ end
+
+ # Set instance variables for this object.
+ #
+ # Subclasses can override this, call super, then set values separately.
+ #
+ # This makes it possible to set defaults in a subclass but still allow
+ # developers to change this values in their program.
+ def initialize_ivars
+ # Internal for calculations
+ @raw_columns = 800.0
+ @raw_rows = 800.0 * (@rows/@columns)
+ @column_count = 0
+ @marker_count = nil
+ @maximum_value = @minimum_value = nil
+ @has_data = false
+ @data = Array.new
+ @labels = Hash.new
+ @labels_seen = Hash.new
+ @sort = true
+ @title = nil
+
+ @scale = @columns / @raw_columns
+
+ vera_font_path = File.expand_path('Vera.ttf', ENV['MAGICK_FONT_PATH'])
+ @font = File.exists?(vera_font_path) ? vera_font_path : nil
+
+ @marker_font_size = 21.0
+ @legend_font_size = 20.0
+ @title_font_size = 36.0
+
+ @legend_box_size = 20.0
+
+ @no_data_message = "No Data"
+
+ @hide_line_markers = @hide_legend = @hide_title = @hide_line_numbers = false
+ @center_labels_over_point = true
+ @has_left_labels = false
+
+ @additional_line_values = []
+ @additional_line_colors = []
+ @theme_options = {}
+
+ @x_axis_label = @y_axis_label = nil
+ @y_axis_increment = nil
+ @stacked = nil
+ @norm_data = nil
+ end
+
+ # Sets the top, bottom, left and right margins to +margin+.
+ def margins=(margin)
+ @top_margin = @left_margin = @right_margin = @bottom_margin = margin
+ end
+
+ # Sets the font for graph text to the font at +font_path+.
+ def font=(font_path)
+ @font = font_path
+ @d.font = @font
+ end
+
+ # Add a color to the list of available colors for lines.
+ #
+ # Example:
+ # add_color('#c0e9d3')
+ def add_color(colorname)
+ @colors << colorname
+ end
+
+ # Replace the entire color list with a new array of colors. You need to
+ # have one more color than the number of datasets you intend to draw. Also
+ # aliased as the colors= setter method.
+ #
+ # Example:
+ # replace_colors ['#cc99cc', '#d9e043', '#34d8a2']
+ def replace_colors(color_list=[])
+ @colors = color_list
+ end
+
+ # You can set a theme manually. Assign a hash to this method before you
+ # send your data.
+ #
+ # graph.theme = {
+ # :colors => %w(orange purple green white red),
+ # :marker_color => 'blue',
+ # :background_colors => %w(black grey)
+ # }
+ #
+ # :background_image => 'squirrel.png' is also possible.
+ #
+ # (Or hopefully something better looking than that.)
+ #
+ def theme=(options)
+ reset_themes()
+
+ defaults = {
+ :colors => ['black', 'white'],
+ :additional_line_colors => [],
+ :marker_color => 'white',
+ :font_color => 'black',
+ :background_colors => nil,
+ :background_image => nil
+ }
+ @theme_options = defaults.merge options
+
+ @colors = @theme_options[:colors]
+ @marker_color = @theme_options[:marker_color]
+ @font_color = @theme_options[:font_color] || @marker_color
+ @additional_line_colors = @theme_options[:additional_line_colors]
+
+ render_background
+ end
+
+ # A color scheme similar to the popular presentation software.
+ def theme_keynote
+ # Colors
+ @blue = '#6886B4'
+ @yellow = '#FDD84E'
+ @green = '#72AE6E'
+ @red = '#D1695E'
+ @purple = '#8A6EAF'
+ @orange = '#EFAA43'
+ @white = 'white'
+ @colors = [@yellow, @blue, @green, @red, @purple, @orange, @white]
+
+ self.theme = {
+ :colors => @colors,
+ :marker_color => 'white',
+ :font_color => 'white',
+ :background_colors => ['black', '#4a465a']
+ }
+ end
+
+ # A color scheme plucked from the colors on the popular usability blog.
+ def theme_37signals
+ # Colors
+ @green = '#339933'
+ @purple = '#cc99cc'
+ @blue = '#336699'
+ @yellow = '#FFF804'
+ @red = '#ff0000'
+ @orange = '#cf5910'
+ @black = 'black'
+ @colors = [@yellow, @blue, @green, @red, @purple, @orange, @black]
+
+ self.theme = {
+ :colors => @colors,
+ :marker_color => 'black',
+ :font_color => 'black',
+ :background_colors => ['#d1edf5', 'white']
+ }
+ end
+
+ # A color scheme from the colors used on the 2005 Rails keynote
+ # presentation at RubyConf.
+ def theme_rails_keynote
+ # Colors
+ @green = '#00ff00'
+ @grey = '#333333'
+ @orange = '#ff5d00'
+ @red = '#f61100'
+ @white = 'white'
+ @light_grey = '#999999'
+ @black = 'black'
+ @colors = [@green, @grey, @orange, @red, @white, @light_grey, @black]
+
+ self.theme = {
+ :colors => @colors,
+ :marker_color => 'white',
+ :font_color => 'white',
+ :background_colors => ['#0083a3', '#0083a3']
+ }
+ end
+
+ # A color scheme similar to that used on the popular podcast site.
+ def theme_odeo
+ # Colors
+ @grey = '#202020'
+ @white = 'white'
+ @dark_pink = '#a21764'
+ @green = '#8ab438'
+ @light_grey = '#999999'
+ @dark_blue = '#3a5b87'
+ @black = 'black'
+ @colors = [@grey, @white, @dark_blue, @dark_pink, @green, @light_grey, @black]
+
+ self.theme = {
+ :colors => @colors,
+ :marker_color => 'white',
+ :font_color => 'white',
+ :background_colors => ['#ff47a4', '#ff1f81']
+ }
+ end
+
+ # A pastel theme
+ def theme_pastel
+ # Colors
+ @colors = [
+ '#a9dada', # blue
+ '#aedaa9', # green
+ '#daaea9', # peach
+ '#dadaa9', # yellow
+ '#a9a9da', # dk purple
+ '#daaeda', # purple
+ '#dadada' # grey
+ ]
+
+ self.theme = {
+ :colors => @colors,
+ :marker_color => '#aea9a9', # Grey
+ :font_color => 'black',
+ :background_colors => 'white'
+ }
+ end
+
+ # A greyscale theme
+ def theme_greyscale
+ # Colors
+ @colors = [
+ '#282828', #
+ '#383838', #
+ '#686868', #
+ '#989898', #
+ '#c8c8c8', #
+ '#e8e8e8', #
+ ]
+
+ self.theme = {
+ :colors => @colors,
+ :marker_color => '#aea9a9', # Grey
+ :font_color => 'black',
+ :background_colors => 'white'
+ }
+ end
+
+ # Parameters are an array where the first element is the name of the dataset
+ # and the value is an array of values to plot.
+ #
+ # Can be called multiple times with different datasets for a multi-valued
+ # graph.
+ #
+ # If the color argument is nil, the next color from the default theme will
+ # be used.
+ #
+ # NOTE: If you want to use a preset theme, you must set it before calling
+ # data().
+ #
+ # Example:
+ # data("Bart S.", [95, 45, 78, 89, 88, 76], '#ffcc00')
+ def data(name, data_points=[], color=nil)
+ data_points = Array(data_points) # make sure it's an array
+ @data << [name, data_points, (color || increment_color)]
+ # Set column count if this is larger than previous counts
+ @column_count = (data_points.length > @column_count) ? data_points.length : @column_count
+
+ # Pre-normalize
+ data_points.each_with_index do |data_point, index|
+ next if data_point.nil?
+
+ # Setup max/min so spread starts at the low end of the data points
+ if @maximum_value.nil? && @minimum_value.nil?
+ @maximum_value = @minimum_value = data_point
+ end
+
+ # TODO Doesn't work with stacked bar graphs
+ # Original: @maximum_value = larger_than_max?(data_point, index) ? max(data_point, index) : @maximum_value
+ @maximum_value = larger_than_max?(data_point) ? data_point : @maximum_value
+ @has_data = true if @maximum_value > 0
+
+ @minimum_value = less_than_min?(data_point) ? data_point : @minimum_value
+ @has_data = true if @minimum_value < 0
+ end
+ end
+
+ # Writes the graph to a file. Defaults to 'graph.png'
+ #
+ # Example:
+ # write('graphs/my_pretty_graph.png')
+ def write(filename="graph.png")
+ draw()
+ @base_image.write(filename)
+ end
+
+ # Return the graph as a rendered binary blob.
+ def to_blob(fileformat='PNG')
+ draw()
+ return @base_image.to_blob do
+ self.format = fileformat
+ end
+ end
+
+
+
+protected
+
+ # Overridden by subclasses to do the actual plotting of the graph.
+ #
+ # Subclasses should start by calling super() for this method.
+ def draw
+ make_stacked if @stacked
+ setup_drawing
+
+ debug {
+ # Outer margin
+ @d.rectangle( @left_margin, @top_margin,
+ @raw_columns - @right_margin, @raw_rows - @bottom_margin)
+ # Graph area box
+ @d.rectangle( @graph_left, @graph_top, @graph_right, @graph_bottom)
+ }
+ end
+
+ # Calculates size of drawable area and draws the decorations.
+ #
+ # * line markers
+ # * legend
+ # * title
+ def setup_drawing
+ # Maybe should be done in one of the following functions for more granularity.
+ unless @has_data
+ draw_no_data()
+ return
+ end
+
+ normalize()
+ setup_graph_measurements()
+ sort_norm_data() if @sort # Sort norm_data with avg largest values set first (for display)
+
+ draw_legend()
+ draw_line_markers()
+ draw_axis_labels()
+ draw_title
+ end
+
+ # Make copy of data with values scaled between 0-100
+ def normalize(force=false)
+ if @norm_data.nil? || force
+ @norm_data = []
+ return unless @has_data
+
+ calculate_spread
+
+ @data.each do |data_row|
+ norm_data_points = []
+ data_row[DATA_VALUES_INDEX].each do |data_point|
+ if data_point.nil?
+ norm_data_points << nil
+ else
+ norm_data_points << ((data_point.to_f - @minimum_value.to_f ) / @spread)
+ end
+ end
+ @norm_data << [data_row[DATA_LABEL_INDEX], norm_data_points, data_row[DATA_COLOR_INDEX]]
+ end
+ end
+ end
+
+ def calculate_spread # :nodoc:
+ @spread = @maximum_value.to_f - @minimum_value.to_f
+ @spread = @spread > 0 ? @spread : 1
+ end
+
+ # Calculates size of drawable area, general font dimensions, etc.
+ def setup_graph_measurements
+ @marker_caps_height = @hide_line_markers ? 0 :
+ calculate_caps_height(@marker_font_size)
+ @title_caps_height = @hide_title ? 0 :
+ calculate_caps_height(@title_font_size)
+ @legend_caps_height = @hide_legend ? 0 :
+ calculate_caps_height(@legend_font_size)
+
+ if @hide_line_markers
+ (@graph_left,
+ @graph_right_margin,
+ @graph_bottom_margin) = [@left_margin, @right_margin, @bottom_margin]
+ else
+ longest_left_label_width = 0
+ if @has_left_labels
+ longest_left_label_width = calculate_width(@marker_font_size,
+ labels.values.inject('') { |value, memo| (value.to_s.length > memo.to_s.length) ? value : memo }) * 1.25
+ else
+ longest_left_label_width = calculate_width(@marker_font_size,
+ label(@maximum_value.to_f))
+ end
+
+ # Shift graph if left line numbers are hidden
+ line_number_width = @hide_line_numbers && !@has_left_labels ?
+ 0.0 :
+ (longest_left_label_width + LABEL_MARGIN * 2)
+
+ @graph_left = @left_margin +
+ line_number_width +
+ (@y_axis_label.nil? ? 0.0 : @marker_caps_height + LABEL_MARGIN * 2)
+ # Make space for half the width of the rightmost column label.
+ # Might be greater than the number of columns if between-style bar markers are used.
+ last_label = @labels.keys.sort.last.to_i
+ extra_room_for_long_label = (last_label >= (@column_count-1) && @center_labels_over_point) ?
+ calculate_width(@marker_font_size, @labels[last_label])/2.0 :
+ 0
+ @graph_right_margin = @right_margin + extra_room_for_long_label
+
+ @graph_bottom_margin = @bottom_margin +
+ @marker_caps_height + LABEL_MARGIN
+ end
+
+ @graph_right = @raw_columns - @graph_right_margin
+ @graph_width = @raw_columns - @graph_left - @graph_right_margin
+
+ # When @hide title, leave a TITLE_MARGIN space for aesthetics.
+ # Same with @hide_legend
+ @graph_top = @top_margin +
+ (@hide_title ? TITLE_MARGIN : @title_caps_height + TITLE_MARGIN * 2) +
+ (@hide_legend ? LEGEND_MARGIN : @legend_caps_height + LEGEND_MARGIN * 2)
+
+ x_axis_label_height = @x_axis_label.nil? ? 0.0 :
+ @marker_caps_height + LABEL_MARGIN
+ @graph_bottom = @raw_rows - @graph_bottom_margin - x_axis_label_height
+ @graph_height = @graph_bottom - @graph_top
+ end
+
+ # Draw the optional labels for the x axis and y axis.
+ def draw_axis_labels
+ unless @x_axis_label.nil?
+ # X Axis
+ # Centered vertically and horizontally by setting the
+ # height to 1.0 and the width to the width of the graph.
+ x_axis_label_y_coordinate = @graph_bottom + LABEL_MARGIN * 2 + @marker_caps_height
+
+ # TODO Center between graph area
+ @d.fill = @font_color
+ @d.font = @font if @font
+ @d.stroke('transparent')
+ @d.pointsize = scale_fontsize(@marker_font_size)
+ @d.gravity = NorthGravity
+ @d = @d.annotate_scaled( @base_image,
+ @raw_columns, 1.0,
+ 0.0, x_axis_label_y_coordinate,
+ @x_axis_label, @scale)
+ debug { @d.line 0.0, x_axis_label_y_coordinate, @raw_columns, x_axis_label_y_coordinate }
+ end
+
+ unless @y_axis_label.nil?
+ # Y Axis, rotated vertically
+ @d.rotation = 90.0
+ @d.gravity = CenterGravity
+ @d = @d.annotate_scaled( @base_image,
+ 1.0, @raw_rows,
+ @left_margin + @marker_caps_height / 2.0, 0.0,
+ @y_axis_label, @scale)
+ @d.rotation = -90.0
+ end
+ end
+
+ # Draws horizontal background lines and labels
+ def draw_line_markers
+ return if @hide_line_markers
+
+ @d = @d.stroke_antialias false
+
+ if @y_axis_increment.nil?
+ # Try to use a number of horizontal lines that will come out even.
+ #
+ # TODO Do the same for larger numbers...100, 75, 50, 25
+ if @marker_count.nil?
+ (3..7).each do |lines|
+ if @spread % lines == 0.0
+ @marker_count = lines
+ break
+ end
+ end
+ @marker_count ||= 4
+ end
+ @increment = (@spread > 0) ? significant(@spread / @marker_count) : 1
+ else
+ # TODO Make this work for negative values
+ @maximum_value = [@maximum_value.ceil, @y_axis_increment].max
+ @minimum_value = @minimum_value.floor
+ calculate_spread
+ normalize(true)
+
+ @marker_count = (@spread / @y_axis_increment).to_i
+ @increment = @y_axis_increment
+ end
+ @increment_scaled = @graph_height.to_f / (@spread / @increment)
+
+ # Draw horizontal line markers and annotate with numbers
+ (0..@marker_count).each do |index|
+ y = @graph_top + @graph_height - index.to_f * @increment_scaled
+
+ @d = @d.stroke(@marker_color)
+ @d = @d.stroke_width 1
+ @d = @d.line(@graph_left, y, @graph_right, y)
+
+ marker_label = index * @increment + @minimum_value.to_f
+
+ unless @hide_line_numbers
+ @d.fill = @font_color
+ @d.font = @font if @font
+ @d.stroke('transparent')
+ @d.pointsize = scale_fontsize(@marker_font_size)
+ @d.gravity = EastGravity
+
+ # Vertically center with 1.0 for the height
+ @d = @d.annotate_scaled( @base_image,
+ @graph_left - LABEL_MARGIN, 1.0,
+ 0.0, y,
+ label(marker_label), @scale)
+ end
+ end
+
+ # # Submitted by a contibutor...the utility escapes me
+ # i = 0
+ # @additional_line_values.each do |value|
+ # @increment_scaled = @graph_height.to_f / (@maximum_value.to_f / value)
+ #
+ # y = @graph_top + @graph_height - @increment_scaled
+ #
+ # @d = @d.stroke(@additional_line_colors[i])
+ # @d = @d.line(@graph_left, y, @graph_right, y)
+ #
+ #
+ # @d.fill = @additional_line_colors[i]
+ # @d.font = @font if @font
+ # @d.stroke('transparent')
+ # @d.pointsize = scale_fontsize(@marker_font_size)
+ # @d.gravity = EastGravity
+ # @d = @d.annotate_scaled( @base_image,
+ # 100, 20,
+ # -10, y - (@marker_font_size/2.0),
+ # "", @scale)
+ # i += 1
+ # end
+
+ @d = @d.stroke_antialias true
+ end
+
+ # Draws a legend with the names of the datasets matched to the colors used
+ # to draw them.
+ def draw_legend
+ return if @hide_legend
+
+ @legend_labels = @data.collect {|item| item[DATA_LABEL_INDEX] }
+
+ legend_square_width = @legend_box_size # small square with color of this item
+
+ # May fix legend drawing problem at small sizes
+ @d.font = @font if @font
+ @d.pointsize = @legend_font_size
+
+ metrics = @d.get_type_metrics(@base_image, @legend_labels.join(''))
+ legend_text_width = metrics.width
+ legend_width = legend_text_width +
+ (@legend_labels.length * legend_square_width * 2.7)
+ legend_left = (@raw_columns - legend_width) / 2
+ legend_increment = legend_width / @legend_labels.length.to_f
+
+ current_x_offset = legend_left
+ current_y_offset = @hide_title ?
+ @top_margin + LEGEND_MARGIN :
+ @top_margin +
+ TITLE_MARGIN + @title_caps_height +
+ LEGEND_MARGIN
+
+ debug { @d.line 0.0, current_y_offset, @raw_columns, current_y_offset }
+
+ @legend_labels.each_with_index do |legend_label, index|
+
+ # Draw label
+ @d.fill = @font_color
+ @d.font = @font if @font
+ @d.pointsize = scale_fontsize(@legend_font_size)
+ @d.stroke('transparent')
+ @d.font_weight = NormalWeight
+ @d.gravity = WestGravity
+ @d = @d.annotate_scaled( @base_image,
+ @raw_columns, 1.0,
+ current_x_offset + (legend_square_width * 1.7), current_y_offset,
+ legend_label.to_s, @scale)
+
+ # Now draw box with color of this dataset
+ @d = @d.stroke('transparent')
+ @d = @d.fill @data[index][DATA_COLOR_INDEX]
+ @d = @d.rectangle(current_x_offset,
+ current_y_offset - legend_square_width / 2.0,
+ current_x_offset + legend_square_width,
+ current_y_offset + legend_square_width / 2.0)
+
+ @d.pointsize = @legend_font_size
+ metrics = @d.get_type_metrics(@base_image, legend_label.to_s)
+ current_string_offset = metrics.width + (legend_square_width * 2.7)
+ current_x_offset += current_string_offset
+ end
+ @color_index = 0
+ end
+
+ # Draws a title on the graph.
+ def draw_title
+ return if (@hide_title || @title.nil?)
+
+ @d.fill = @font_color
+ @d.font = @font if @font
+ @d.stroke('transparent')
+ @d.pointsize = scale_fontsize(@title_font_size)
+ @d.font_weight = BoldWeight
+ @d.gravity = NorthGravity
+ @d = @d.annotate_scaled( @base_image,
+ @raw_columns, 1.0,
+ 0, @top_margin,
+ @title, @scale)
+ end
+
+ # Draws column labels below graph, centered over x_offset
+ #--
+ # TODO Allow WestGravity as an option
+ def draw_label(x_offset, index)
+ return if @hide_line_markers
+
+ if !@labels[index].nil? && @labels_seen[index].nil?
+ y_offset = @graph_bottom + LABEL_MARGIN
+
+ @d.fill = @font_color
+ @d.font = @font if @font
+ @d.stroke('transparent')
+ @d.font_weight = NormalWeight
+ @d.pointsize = scale_fontsize(@marker_font_size)
+ @d.gravity = NorthGravity
+ @d = @d.annotate_scaled(@base_image,
+ 1.0, 1.0,
+ x_offset, y_offset,
+ @labels[index], @scale)
+ @labels_seen[index] = 1
+ debug { @d.line 0.0, y_offset, @raw_columns, y_offset }
+ end
+ end
+
+ # Shows an error message because you have no data.
+ def draw_no_data
+ @d.fill = @font_color
+ @d.font = @font if @font
+ @d.stroke('transparent')
+ @d.font_weight = NormalWeight
+ @d.pointsize = scale_fontsize(80)
+ @d.gravity = CenterGravity
+ @d = @d.annotate_scaled( @base_image,
+ @raw_columns, @raw_rows/2.0,
+ 0, 10,
+ @no_data_message, @scale)
+ end
+
+ # Finds the best background to render based on the provided theme options.
+ #
+ # Creates a @base_image to draw on.
+ def render_background
+ case @theme_options[:background_colors]
+ when Array
+ @base_image = render_gradiated_background(*@theme_options[:background_colors])
+ when String
+ @base_image = render_solid_background(@theme_options[:background_colors])
+ else
+ @base_image = render_image_background(*@theme_options[:background_image])
+ end
+ end
+
+ # Make a new image at the current size with a solid +color+.
+ def render_solid_background(color)
+ Image.new(@columns, @rows) {
+ self.background_color = color
+ }
+ end
+
+ # Use with a theme definition method to draw a gradiated background.
+ def render_gradiated_background(top_color, bottom_color)
+ Image.new(@columns, @rows,
+ GradientFill.new(0, 0, 100, 0, top_color, bottom_color))
+ end
+
+ # Use with a theme to use an image (800x600 original) background.
+ def render_image_background(image_path)
+ image = Image.read(image_path)
+ if @scale != 1.0
+ image[0].resize!(@scale) # TODO Resize with new scale (crop if necessary for wide graph)
+ end
+ image[0]
+ end
+
+ # Use with a theme to make a transparent background
+ def render_transparent_background
+ Image.new(@columns, @rows) do
+ self.background_color = 'transparent'
+ end
+ end
+
+ # Resets everything to defaults (except data).
+ def reset_themes
+ @color_index = 0
+ @labels_seen = {}
+ @theme_options = {}
+
+ @d = Draw.new
+ # Scale down from 800x600 used to calculate drawing.
+ @d = @d.scale(@scale, @scale)
+ end
+
+ def scale(value) # :nodoc:
+ value * @scale
+ end
+
+ # Return a comparable fontsize for the current graph.
+ def scale_fontsize(value)
+ new_fontsize = value * @scale
+ # return new_fontsize < 10.0 ? 10.0 : new_fontsize
+ return new_fontsize
+ end
+
+ def clip_value_if_greater_than(value, max_value) # :nodoc:
+ (value > max_value) ? max_value : value
+ end
+
+ # Overridden by subclasses such as stacked bar.
+ def larger_than_max?(data_point, index=0) # :nodoc:
+ data_point > @maximum_value
+ end
+
+ def less_than_min?(data_point, index=0) # :nodoc:
+ data_point < @minimum_value
+ end
+
+ # Overridden by subclasses that need it.
+ def max(data_point, index) # :nodoc:
+ data_point
+ end
+
+ # Overridden by subclasses that need it.
+ def min(data_point, index) # :nodoc:
+ data_point
+ end
+
+ def significant(inc) # :nodoc:
+ return 1.0 if inc == 0 # Keep from going into infinite loop
+ factor = 1.0
+ while (inc < 10)
+ inc *= 10
+ factor /= 10
+ end
+
+ while (inc > 100)
+ inc /= 10
+ factor *= 10
+ end
+
+ res = inc.floor * factor
+ if (res.to_i.to_f == res)
+ res.to_i
+ else
+ res
+ end
+ end
+
+ # Sort with largest overall summed value at front of array so it shows up
+ # correctly in the drawn graph.
+ def sort_norm_data
+ @norm_data.sort! { |a,b| sums(b[1]) <=> sums(a[1]) }
+ end
+
+ def sums(data_set) # :nodoc:
+ total_sum = 0
+ data_set.collect {|num| total_sum += num.to_f }
+ total_sum
+ end
+
+ # Used by StackedBar and child classes.
+ #
+ # May need to be moved to the StackedBar class.
+ def get_maximum_by_stack
+ # Get sum of each stack
+ max_hash = {}
+ @data.each do |data_set|
+ data_set[DATA_VALUES_INDEX].each_with_index do |data_point, i|
+ max_hash[i] = 0.0 unless max_hash[i]
+ max_hash[i] += data_point.to_f
+ end
+ end
+
+ # @maximum_value = 0
+ max_hash.keys.each do |key|
+ @maximum_value = max_hash[key] if max_hash[key] > @maximum_value
+ end
+ @minimum_value = 0
+ end
+
+ def make_stacked # :nodoc:
+ stacked_values = Array.new(@column_count, 0)
+ @data.each do |value_set|
+ value_set[1].each_with_index do |value, index|
+ stacked_values[index] += value
+ end
+ value_set[1] = stacked_values.dup
+ end
+ end
+
+private
+
+ # Takes a block and draws it if DEBUG is true.
+ #
+ # Example:
+ # debug { @d.rectangle x1, y1, x2, y2 }
+ def debug
+ if DEBUG
+ @d = @d.fill 'transparent'
+ @d = @d.stroke 'turquoise'
+ @d = yield
+ end
+ end
+
+ # Uses the next color in your color list.
+ def increment_color
+ if @color_index == 0
+ @color_index += 1
+ return @colors[0]
+ else
+ if @color_index < @colors.length
+ @color_index += 1
+ return @colors[@color_index - 1]
+ else
+ # Start over
+ @color_index = 0
+ return @colors[-1]
+ end
+ end
+ end
+
+ # Return a formatted string representing a number value that should be
+ # printed as a label.
+ def label(value)
+ if (@spread.to_f % @marker_count.to_f == 0) || !@y_axis_increment.nil?
+ return value.to_i.to_s
+ end
+
+ if @spread > 10.0
+ sprintf("%0i", value)
+ elsif @spread >= 3.0
+ sprintf("%0.2f", value)
+ else
+ value.to_s
+ end
+ end
+
+ # Returns the height of the capital letter 'X' for the current font and
+ # size.
+ #
+ # Not scaled since it deals with dimensions that the regular scaling will
+ # handle.
+ def calculate_caps_height(font_size)
+ @d.pointsize = font_size
+ @d.get_type_metrics(@base_image, 'X').height
+ end
+
+ # Returns the width of a string at this pointsize.
+ #
+ # Not scaled since it deals with dimensions that the regular
+ # scaling will handle.
+ def calculate_width(font_size, text)
+ @d.pointsize = font_size
+ @d.get_type_metrics(@base_image, text.to_s).width
+ end
+
+ end # Gruff::Base
+
+ class IncorrectNumberOfDatasetsException < StandardError; end
+
+end # Gruff
+
+module Magick
+
+ class Draw
+
+ # Additional method to scale annotation text since Draw.scale doesn't.
+ def annotate_scaled(img, width, height, x, y, text, scale)
+ scaled_width = (width * scale) >= 1 ? (width * scale) : 1
+ scaled_height = (height * scale) >= 1 ? (height * scale) : 1
+
+ self.annotate( img,
+ scaled_width, scaled_height,
+ x * scale, y * scale,
+ text)
+ end
+
+ end
+
+end # Magick
+
diff --git a/vendor/plugins/gruff/lib/gruff/bullet.rb b/vendor/plugins/gruff/lib/gruff/bullet.rb
new file mode 100644
index 0000000..21fe1f3
--- /dev/null
+++ b/vendor/plugins/gruff/lib/gruff/bullet.rb
@@ -0,0 +1,109 @@
+require File.dirname(__FILE__) + '/base'
+
+class Gruff::Bullet < Gruff::Base
+
+ def initialize(target_width="400x40")
+ if not Numeric === target_width
+ geometric_width, geometric_height = target_width.split('x')
+ @columns = geometric_width.to_f
+ @rows = geometric_height.to_f
+ else
+ @columns = target_width.to_f
+ @rows = target_width.to_f / 5.0
+ end
+
+ initialize_ivars
+
+ reset_themes
+ theme_greyscale
+ @title_font_size = 20
+ end
+
+ def data(value, maximum_value, options={})
+ @value = value.to_f
+ @maximum_value = maximum_value.to_f
+ @options = options
+ @options.map { |k, v| @options[k] = v.to_f if v === Numeric }
+ end
+
+ # def setup_drawing
+ # # Maybe should be done in one of the following functions for more granularity.
+ # unless @has_data
+ # draw_no_data()
+ # return
+ # end
+ #
+ # normalize()
+ # setup_graph_measurements()
+ # sort_norm_data() if @sort # Sort norm_data with avg largest values set first (for display)
+ #
+ # draw_legend()
+ # draw_line_markers()
+ # draw_axis_labels()
+ # draw_title
+ # end
+
+ def draw
+ # TODO Left label
+ # TODO Bottom labels and markers
+ # @graph_bottom
+ # Calculations are off 800x???
+
+ @colors.reverse!
+
+ draw_title
+
+ @margin = 30.0
+ @thickness = @raw_rows / 6.0
+ @right_margin = @margin
+ @graph_left = @title_width * 1.3 rescue @margin # HACK Need to calculate real width
+ @graph_width = @raw_columns - @graph_left - @right_margin
+ @graph_height = @thickness * 3.0
+
+ # Background
+ @d = @d.fill @colors[0]
+ @d = @d.rectangle(@graph_left, 0, @graph_left + @graph_width, @graph_height)
+
+ [:high, :low].each_with_index do |indicator, index|
+ next unless @options.has_key?(indicator)
+ @d = @d.fill @colors[index + 1]
+ indicator_width_x = @graph_left + @graph_width * (@options[indicator] / @maximum_value)
+ @d = @d.rectangle(@graph_left, 0, indicator_width_x, @graph_height)
+ end
+
+ if @options.has_key?(:target)
+ @d = @d.fill @font_color
+ target_x = @graph_left + @graph_width * (@options[:target] / @maximum_value)
+ half_thickness = @thickness / 2.0
+ @d = @d.rectangle(target_x, half_thickness, target_x + half_thickness, @thickness * 2 + half_thickness)
+ end
+
+ # Value
+ @d = @d.fill @font_color
+ @d = @d.rectangle(@graph_left, @thickness, @graph_left + @graph_width * (@value / @maximum_value), @thickness * 2)
+
+ @d.draw(@base_image)
+ end
+
+ def draw_title
+ return unless @title
+
+ @font_height = calculate_caps_height(scale_fontsize(@title_font_size))
+ @title_width = calculate_width(@title_font_size, @title)
+
+ @d.fill = @font_color
+ @d.font = @font if @font
+ @d.stroke('transparent')
+ @d.font_weight = NormalWeight
+ @d.pointsize = scale_fontsize(@title_font_size)
+ @d.gravity = NorthWestGravity
+ @d = @d.annotate_scaled(*[
+ @base_image,
+ 1.0, 1.0,
+ @font_height/2, @font_height/2,
+ @title,
+ @scale
+ ])
+ end
+
+end
diff --git a/vendor/plugins/gruff/lib/gruff/deprecated.rb b/vendor/plugins/gruff/lib/gruff/deprecated.rb
new file mode 100644
index 0000000..be254b5
--- /dev/null
+++ b/vendor/plugins/gruff/lib/gruff/deprecated.rb
@@ -0,0 +1,39 @@
+
+##
+# A mixin for methods that need to be deleted or have been
+# replaced by cleaner code.
+
+module Gruff
+ module Deprecated
+
+ def scale_measurements
+ setup_graph_measurements
+ end
+
+ def total_height
+ @rows + 10
+ end
+
+ def graph_top
+ @graph_top * @scale
+ end
+
+ def graph_height
+ @graph_height * @scale
+ end
+
+ def graph_left
+ @graph_left * @scale
+ end
+
+ def graph_width
+ @graph_width * @scale
+ end
+
+ # TODO Should be calculate_graph_height
+ # def setup_graph_height
+ # @graph_height = @graph_bottom - @graph_top
+ # end
+
+ end
+end
diff --git a/vendor/plugins/gruff/lib/gruff/line.rb b/vendor/plugins/gruff/lib/gruff/line.rb
new file mode 100644
index 0000000..c238184
--- /dev/null
+++ b/vendor/plugins/gruff/lib/gruff/line.rb
@@ -0,0 +1,105 @@
+
+require File.dirname(__FILE__) + '/base'
+
+##
+# Here's how to make a Line graph:
+#
+# g = Gruff::Line.new
+# g.title = "A Line Graph"
+# g.data 'Fries', [20, 23, 19, 8]
+# g.data 'Hamburgers', [50, 19, 99, 29]
+# g.write("test/output/line.png")
+#
+# There are also other options described below, such as #baseline_value, #baseline_color, #hide_dots, and #hide_lines.
+
+class Gruff::Line < Gruff::Base
+
+ # Draw a dashed line at the given value
+ attr_accessor :baseline_value
+
+ # Color of the baseline
+ attr_accessor :baseline_color
+
+ # Hide parts of the graph to fit more datapoints, or for a different appearance.
+ attr_accessor :hide_dots, :hide_lines
+
+ # Call with target pixel width of graph (800, 400, 300), and/or 'false' to omit lines (points only).
+ #
+ # g = Gruff::Line.new(400) # 400px wide with lines
+ #
+ # g = Gruff::Line.new(400, false) # 400px wide, no lines (for backwards compatibility)
+ #
+ # g = Gruff::Line.new(false) # Defaults to 800px wide, no lines (for backwards compatibility)
+ #
+ # The preferred way is to call hide_dots or hide_lines instead.
+ def initialize(*args)
+ raise ArgumentError, "Wrong number of arguments" if args.length > 2
+ if args.empty? or ((not Numeric === args.first) && (not String === args.first)) then
+ super()
+ else
+ super args.shift
+ end
+
+ @hide_dots = @hide_lines = false
+ @baseline_color = 'red'
+ @baseline_value = nil
+ end
+
+ def draw
+ super
+
+ return unless @has_data
+
+ # Check to see if more than one datapoint was given. NaN can result otherwise.
+ @x_increment = (@column_count > 1) ? (@graph_width / (@column_count - 1).to_f) : @graph_width
+
+ if (defined?(@norm_baseline)) then
+ level = @graph_top + (@graph_height - @norm_baseline * @graph_height)
+ @d = @d.push
+ @d.stroke_color @baseline_color
+ @d.fill_opacity 0.0
+ @d.stroke_dasharray(10, 20)
+ @d.stroke_width 5
+ @d.line(@graph_left, level, @graph_left + @graph_width, level)
+ @d = @d.pop
+ end
+
+ @norm_data.each do |data_row|
+ prev_x = prev_y = nil
+
+ data_row[1].each_with_index do |data_point, index|
+ new_x = @graph_left + (@x_increment * index)
+ next if data_point.nil?
+
+ draw_label(new_x, index)
+
+ new_y = @graph_top + (@graph_height - data_point * @graph_height)
+
+ # Reset each time to avoid thin-line errors
+ @d = @d.stroke data_row[DATA_COLOR_INDEX]
+ @d = @d.fill data_row[DATA_COLOR_INDEX]
+ @d = @d.stroke_opacity 1.0
+ @d = @d.stroke_width clip_value_if_greater_than(@columns / (@norm_data.first[1].size * 4), 5.0)
+
+ if !@hide_lines and !prev_x.nil? and !prev_y.nil? then
+ @d = @d.line(prev_x, prev_y, new_x, new_y)
+ end
+ circle_radius = clip_value_if_greater_than(@columns / (@norm_data.first[1].size * 2.5), 5.0)
+ @d = @d.circle(new_x, new_y, new_x - circle_radius, new_y) unless @hide_dots
+
+ prev_x = new_x
+ prev_y = new_y
+ end
+
+ end
+
+ @d.draw(@base_image)
+ end
+
+ def normalize
+ @maximum_value = [@maximum_value.to_f, @baseline_value.to_f].max
+ super
+ @norm_baseline = (@baseline_value.to_f / @maximum_value.to_f) if @baseline_value
+ end
+
+end
diff --git a/vendor/plugins/gruff/lib/gruff/mini/bar.rb b/vendor/plugins/gruff/lib/gruff/mini/bar.rb
new file mode 100644
index 0000000..6410d68
--- /dev/null
+++ b/vendor/plugins/gruff/lib/gruff/mini/bar.rb
@@ -0,0 +1,32 @@
+##
+#
+# Makes a small bar graph suitable for display at 200px or even smaller.
+#
+module Gruff
+ module Mini
+
+ class Bar < Gruff::Bar
+
+ include Gruff::Mini::Legend
+
+ def draw
+ @hide_legend = true
+ @hide_title = true
+ @hide_line_numbers = true
+
+ @marker_font_size = 50.0
+ @minimum_value = 0.0
+ @legend_font_size = 60.0
+
+ expand_canvas_for_vertical_legend
+
+ super
+
+ draw_vertical_legend
+ @d.draw(@base_image)
+ end
+
+ end
+
+ end
+end
diff --git a/vendor/plugins/gruff/lib/gruff/mini/legend.rb b/vendor/plugins/gruff/lib/gruff/mini/legend.rb
new file mode 100644
index 0000000..83f200e
--- /dev/null
+++ b/vendor/plugins/gruff/lib/gruff/mini/legend.rb
@@ -0,0 +1,77 @@
+module Gruff
+ module Mini
+ module Legend
+
+ ##
+ # The canvas needs to be bigger so we can put the legend beneath it.
+
+ def expand_canvas_for_vertical_legend
+ @original_rows = @raw_rows
+ @rows += @data.length * calculate_caps_height(scale_fontsize(@legend_font_size)) * 1.7
+ render_background
+ end
+
+ ##
+ # Draw the legend beneath the existing graph.
+
+ def draw_vertical_legend
+
+ @legend_labels = @data.collect {|item| item[Gruff::Base::DATA_LABEL_INDEX] }
+
+ legend_square_width = 40.0 # small square with color of this item
+ legend_square_margin = 10.0
+ @legend_left_margin = 100.0
+ legend_top_margin = 40.0
+
+ # May fix legend drawing problem at small sizes
+ @d.font = @font if @font
+ @d.pointsize = @legend_font_size
+
+ current_x_offset = @legend_left_margin
+ current_y_offset = @original_rows + legend_top_margin
+
+ debug { @d.line 0.0, current_y_offset, @raw_columns, current_y_offset }
+
+ @legend_labels.each_with_index do |legend_label, index|
+
+ # Draw label
+ @d.fill = @font_color
+ @d.font = @font if @font
+ @d.pointsize = scale_fontsize(@legend_font_size)
+ @d.stroke = 'transparent'
+ @d.font_weight = Magick::NormalWeight
+ @d.gravity = Magick::WestGravity
+ @d = @d.annotate_scaled( @base_image,
+ @raw_columns, 1.0,
+ current_x_offset + (legend_square_width * 1.7), current_y_offset,
+ truncate_legend_label(legend_label), @scale)
+
+ # Now draw box with color of this dataset
+ @d = @d.stroke 'transparent'
+ @d = @d.fill @data[index][Gruff::Base::DATA_COLOR_INDEX]
+ @d = @d.rectangle(current_x_offset,
+ current_y_offset - legend_square_width / 2.0,
+ current_x_offset + legend_square_width,
+ current_y_offset + legend_square_width / 2.0)
+
+ current_y_offset += calculate_caps_height(@legend_font_size) * 1.7
+ end
+ @color_index = 0
+ end
+
+ ##
+ # Shorten long labels so they will fit on the canvas.
+ #
+ # Department of Hu...
+
+ def truncate_legend_label(label)
+ truncated_label = label.to_s
+ while calculate_width(scale_fontsize(@legend_font_size), truncated_label) > (@columns - @legend_left_margin - @right_margin) && (truncated_label.length > 1)
+ truncated_label = truncated_label[0..truncated_label.length-2]
+ end
+ truncated_label + (truncated_label.length < label.to_s.length ? "…" : '')
+ end
+
+ end
+ end
+end
diff --git a/vendor/plugins/gruff/lib/gruff/mini/pie.rb b/vendor/plugins/gruff/lib/gruff/mini/pie.rb
new file mode 100644
index 0000000..7822ba5
--- /dev/null
+++ b/vendor/plugins/gruff/lib/gruff/mini/pie.rb
@@ -0,0 +1,36 @@
+##
+#
+# Makes a small pie graph suitable for display at 200px or even smaller.
+#
+module Gruff
+ module Mini
+
+ class Pie < Gruff::Pie
+
+ include Gruff::Mini::Legend
+
+ def initialize_ivars
+ super
+
+ @hide_legend = true
+ @hide_title = true
+ @hide_line_numbers = true
+
+ @marker_font_size = 60.0
+ @legend_font_size = 60.0
+ end
+
+ def draw
+ expand_canvas_for_vertical_legend
+
+ super
+
+ draw_vertical_legend
+
+ @d.draw(@base_image)
+ end # def draw
+
+ end # class Pie
+
+ end
+end
diff --git a/vendor/plugins/gruff/lib/gruff/mini/side_bar.rb b/vendor/plugins/gruff/lib/gruff/mini/side_bar.rb
new file mode 100644
index 0000000..46be4f4
--- /dev/null
+++ b/vendor/plugins/gruff/lib/gruff/mini/side_bar.rb
@@ -0,0 +1,35 @@
+##
+#
+# Makes a small pie graph suitable for display at 200px or even smaller.
+#
+module Gruff
+ module Mini
+
+ class SideBar < Gruff::SideBar
+
+ include Gruff::Mini::Legend
+
+ def initialize_ivars
+ super
+ @hide_legend = true
+ @hide_title = true
+ @hide_line_numbers = true
+
+ @marker_font_size = 50.0
+ @legend_font_size = 50.0
+ end
+
+ def draw
+ expand_canvas_for_vertical_legend
+
+ super
+
+ draw_vertical_legend
+
+ @d.draw(@base_image)
+ end
+
+ end
+
+ end
+end
diff --git a/vendor/plugins/gruff/lib/gruff/net.rb b/vendor/plugins/gruff/lib/gruff/net.rb
new file mode 100644
index 0000000..debf9f7
--- /dev/null
+++ b/vendor/plugins/gruff/lib/gruff/net.rb
@@ -0,0 +1,142 @@
+
+require File.dirname(__FILE__) + '/base'
+
+# Experimental!!! See also the Spider graph.
+class Gruff::Net < Gruff::Base
+
+ # Hide parts of the graph to fit more datapoints, or for a different appearance.
+ attr_accessor :hide_dots
+
+ def initialize(*args)
+ super
+
+ @hide_dots = false
+ end
+
+ def draw
+
+ super
+
+ return unless @has_data
+
+ @radius = @graph_height / 2.0
+ @center_x = @graph_left + (@graph_width / 2.0)
+ @center_y = @graph_top + (@graph_height / 2.0) - 10 # Move graph up a bit
+
+ @x_increment = @graph_width / (@column_count - 1).to_f
+ circle_radius = clip_value_if_greater_than(@columns / (@norm_data.first[1].size * 2.5), 5.0)
+
+ @d = @d.stroke_opacity 1.0
+ @d = @d.stroke_width clip_value_if_greater_than(@columns / (@norm_data.first[1].size * 4), 5.0)
+
+ if (defined?(@norm_baseline)) then
+ level = @graph_top + (@graph_height - @norm_baseline * @graph_height)
+ @d = @d.push
+ @d.stroke_color @baseline_color
+ @d.fill_opacity 0.0
+ @d.stroke_dasharray(10, 20)
+ @d.stroke_width 5
+ @d.line(@graph_left, level, @graph_left + @graph_width, level)
+ @d = @d.pop
+ end
+
+ @norm_data.each do |data_row|
+ prev_x = prev_y = nil
+ @d = @d.stroke data_row[DATA_COLOR_INDEX]
+ @d = @d.fill data_row[DATA_COLOR_INDEX]
+
+ data_row[1].each_with_index do |data_point, index|
+ next if data_point.nil?
+
+ rad_pos = index * Math::PI * 2 / @column_count
+ point_distance = data_point * @radius
+ start_x = @center_x + Math::sin(rad_pos) * point_distance
+ start_y = @center_y - Math::cos(rad_pos) * point_distance
+
+ next_index = index + 1 < data_row[1].length ? index + 1 : 0
+
+ next_rad_pos = next_index * Math::PI * 2 / @column_count
+ next_point_distance = data_row[1][next_index] * @radius
+ end_x = @center_x + Math::sin(next_rad_pos) * next_point_distance
+ end_y = @center_y - Math::cos(next_rad_pos) * next_point_distance
+
+ @d = @d.line(start_x, start_y, end_x, end_y)
+
+ @d = @d.circle(start_x, start_y, start_x - circle_radius, start_y) unless @hide_dots
+ end
+
+ end
+
+ @d.draw(@base_image)
+ end
+
+
+ # the lines connecting in the center, with the first line vertical
+ def draw_line_markers
+ return if @hide_line_markers
+
+
+ # have to do this here (AGAIN)... see draw() in this class
+ # because this funtion is called before the @radius, @center_x and @center_y are set
+ @radius = @graph_height / 2.0
+ @center_x = @graph_left + (@graph_width / 2.0)
+ @center_y = @graph_top + (@graph_height / 2.0) - 10 # Move graph up a bit
+
+
+ # Draw horizontal line markers and annotate with numbers
+ @d = @d.stroke(@marker_color)
+ @d = @d.stroke_width 1
+
+
+ (0..@column_count-1).each do |index|
+ rad_pos = index * Math::PI * 2 / @column_count
+
+ @d = @d.line(@center_x, @center_y, @center_x + Math::sin(rad_pos) * @radius, @center_y - Math::cos(rad_pos) * @radius)
+
+
+ marker_label = labels[index] ? labels[index].to_s : '000'
+
+ draw_label(@center_x, @center_y, rad_pos * 360 / (2 * Math::PI), @radius, marker_label)
+ end
+ end
+
+private
+
+ def draw_label(center_x, center_y, angle, radius, amount)
+ r_offset = 1.1
+ x_offset = center_x # + 15 # The label points need to be tweaked slightly
+ y_offset = center_y # + 0 # This one doesn't though
+ x = x_offset + (radius * r_offset * Math.sin(angle.deg2rad))
+ y = y_offset - (radius * r_offset * Math.cos(angle.deg2rad))
+
+ # Draw label
+ @d.fill = @marker_color
+ @d.font = @font if @font
+ @d.pointsize = scale_fontsize(20)
+ @d.stroke = 'transparent'
+ @d.font_weight = BoldWeight
+ s = angle.deg2rad / (2*Math::PI)
+ @d.gravity = SouthGravity if s >= 0.96 or s < 0.04
+ @d.gravity = SouthWestGravity if s >= 0.04 or s < 0.21
+ @d.gravity = WestGravity if s >= 0.21 or s < 0.29
+ @d.gravity = NorthWestGravity if s >= 0.29 or s < 0.46
+ @d.gravity = NorthGravity if s >= 0.46 or s < 0.54
+ @d.gravity = NorthEastGravity if s >= 0.54 or s < 0.71
+ @d.gravity = EastGravity if s >= 0.71 or s < 0.79
+ @d.gravity = SouthEastGravity if s >= 0.79 or s < 0.96
+# @d.gravity = NorthGravity
+ @d.annotate_scaled(@base_image, 0, 0, x, y, amount, @scale)
+ end
+
+end
+
+# # This method is already in Float
+# class Float
+# # Used for degree => radian conversions
+# def deg2rad
+# self * (Math::PI/180.0)
+# end
+# end
+
+
+
diff --git a/vendor/plugins/gruff/lib/gruff/photo_bar.rb b/vendor/plugins/gruff/lib/gruff/photo_bar.rb
new file mode 100644
index 0000000..7240da0
--- /dev/null
+++ b/vendor/plugins/gruff/lib/gruff/photo_bar.rb
@@ -0,0 +1,100 @@
+require File.dirname(__FILE__) + '/base'
+
+# EXPERIMENTAL!
+#
+# Doesn't work yet.
+#
+class Gruff::PhotoBar < Gruff::Base
+
+# TODO
+#
+# define base and cap in yml
+# allow for image directory to be located elsewhere
+# more exact measurements for bar heights (go all the way to the bottom of the graph)
+# option to tile images instead of use a single image
+# drop base label a few px lower so photo bar graphs can have a base dropping over the lower marker line
+#
+
+ # The name of a pre-packaged photo-based theme.
+ attr_reader :theme
+
+# def initialize(target_width=800)
+# super
+# init_photo_bar_graphics()
+# end
+
+ def draw
+ super
+ return unless @has_data
+
+ return # TODO Remove for further development
+
+ init_photo_bar_graphics()
+
+ #Draw#define_clip_path()
+ #Draw#clip_path(pathname)
+ #Draw#composite....with bar graph image OverCompositeOp
+ #
+ # See also
+ #
+ # Draw.pattern # define an image to tile as the filling of a draw object
+ #
+
+ # Setup spacing.
+ #
+ # Columns sit side-by-side.
+ spacing_factor = 0.9
+ @bar_width = @norm_data[0][DATA_COLOR_INDEX].columns
+
+ @norm_data.each_with_index do |data_row, row_index|
+
+ data_row[1].each_with_index do |data_point, point_index|
+ data_point = 0 if data_point.nil?
+ # Use incremented x and scaled y
+ left_x = @graph_left + (@bar_width * (row_index + point_index + ((@data.length - 1) * point_index)))
+ left_y = @graph_top + (@graph_height - data_point * @graph_height) + 1
+ right_x = left_x + @bar_width * spacing_factor
+ right_y = @graph_top + @graph_height - 1
+
+ bar_image_width = data_row[DATA_COLOR_INDEX].columns
+ bar_image_height = right_y.to_f - left_y.to_f
+
+ # Crop to scale for data
+ bar_image = data_row[DATA_COLOR_INDEX].crop(0, 0, bar_image_width, bar_image_height)
+
+ @d.gravity = NorthWestGravity
+ @d = @d.composite(left_x, left_y, bar_image_width, bar_image_height, bar_image)
+
+ # Calculate center based on bar_width and current row
+ label_center = @graph_left + (@data.length * @bar_width * point_index) + (@data.length * @bar_width / 2.0)
+ draw_label(label_center, point_index)
+ end
+
+ end
+
+ @d.draw(@base_image)
+ end
+
+
+ # Return the chosen theme or the default
+ def theme
+ @theme || 'plastik'
+ end
+
+protected
+
+ # Sets up colors with a list of images that will be used.
+ # Images should be 340px tall
+ def init_photo_bar_graphics
+ color_list = Array.new
+ theme_dir = File.dirname(__FILE__) + '/../../assets/' + theme
+
+ Dir.open(theme_dir).each do |file|
+ next unless /\.png$/.match(file)
+ color_list << Image.read("#{theme_dir}/#{file}").first
+ end
+ @colors = color_list
+ end
+
+end
+
diff --git a/vendor/plugins/gruff/lib/gruff/pie.rb b/vendor/plugins/gruff/lib/gruff/pie.rb
new file mode 100644
index 0000000..f62d819
--- /dev/null
+++ b/vendor/plugins/gruff/lib/gruff/pie.rb
@@ -0,0 +1,124 @@
+require File.dirname(__FILE__) + '/base'
+
+##
+# Here's how to make a Pie graph:
+#
+# g = Gruff::Pie.new
+# g.title = "Visual Pie Graph Test"
+# g.data 'Fries', 20
+# g.data 'Hamburgers', 50
+# g.write("test/output/pie_keynote.png")
+#
+# To control where the pie chart starts creating slices, use #zero_degree.
+
+class Gruff::Pie < Gruff::Base
+
+ TEXT_OFFSET_PERCENTAGE = 0.15
+
+ # Can be used to make the pie start cutting slices at the top (-90.0)
+ # or at another angle. Default is 0.0, which starts at 3 o'clock.
+ attr_accessor :zero_degree
+
+ def initialize_ivars
+ super
+ @zero_degree = 0.0
+ end
+
+ def draw
+ @hide_line_markers = true
+
+ super
+
+ return unless @has_data
+
+ diameter = @graph_height
+ radius = ([@graph_width, @graph_height].min / 2.0) * 0.8
+ top_x = @graph_left + (@graph_width - diameter) / 2.0
+ center_x = @graph_left + (@graph_width / 2.0)
+ center_y = @graph_top + (@graph_height / 2.0) - 10 # Move graph up a bit
+ total_sum = sums_for_pie()
+ prev_degrees = @zero_degree
+
+ # Use full data since we can easily calculate percentages
+ data = (@sort ? @data.sort{ |a, b| a[DATA_VALUES_INDEX][0] <=> b[DATA_VALUES_INDEX][0] } : @data)
+ data.each do |data_row|
+ if data_row[DATA_VALUES_INDEX][0] > 0
+ @d = @d.stroke data_row[DATA_COLOR_INDEX]
+ @d = @d.fill 'transparent'
+ @d.stroke_width(radius) # stroke width should be equal to radius. we'll draw centered on (radius / 2)
+
+ current_degrees = (data_row[DATA_VALUES_INDEX][0] / total_sum) * 360.0
+
+ # ellipse will draw the the stroke centered on the first two parameters offset by the second two.
+ # therefore, in order to draw a circle of the proper diameter we must center the stroke at
+ # half the radius for both x and y
+ @d = @d.ellipse(center_x, center_y,
+ radius / 2.0, radius / 2.0,
+ prev_degrees, prev_degrees + current_degrees + 0.5) # <= +0.5 'fudge factor' gets rid of the ugly gaps
+
+ half_angle = prev_degrees + ((prev_degrees + current_degrees) - prev_degrees) / 2
+
+ # Following line is commented to allow display of the percentiles
+ # bug appeared between r90 and r92
+ # unless @hide_line_markers then
+ # End the string with %% to escape the single %.
+ # RMagick must use sprintf with the string and % has special significance.
+ label_string = ((data_row[DATA_VALUES_INDEX][0] / total_sum) *
+ 100.0).round.to_s + '%%'
+ @d = draw_label(center_x,center_y, half_angle,
+ radius + (radius * TEXT_OFFSET_PERCENTAGE),
+ label_string)
+ # end
+
+ prev_degrees += current_degrees
+ end
+ end
+
+ # TODO debug a circle where the text is drawn...
+
+ @d.draw(@base_image)
+ end
+
+private
+
+ ##
+ # Labels are drawn around a slightly wider ellipse to give room for
+ # labels on the left and right.
+ def draw_label(center_x, center_y, angle, radius, amount)
+ # TODO Don't use so many hard-coded numbers
+ r_offset = 20.0 # The distance out from the center of the pie to get point
+ x_offset = center_x # + 15.0 # The label points need to be tweaked slightly
+ y_offset = center_y # This one doesn't though
+ radius_offset = (radius + r_offset)
+ ellipse_factor = radius_offset * 0.15
+ x = x_offset + ((radius_offset + ellipse_factor) * Math.cos(angle.deg2rad))
+ y = y_offset + (radius_offset * Math.sin(angle.deg2rad))
+
+ # Draw label
+ @d.fill = @font_color
+ @d.font = @font if @font
+ @d.pointsize = scale_fontsize(@marker_font_size)
+ @d.stroke = 'transparent'
+ @d.font_weight = BoldWeight
+ @d.gravity = CenterGravity
+ @d.annotate_scaled( @base_image,
+ 0, 0,
+ x, y,
+ amount, @scale)
+ end
+
+ def sums_for_pie
+ total_sum = 0.0
+ @data.collect {|data_row| total_sum += data_row[DATA_VALUES_INDEX][0] }
+ total_sum
+ end
+
+end
+
+class Float
+ # Used for degree => radian conversions
+ def deg2rad
+ self * (Math::PI/180.0)
+ end
+end
+
diff --git a/vendor/plugins/gruff/lib/gruff/scene.rb b/vendor/plugins/gruff/lib/gruff/scene.rb
new file mode 100644
index 0000000..47943db
--- /dev/null
+++ b/vendor/plugins/gruff/lib/gruff/scene.rb
@@ -0,0 +1,209 @@
+
+require "observer"
+require File.dirname(__FILE__) + '/base'
+
+##
+# A scene is a non-linear graph that assembles layers together to tell a story.
+# Layers are folders with appropriately named files (see below). You can group
+# layers and control them together or just set their values individually.
+#
+# Examples:
+#
+# * A city scene that changes with the time of day and the weather conditions.
+# * A traffic map that shows red lines on streets that are crowded and green on free-flowing ones.
+#
+# Usage:
+#
+# g = Gruff::Scene.new("500x100", "path/to/city_scene_directory")
+#
+# # Define order of layers, back to front
+# g.layers = %w(background haze sky clouds)
+#
+# # Define groups that will be controlled by the same input
+# g.weather_group = %w(clouds)
+# g.time_group = %w(background sky)
+#
+# # Set values for the layers or groups
+# g.weather = "cloudy"
+# g.time = Time.now
+# g.haze = true
+#
+# # Write the final graph to disk
+# g.write "hazy_daytime_city_scene.png"
+#
+#
+# There are several rules that will magically select a layer when possible.
+#
+# * Numbered files will be selected according to the closest value that is less than the input value.
+# * 'true.png' and 'false.png' will be used as booleans.
+# * Other named files will be used if the input matches the filename (without the filetype extension).
+# * If there is a file named 'default.png', it will be used unless other input values are set for the corresponding layer.
+
+class Gruff::Scene < Gruff::Base
+
+ # An array listing the foldernames that will be rendered, from back to front.
+ #
+ # g.layers = %w(sky clouds buildings street people)
+ #
+ attr_reader :layers
+
+ def initialize(target_width, base_dir)
+ @base_dir = base_dir
+ @groups = {}
+ @layers = []
+ super target_width
+ end
+
+ def draw
+ # Join all the custom paths and filter out the empty ones
+ image_paths = @layers.map { |layer| layer.path }.select { |path| !path.empty? }
+ images = Magick::ImageList.new(*image_paths)
+ @base_image = images.flatten_images
+ end
+
+ def layers=(ordered_list)
+ ordered_list.each do |layer_name|
+ @layers << Gruff::Layer.new(@base_dir, layer_name)
+ end
+ end
+
+ # Group layers to input values
+ #
+ # g.weather_group = ["sky", "sea", "clouds"]
+ #
+ # Set input values
+ #
+ # g.weather = "cloudy"
+ #
+ def method_missing(method_name, *args)
+ case method_name.to_s
+ when /^(\w+)_group=$/
+ add_group $1, *args
+ return
+ when /^(\w+)=$/
+ set_input $1, args.first
+ return
+ end
+ super
+ end
+
+private
+
+ def add_group(input_name, layer_names)
+ @groups[input_name] = Gruff::Group.new(input_name, @layers.select { |layer| layer_names.include?(layer.name) })
+ end
+
+ def set_input(input_name, input_value)
+ if not @groups[input_name].nil?
+ @groups[input_name].send_updates(input_value)
+ else
+ if chosen_layer = @layers.detect { |layer| layer.name == input_name }
+ chosen_layer.update input_value
+ end
+ end
+ end
+
+end
+
+
+class Gruff::Group
+
+ include Observable
+ attr_reader :name
+
+ def initialize(folder_name, layers)
+ @name = folder_name
+ layers.each do |layer|
+ layer.observe self
+ end
+ end
+
+ def send_updates(value)
+ changed
+ notify_observers value
+ end
+
+end
+
+
+class Gruff::Layer
+
+ attr_reader :name
+
+ def initialize(base_dir, folder_name)
+ @base_dir = base_dir.to_s
+ @name = folder_name.to_s
+ @filenames = Dir.open(File.join(base_dir, folder_name)).entries.select { |file| file =~ /^[^.]+\.png$/ }
+ @selected_filename = select_default
+ end
+
+ # Register this layer so it receives updates from the group
+ def observe(obj)
+ obj.add_observer self
+ end
+
+ # Choose the appropriate filename for this layer, based on the input
+ def update(value)
+ @selected_filename = case value.to_s
+ when /^(true|false)$/
+ select_boolean value
+ when /^(\w|\s)+$/
+ select_string value
+ when /^-?(\d+\.)?\d+$/
+ select_numeric value
+ when /(\d\d):(\d\d):\d\d/
+ select_time "#{$1}#{$2}"
+ else
+ select_default
+ end
+ # Finally, try to use 'default' if we're still blank
+ @selected_filename ||= select_default
+ end
+
+ # Returns the full path to the selected image, or a blank string
+ def path
+ unless @selected_filename.nil? || @selected_filename.empty?
+ return File.join(@base_dir, @name, @selected_filename)
+ end
+ ''
+ end
+
+private
+
+ # Match "true.png" or "false.png"
+ def select_boolean(value)
+ file_exists_or_blank value.to_s
+ end
+
+ # Match -5 to _5.png
+ def select_numeric(value)
+ file_exists_or_blank value.to_s.gsub('-', '_')
+ end
+
+ def select_time(value)
+ times = @filenames.map { |filename| filename.gsub('.png', '') }
+ times.each_with_index do |time, index|
+ if (time > value) && (index > 0)
+ return "#{times[index - 1]}.png"
+ end
+ end
+ return "#{times.last}.png"
+ end
+
+ # Match "partly cloudy" to "partly_cloudy.png"
+ def select_string(value)
+ file_exists_or_blank value.to_s.gsub(' ', '_')
+ end
+
+ def select_default
+ @filenames.include?("default.png") ? "default.png" : ''
+ end
+
+ # Returns the string "#{filename}.png", if it exists.
+ #
+ # Failing that, it returns default.png, or '' if that doesn't exist.
+ def file_exists_or_blank(filename)
+ @filenames.include?("#{filename}.png") ? "#{filename}.png" : select_default
+ end
+
+end
diff --git a/vendor/plugins/gruff/lib/gruff/side_bar.rb b/vendor/plugins/gruff/lib/gruff/side_bar.rb
new file mode 100644
index 0000000..62208cf
--- /dev/null
+++ b/vendor/plugins/gruff/lib/gruff/side_bar.rb
@@ -0,0 +1,114 @@
+require File.dirname(__FILE__) + '/base'
+
+##
+# Graph with individual horizontal bars instead of vertical bars.
+
+class Gruff::SideBar < Gruff::Base
+
+ def draw
+ @has_left_labels = true
+ super
+
+ return unless @has_data
+
+ # Setup spacing.
+ #
+ spacing_factor = 0.9
+
+ @bars_width = @graph_height / @column_count.to_f
+ @bar_width = @bars_width * spacing_factor / @norm_data.size
+ @d = @d.stroke_opacity 0.0
+ height = Array.new(@column_count, 0)
+ length = Array.new(@column_count, @graph_left)
+
+ @norm_data.each_with_index do |data_row, row_index|
+ @d = @d.fill data_row[DATA_COLOR_INDEX]
+
+ data_row[1].each_with_index do |data_point, point_index|
+
+ # Using the original calcs from the stacked bar chart
+ # to get the difference between
+ # part of the bart chart we wish to stack.
+ temp1 = @graph_left + (@graph_width - data_point * @graph_width - height[point_index])
+ temp2 = @graph_left + @graph_width - height[point_index]
+ difference = temp2 - temp1
+
+ left_x = length[point_index] - 1
+ left_y = @graph_top + (@bars_width * point_index) + (@bar_width * row_index)
+ right_x = left_x + difference
+ right_y = left_y + @bar_width
+
+ height[point_index] += (data_point * @graph_width)
+
+ @d = @d.rectangle(left_x, left_y, right_x, right_y)
+
+ # Calculate center based on bar_width and current row
+ label_center = @graph_top + (@bars_width * point_index + @bars_width / 2)
+ draw_label(label_center, point_index)
+ end
+
+ end
+
+ @d.draw(@base_image)
+ end
+
+protected
+
+ # Instead of base class version, draws vertical background lines and label
+ def draw_line_markers
+
+ return if @hide_line_markers
+
+ @d = @d.stroke_antialias false
+
+ # Draw horizontal line markers and annotate with numbers
+ @d = @d.stroke(@marker_color)
+ @d = @d.stroke_width 1
+ number_of_lines = 5
+
+ # TODO Round maximum marker value to a round number like 100, 0.1, 0.5, etc.
+ increment = significant(@maximum_value.to_f / number_of_lines)
+ (0..number_of_lines).each do |index|
+
+ line_diff = (@graph_right - @graph_left) / number_of_lines
+ x = @graph_right - (line_diff * index) - 1
+ @d = @d.line(x, @graph_bottom, x, @graph_top)
+ diff = index - number_of_lines
+ marker_label = diff.abs * increment
+
+ unless @hide_line_numbers
+ @d.fill = @font_color
+ @d.font = @font if @font
+ @d.stroke = 'transparent'
+ @d.pointsize = scale_fontsize(@marker_font_size)
+ @d.gravity = CenterGravity
+ # TODO Center text over line
+ @d = @d.annotate_scaled( @base_image,
+ 0, 0, # Width of box to draw text in
+ x, @graph_bottom + (LABEL_MARGIN * 2.0), # Coordinates of text
+ marker_label.to_s, @scale)
+ end # unless
+ @d = @d.stroke_antialias true
+ end
+ end
+
+ ##
+ # Draw on the Y axis instead of the X
+
+ def draw_label(y_offset, index)
+ if !@labels[index].nil? && @labels_seen[index].nil?
+ @d.fill = @font_color
+ @d.font = @font if @font
+ @d.stroke = 'transparent'
+ @d.font_weight = NormalWeight
+ @d.pointsize = scale_fontsize(@marker_font_size)
+ @d.gravity = EastGravity
+ @d = @d.annotate_scaled(@base_image,
+ 1, 1,
+ -@graph_left + LABEL_MARGIN * 2.0, y_offset,
+ @labels[index], @scale)
+ @labels_seen[index] = 1
+ end
+ end
+
+end
diff --git a/vendor/plugins/gruff/lib/gruff/side_stacked_bar.rb b/vendor/plugins/gruff/lib/gruff/side_stacked_bar.rb
new file mode 100644
index 0000000..271e18f
--- /dev/null
+++ b/vendor/plugins/gruff/lib/gruff/side_stacked_bar.rb
@@ -0,0 +1,73 @@
+require File.dirname(__FILE__) + '/base'
+require File.dirname(__FILE__) + '/side_bar'
+require File.dirname(__FILE__) + '/stacked_mixin'
+
+##
+# New gruff graph type added to enable sideways stacking bar charts
+# (basically looks like a x/y flip of a standard stacking bar chart)
+#
+# alun.eyre@googlemail.com
+
+class Gruff::SideStackedBar < Gruff::SideBar
+ include StackedMixin
+
+ def draw
+ @has_left_labels = true
+ get_maximum_by_stack
+ super
+
+ return unless @has_data
+
+ # Setup spacing.
+ #
+ # Columns sit stacked.
+ spacing_factor = 0.9
+
+ @bar_width = @graph_height / @column_count.to_f
+ @d = @d.stroke_opacity 0.0
+ height = Array.new(@column_count, 0)
+ length = Array.new(@column_count, @graph_left)
+
+ @norm_data.each_with_index do |data_row, row_index|
+ @d = @d.fill data_row[DATA_COLOR_INDEX]
+
+ data_row[1].each_with_index do |data_point, point_index|
+
+ ## using the original calcs from the stacked bar chart to get the difference between
+ ## part of the bart chart we wish to stack.
+ temp1 = @graph_left + (@graph_width -
+ data_point * @graph_width -
+ height[point_index]) + 1
+ temp2 = @graph_left + @graph_width - height[point_index] - 1
+ difference = temp2 - temp1
+
+ left_x = length[point_index] #+ 1
+ left_y = @graph_top + (@bar_width * point_index)
+ right_x = left_x + difference
+ right_y = left_y + @bar_width * spacing_factor
+ length[point_index] += difference
+ height[point_index] += (data_point * @graph_width - 2)
+
+ @d = @d.rectangle(left_x, left_y, right_x, right_y)
+
+ # Calculate center based on bar_width and current row
+ label_center = @graph_top + (@bar_width * point_index) + (@bar_width * spacing_factor / 2.0)
+ draw_label(label_center, point_index)
+ end
+
+ end
+
+ @d.draw(@base_image)
+ end
+
+ protected
+
+ def larger_than_max?(data_point, index=0)
+ max(data_point, index) > @maximum_value
+ end
+
+ def max(data_point, index)
+ @data.inject(0) {|sum, item| sum + item[1][index]}
+ end
+
+end
diff --git a/vendor/plugins/gruff/lib/gruff/spider.rb b/vendor/plugins/gruff/lib/gruff/spider.rb
new file mode 100644
index 0000000..7710426
--- /dev/null
+++ b/vendor/plugins/gruff/lib/gruff/spider.rb
@@ -0,0 +1,130 @@
+
+require File.dirname(__FILE__) + '/base'
+
+# Experimental!!! See also the Net graph.
+#
+# Submitted by Kevin Clark http://glu.ttono.us/
+class Gruff::Spider < Gruff::Base
+
+ # Hide all text
+ attr_reader :hide_text
+ attr_accessor :hide_axes
+ attr_reader :transparent_background
+
+ def transparent_background=(value)
+ @transparent_background = value
+ @base_image = render_transparent_background if value
+ end
+
+ def hide_text=(value)
+ @hide_title = @hide_text = value
+ end
+
+ def initialize(max_value, target_width = 800)
+ super(target_width)
+ @max_value = max_value
+ @hide_legend = true;
+ end
+
+ def draw
+ @hide_line_markers = true
+
+ super
+
+ return unless @has_data
+
+ # Setup basic positioning
+ diameter = @graph_height
+ radius = @graph_height / 2.0
+ top_x = @graph_left + (@graph_width - diameter) / 2.0
+ center_x = @graph_left + (@graph_width / 2.0)
+ center_y = @graph_top + (@graph_height / 2.0) - 25 # Move graph up a bit
+
+ @unit_length = radius / @max_value
+
+
+ total_sum = sums_for_spider
+ prev_degrees = 0.0
+ additive_angle = (2 * Math::PI)/ @data.size
+
+ current_angle = 0.0
+
+ # Draw axes
+ draw_axes(center_x, center_y, radius, additive_angle) unless hide_axes
+
+ # Draw polygon
+ draw_polygon(center_x, center_y, additive_angle)
+
+
+ @d.draw(@base_image)
+ end
+
+private
+
+ def normalize_points(value)
+ value * @unit_length
+ end
+
+ def draw_label(center_x, center_y, angle, radius, amount)
+ r_offset = 50 # The distance out from the center of the pie to get point
+ x_offset = center_x # The label points need to be tweaked slightly
+ y_offset = center_y + 0 # This one doesn't though
+ x = x_offset + ((radius + r_offset) * Math.cos(angle))
+ y = y_offset + ((radius + r_offset) * Math.sin(angle))
+
+ # Draw label
+ @d.fill = @marker_color
+ @d.font = @font if @font
+ @d.pointsize = scale_fontsize(legend_font_size)
+ @d.stroke = 'transparent'
+ @d.font_weight = BoldWeight
+ @d.gravity = CenterGravity
+ @d.annotate_scaled( @base_image,
+ 0, 0,
+ x, y,
+ amount, @scale)
+ end
+
+ def draw_axes(center_x, center_y, radius, additive_angle, line_color = nil)
+ return if hide_axes
+
+ current_angle = 0.0
+
+ @data.each do |data_row|
+ @d.stroke(line_color || data_row[DATA_COLOR_INDEX])
+ @d.stroke_width 5.0
+
+ x_offset = radius * Math.cos(current_angle)
+ y_offset = radius * Math.sin(current_angle)
+
+ @d.line(center_x, center_y,
+ center_x + x_offset,
+ center_y + y_offset)
+
+ draw_label(center_x, center_y, current_angle, radius, data_row[0].to_s) unless hide_text
+
+ current_angle += additive_angle
+ end
+ end
+
+ def draw_polygon(center_x, center_y, additive_angle, color = nil)
+ points = []
+ current_angle = 0.0
+ @data.each do |data_row|
+ points << center_x + normalize_points(data_row[1][0]) * Math.cos(current_angle)
+ points << center_y + normalize_points(data_row[1][0]) * Math.sin(current_angle)
+ current_angle += additive_angle
+ end
+
+ @d.stroke_width 1.0
+ @d.stroke(color || @marker_color)
+ @d.fill(color || @marker_color)
+ @d.fill_opacity 0.4
+ @d.polygon(*points)
+ end
+
+ def sums_for_spider
+ @data.inject(0.0) {|sum, data_row| sum += data_row[1][0]}
+ end
+
+end
diff --git a/vendor/plugins/gruff/lib/gruff/stacked_area.rb b/vendor/plugins/gruff/lib/gruff/stacked_area.rb
new file mode 100644
index 0000000..e0573b5
--- /dev/null
+++ b/vendor/plugins/gruff/lib/gruff/stacked_area.rb
@@ -0,0 +1,66 @@
+
+require File.dirname(__FILE__) + '/base'
+require File.dirname(__FILE__) + '/stacked_mixin'
+
+class Gruff::StackedArea < Gruff::Base
+ include StackedMixin
+ attr_accessor :last_series_goes_on_bottom
+
+ def draw
+ super
+
+ return unless @has_data
+
+ @x_increment = @graph_width / (@column_count - 1).to_f
+ @d = @d.stroke 'transparent'
+
+ height = Array.new(@column_count, 0)
+
+ data_points = nil
+ iterator = last_series_goes_on_bottom ? :reverse_each : :each
+ @norm_data.send(iterator) do |data_row|
+ prev_data_points = data_points
+ data_points = Array.new
+
+ @d = @d.fill data_row[DATA_COLOR_INDEX]
+
+ data_row[1].each_with_index do |data_point, index|
+ # Use incremented x and scaled y
+ new_x = @graph_left + (@x_increment * index)
+ new_y = @graph_top + (@graph_height - data_point * @graph_height - height[index])
+
+ height[index] += (data_point * @graph_height)
+
+ data_points << new_x
+ data_points << new_y
+
+ draw_label(new_x, index)
+
+ end
+
+ if prev_data_points
+ poly_points = data_points.dup
+ (prev_data_points.length/2 - 1).downto(0) do |i|
+ poly_points << prev_data_points[2*i]
+ poly_points << prev_data_points[2*i+1]
+ end
+ poly_points << data_points[0]
+ poly_points << data_points[1]
+ else
+ poly_points = data_points.dup
+ poly_points << @graph_right
+ poly_points << @graph_bottom - 1
+ poly_points << @graph_left
+ poly_points << @graph_bottom - 1
+ poly_points << data_points[0]
+ poly_points << data_points[1]
+ end
+ @d = @d.polyline(*poly_points)
+
+ end
+
+ @d.draw(@base_image)
+ end
+
+
+end
diff --git a/vendor/plugins/gruff/lib/gruff/stacked_bar.rb b/vendor/plugins/gruff/lib/gruff/stacked_bar.rb
new file mode 100644
index 0000000..dd8be89
--- /dev/null
+++ b/vendor/plugins/gruff/lib/gruff/stacked_bar.rb
@@ -0,0 +1,53 @@
+
+require File.dirname(__FILE__) + '/base'
+require File.dirname(__FILE__) + '/stacked_mixin'
+
+class Gruff::StackedBar < Gruff::Base
+ include StackedMixin
+
+ # Draws a bar graph, but multiple sets are stacked on top of each other.
+ def draw
+ get_maximum_by_stack
+ super
+ return unless @has_data
+
+ # Setup spacing.
+ #
+ # Columns sit stacked.
+ spacing_factor = 0.9
+ @bar_width = @graph_width / @column_count.to_f
+
+ @d = @d.stroke_opacity 0.0
+
+ height = Array.new(@column_count, 0)
+
+ @norm_data.each_with_index do |data_row, row_index|
+ @d = @d.fill data_row[DATA_COLOR_INDEX]
+
+ data_row[1].each_with_index do |data_point, point_index|
+ # Calculate center based on bar_width and current row
+ label_center = @graph_left + (@bar_width * point_index) + (@bar_width * spacing_factor / 2.0)
+ draw_label(label_center, point_index)
+
+ next if (data_point == 0)
+ # Use incremented x and scaled y
+ left_x = @graph_left + (@bar_width * point_index)
+ left_y = @graph_top + (@graph_height -
+ data_point * @graph_height -
+ height[point_index]) + 1
+ right_x = left_x + @bar_width * spacing_factor
+ right_y = @graph_top + @graph_height - height[point_index] - 1
+
+ # update the total height of the current stacked bar
+ height[point_index] += (data_point * @graph_height )
+
+ @d = @d.rectangle(left_x, left_y, right_x, right_y)
+
+ end
+
+ end
+
+ @d.draw(@base_image)
+ end
+
+end
diff --git a/vendor/plugins/gruff/lib/gruff/stacked_mixin.rb b/vendor/plugins/gruff/lib/gruff/stacked_mixin.rb
new file mode 100644
index 0000000..845fe28
--- /dev/null
+++ b/vendor/plugins/gruff/lib/gruff/stacked_mixin.rb
@@ -0,0 +1,23 @@
+
+module Gruff::Base::StackedMixin
+ # Used by StackedBar and child classes.
+ #
+ # tsal: moved from Base 03 FEB 2007
+ DATA_VALUES_INDEX = Gruff::Base::DATA_VALUES_INDEX
+ def get_maximum_by_stack
+ # Get sum of each stack
+ max_hash = {}
+ @data.each do |data_set|
+ data_set[DATA_VALUES_INDEX].each_with_index do |data_point, i|
+ max_hash[i] = 0.0 unless max_hash[i]
+ max_hash[i] += data_point.to_f
+ end
+ end
+
+ # @maximum_value = 0
+ max_hash.keys.each do |key|
+ @maximum_value = max_hash[key] if max_hash[key] > @maximum_value
+ end
+ @minimum_value = 0
+ end
+end
diff --git a/vendor/plugins/gruff/rails_generators/gruff/gruff_generator.rb b/vendor/plugins/gruff/rails_generators/gruff/gruff_generator.rb
new file mode 100644
index 0000000..337f58e
--- /dev/null
+++ b/vendor/plugins/gruff/rails_generators/gruff/gruff_generator.rb
@@ -0,0 +1,63 @@
+class GruffGenerator < Rails::Generator::NamedBase
+
+ attr_reader :controller_name,
+ :controller_class_path,
+ :controller_file_path,
+ :controller_class_nesting,
+ :controller_class_nesting_depth,
+ :controller_class_name,
+ :controller_singular_name,
+ :controller_plural_name,
+ :parent_folder_for_require
+ alias_method :controller_file_name, :controller_singular_name
+ alias_method :controller_table_name, :controller_plural_name
+
+ def initialize(runtime_args, runtime_options = {})
+ super
+
+ # Take controller name from the next argument.
+ @controller_name = runtime_args.shift
+
+ base_name, @controller_class_path, @controller_file_path, @controller_class_nesting, @controller_class_nesting_depth = extract_modules(@controller_name)
+ @controller_class_name_without_nesting, @controller_singular_name, @controller_plural_name = inflect_names(base_name)
+
+ if @controller_class_nesting.empty?
+ @controller_class_name = @controller_class_name_without_nesting
+ else
+ @controller_class_name = "#{@controller_class_nesting}::#{@controller_class_name_without_nesting}"
+ end
+ end
+
+ def manifest
+ record do |m|
+ # Check for class naming collisions.
+ m.class_collisions controller_class_path, "#{controller_class_name}Controller",
+ "#{controller_class_name}ControllerTest"
+
+ # Controller, helper, views, and test directories.
+ m.directory File.join('app/controllers', controller_class_path)
+ m.directory File.join('test/functional', controller_class_path)
+
+ m.template 'controller.rb',
+ File.join('app/controllers',
+ controller_class_path,
+ "#{controller_file_name}_controller.rb")
+
+ # For some reason this doesn't take effect if done in initialize()
+ @parent_folder_for_require = @controller_class_path.join('/').gsub(%r%app/controllers/?%, '')
+ @parent_folder_for_require += @parent_folder_for_require.blank? ? '' : '/'
+
+ m.template 'functional_test.rb',
+ File.join('test/functional',
+ controller_class_path,
+ "#{controller_file_name}_controller_test.rb")
+
+ end
+ end
+
+ protected
+ # Override with your own usage banner.
+ def banner
+ "Usage: #{$0} gruff ControllerName"
+ end
+end
diff --git a/vendor/plugins/gruff/rails_generators/gruff/templates/controller.rb b/vendor/plugins/gruff/rails_generators/gruff/templates/controller.rb
new file mode 100644
index 0000000..b8f90dd
--- /dev/null
+++ b/vendor/plugins/gruff/rails_generators/gruff/templates/controller.rb
@@ -0,0 +1,32 @@
+class <%= controller_class_name %>Controller < ApplicationController
+
+ # To make caching easier, add a line like this to config/routes.rb:
+ # map.graph "graph/:action/:id/image.png", :controller => "graph"
+ #
+ # Then reference it with the named route:
+ # image_tag graph_url(:action => 'show', :id => 42)
+
+ def show
+ g = Gruff::Line.new
+ # Uncomment to use your own theme or font
+ # See http://colourlovers.com or http://www.firewheeldesign.com/widgets/ for color ideas
+# g.theme = {
+# :colors => ['#663366', '#cccc99', '#cc6633', '#cc9966', '#99cc99'],
+# :marker_color => 'white',
+# :background_colors => ['black', '#333333']
+# }
+# g.font = File.expand_path('artwork/fonts/VeraBd.ttf', RAILS_ROOT)
+
+ g.title = "Gruff-o-Rama"
+
+ g.data("Apples", [1, 2, 3, 4, 4, 3])
+ g.data("Oranges", [4, 8, 7, 9, 8, 9])
+ g.data("Watermelon", [2, 3, 1, 5, 6, 8])
+ g.data("Peaches", [9, 9, 10, 8, 7, 9])
+
+ g.labels = {0 => '2004', 2 => '2005', 4 => '2006'}
+
+ send_data(g.to_blob, :disposition => 'inline', :type => 'image/png', :filename => "gruff.png")
+ end
+
+end
diff --git a/vendor/plugins/gruff/rails_generators/gruff/templates/functional_test.rb b/vendor/plugins/gruff/rails_generators/gruff/templates/functional_test.rb
new file mode 100644
index 0000000..c1f0818
--- /dev/null
+++ b/vendor/plugins/gruff/rails_generators/gruff/templates/functional_test.rb
@@ -0,0 +1,24 @@
+require File.dirname(__FILE__) + '<%= '/..' * controller_class_name.split("::").length %>/test_helper'
+require '<%= parent_folder_for_require %><%= controller_file_name %>_controller'
+
+# Re-raise errors caught by the controller.
+class <%= controller_class_name %>Controller; def rescue_action(e) raise e end; end
+
+class <%= controller_class_name %>ControllerTest < Test::Unit::TestCase
+
+ #fixtures :data
+
+ def setup
+ @controller = <%= controller_class_name %>Controller.new
+ @request = ActionController::TestRequest.new
+ @response = ActionController::TestResponse.new
+ end
+
+ # TODO Replace this with your actual tests
+ def test_show
+ get :show
+ assert_response :success
+ assert_equal 'image/png', @response.headers['Content-Type']
+ end
+
+end
diff --git a/vendor/plugins/gruff/test/gruff_test_case.rb b/vendor/plugins/gruff/test/gruff_test_case.rb
new file mode 100644
index 0000000..074a8d5
--- /dev/null
+++ b/vendor/plugins/gruff/test/gruff_test_case.rb
@@ -0,0 +1,123 @@
+$:.unshift(File.dirname(__FILE__) + "/../lib/")
+# require 'rubygems'
+
+require 'test/unit'
+require 'gruff'
+require 'fileutils'
+# require 'test_timer'
+
+TEST_OUTPUT_DIR = File.dirname(__FILE__) + "/output"
+FileUtils.mkdir_p(TEST_OUTPUT_DIR)
+
+class GruffTestCase < Test::Unit::TestCase
+
+ def setup
+ @datasets = [
+ [:Jimmy, [25, 36, 86, 39, 25, 31, 79, 88]],
+ [:Charles, [80, 54, 67, 54, 68, 70, 90, 95]],
+ [:Julie, [22, 29, 35, 38, 36, 40, 46, 57]],
+ [:Jane, [95, 95, 95, 90, 85, 80, 88, 100]],
+ [:Philip, [90, 34, 23, 12, 78, 89, 98, 88]],
+ ["Arthur", [5, 10, 13, 11, 6, 16, 22, 32]],
+ ]
+
+ @labels = {
+ 0 => '5/6',
+ 1 => '5/15',
+ 2 => '5/24',
+ 3 => '5/30',
+ 4 => '6/4',
+ 5 => '6/12',
+ 6 => '6/21',
+ 7 => '6/28',
+ }
+ end
+
+ def setup_single_dataset
+ @datasets = [
+ [:Jimmy, [25, 36, 86]]
+ ]
+
+ @labels = {
+ 0 => 'You',
+ 1 => 'Average',
+ 2 => 'Lifetime'
+ }
+ end
+
+ def setup_wide_dataset
+ @datasets = [
+ ["Auto", 25],
+ ["Food", 5],
+ ["Entertainment", 15]
+ ]
+
+ @labels = { 0 => 'This Month' }
+ end
+
+ def test_dummy
+ assert true
+ end
+
+protected
+
+ # Generate graphs at several sizes.
+ #
+ # Also writes the graph to disk.
+ #
+ # graph_sized 'bar_basic' do |g|
+ # g.data('students', [1, 2, 3, 4])
+ # end
+ #
+ def graph_sized(filename, sizes=['', 400])
+ class_name = self.class.name.gsub(/^TestGruff/, '')
+ Array(sizes).each do |size|
+ g = instance_eval("Gruff::#{class_name}.new #{size}")
+ g.title = "#{class_name} Graph"
+ yield g
+ write_test_file g, "#{filename}_#{size}.png"
+ end
+ end
+
+ def write_test_file(graph, filename)
+ graph.write([TEST_OUTPUT_DIR, filename].join("/"))
+ end
+
+ ##
+ # Example:
+ #
+ # setup_basic_graph Gruff::Pie, 400
+ #
+ def setup_basic_graph(*args)
+ klass, size = Gruff::Bar, 400
+ # Allow args to be klass, size or just klass or just size.
+ #
+ # TODO Refactor
+ case args.length
+ when 1
+ case args[0]
+ when Fixnum
+ size = args[0]
+ klass = eval("Gruff::#{self.class.name.gsub(/^TestGruff/, '')}")
+ when String
+ size = args[0]
+ klass = eval("Gruff::#{self.class.name.gsub(/^TestGruff/, '')}")
+ else
+ klass = args[0]
+ end
+ when 2
+ klass, size = args[0], args[1]
+ end
+
+ g = klass.new(size)
+ g.title = "My Bar Graph"
+ g.labels = @labels
+
+
+ @datasets.each do |data|
+ g.data(data[0], data[1])
+ end
+ g
+ end
+
+end
diff --git a/vendor/plugins/gruff/test/test_accumulator_bar.rb b/vendor/plugins/gruff/test/test_accumulator_bar.rb
new file mode 100644
index 0000000..1872c7a
--- /dev/null
+++ b/vendor/plugins/gruff/test/test_accumulator_bar.rb
@@ -0,0 +1,50 @@
+require File.dirname(__FILE__) + "/gruff_test_case"
+
+class TestGruffAccumulatorBar < GruffTestCase
+
+ # TODO Delete old output files once when starting tests
+
+ def setup
+ @datasets = [
+ (1..20).to_a.map { rand(10) }
+ ]
+ end
+
+ def test_accumulator
+ g = Gruff::AccumulatorBar.new 500
+ g.title = "Your Savings"
+ g.hide_legend = true
+
+ # g.font = File.expand_path(File.dirname(__FILE__) + "/../assets/fonts/ATMA____.TTF")
+
+ g.marker_font_size = 18
+
+ g.theme = {
+ :colors => ['#aedaa9', '#12a702'], # 3077a9 blue, aedaa9 light green
+ :marker_color => '#dddddd',
+ :font_color => 'black',
+ :background_colors => "white"
+ # :background_image => File.expand_path(File.dirname(__FILE__) + "/../assets/backgrounds/43things.png")
+ }
+
+ # Attempt at negative numbers
+ # g.data 'Savings', (1..20).to_a.map { rand(10) * (rand(2) > 0 ? 1 : -1) }
+ g.data 'Savings', (1..12).to_a.map { rand(100) }
+ g.labels = (0..11).to_a.inject({}) {|memo, index| {index => '12-26'}.merge(memo)}
+
+ g.maximum_value = 1000
+ g.minimum_value = 0
+
+ g.write("test/output/accum_bar.png")
+ end
+
+ def test_too_many_args
+ assert_raise(Gruff::IncorrectNumberOfDatasetsException) {
+ g = Gruff::AccumulatorBar.new
+ g.data 'First', [1,1,1]
+ g.data 'Too Many', [1,1,1]
+ g.write("test/output/_SHOULD_NOT_ACTUALLY_BE_WRITTEN.png")
+ }
+ end
+
+end
diff --git a/vendor/plugins/gruff/test/test_area.rb b/vendor/plugins/gruff/test/test_area.rb
new file mode 100644
index 0000000..357711c
--- /dev/null
+++ b/vendor/plugins/gruff/test/test_area.rb
@@ -0,0 +1,134 @@
+#!/usr/bin/ruby
+
+require File.dirname(__FILE__) + "/gruff_test_case"
+
+class TestGruffArea < GruffTestCase
+
+ def setup
+ @datasets = [
+ [:Jimmy, [25, 36, 86, 39, 25, 31, 79, 88]],
+ [:Charles, [80, 54, 67, 54, 68, 70, 90, 95]],
+ [:Julie, [22, 29, 35, 38, 36, 40, 46, 57]],
+ [:Jane, [95, 95, 95, 90, 85, 80, 88, 100]],
+ [:Philip, [90, 34, 23, 12, 78, 89, 98, 88]],
+ ["Arthur", [5, 10, 13, 11, 6, 16, 22, 32]],
+ ]
+ @sample_labels = {
+ 0 => '5/6',
+ 1 => '5/15',
+ 2 => '5/24',
+ 3 => '5/30',
+ 4 => '6/4',
+ 5 => '6/12',
+ 6 => '6/21',
+ 7 => '6/28',
+ }
+
+ end
+
+ def test_area_graph
+ g = Gruff::Area.new
+ g.title = "Visual Multi-Area Graph Test"
+ g.labels = {
+ 0 => '5/6',
+ 2 => '5/15',
+ 4 => '5/24',
+ 6 => '5/30',
+ }
+ @datasets.each do |data|
+ g.data(data[0], data[1])
+ end
+
+ # Default theme
+ g.write("test/output/area_keynote.png")
+ end
+
+ def test_resize
+ g = Gruff::Area.new(400)
+ g.title = "Small Size Multi-Area Graph Test"
+ g.labels = {
+ 0 => '5/6',
+ 2 => '5/15',
+ 4 => '5/24',
+ 6 => '5/30',
+ }
+ @datasets.each do |data|
+ g.data(data[0], data[1])
+ end
+
+ # Default theme
+ g.write("test/output/area_keynote_small.png")
+ end
+
+ def test_many_datapoints
+ g = Gruff::Area.new
+ g.title = "Many Multi-Area Graph Test"
+ g.labels = {
+ 0 => 'June',
+ 10 => 'July',
+ 30 => 'August',
+ 50 => 'September',
+ }
+ g.data('many points', (0..50).collect {|i| rand(100) })
+
+ # Default theme
+ g.write("test/output/area_many.png")
+ end
+
+ def test_many_areas_graph_small
+ g = Gruff::Area.new(400)
+ g.title = "Many Values Area Test 400px"
+ g.labels = {
+ 0 => '5/6',
+ 10 => '5/15',
+ 20 => '5/24',
+ 30 => '5/30',
+ 40 => '6/4',
+ 50 => '6/16'
+ }
+ %w{jimmy jane philip arthur julie bert}.each do |student_name|
+ g.data(student_name, (0..50).collect { |i| rand 100 })
+ end
+
+ # Default theme
+ g.write("test/output/area_many_areas_small.png")
+ end
+
+ def test_area_graph_tiny
+ g = Gruff::Area.new(300)
+ g.title = "Area Test 300px"
+ g.labels = {
+ 0 => '5/6',
+ 10 => '5/15',
+ 20 => '5/24',
+ 30 => '5/30',
+ 40 => '6/4',
+ 50 => '6/16'
+ }
+ %w{jimmy jane philip arthur julie bert}.each do |student_name|
+ g.data(student_name, (0..50).collect { |i| rand 100 })
+ end
+
+ # Default theme
+ g.write("test/output/area_tiny.png")
+ end
+
+ def test_wide
+ g = setup_basic_graph('800x400')
+ g.title = "Area Wide"
+ g.write("test/output/area_wide.png")
+ end
+
+protected
+
+ def setup_basic_graph(size=800)
+ g = Gruff::Area.new(size)
+ g.title = "My Graph Title"
+ g.labels = @sample_labels
+ @datasets.each do |data|
+ g.data(data[0], data[1])
+ end
+ return g
+ end
+
+end
diff --git a/vendor/plugins/gruff/test/test_bar.rb b/vendor/plugins/gruff/test/test_bar.rb
new file mode 100644
index 0000000..695ad2e
--- /dev/null
+++ b/vendor/plugins/gruff/test/test_bar.rb
@@ -0,0 +1,283 @@
+#!/usr/bin/ruby
+
+require File.dirname(__FILE__) + "/gruff_test_case"
+
+class TestGruffBar < GruffTestCase
+
+ # TODO Delete old output files once when starting tests
+
+ def setup
+ @datasets = [
+ [:Jimmy, [25, 36, 86, 39]],
+ [:Charles, [80, 54, 67, 54]],
+ [:Julie, [22, 29, 35, 38]],
+ #[:Jane, [95, 95, 95, 90, 85, 80, 88, 100]],
+ #[:Philip, [90, 34, 23, 12, 78, 89, 98, 88]],
+ #["Arthur", [5, 10, 13, 11, 6, 16, 22, 32]],
+ ]
+ end
+
+ def test_bar_graph
+ g = setup_basic_graph
+ g.title = "Bar Graph Test"
+ g.write("test/output/bar_keynote.png")
+
+ g = setup_basic_graph
+ g.title = "Visual Multi-Line Bar Graph Test"
+ g.theme_rails_keynote
+ g.write("test/output/bar_rails_keynote.png")
+
+ g = setup_basic_graph
+ g.title = "Visual Multi-Line Bar Graph Test"
+ g.theme_odeo
+ g.write("test/output/bar_odeo.png")
+ end
+
+ def test_bar_graph_set_colors
+ g = Gruff::Bar.new
+ g.title = "Bar Graph With Manual Colors"
+ g.labels = {
+ 0 => '5/6',
+ 1 => '5/15',
+ 2 => '5/24',
+ 3 => '5/30',
+ }
+ g.data(:Art, [0, 5, 8, 15], '#990000')
+ g.data(:Philosophy, [10, 3, 2, 8], '#009900')
+ g.data(:Science, [2, 15, 8, 11], '#990099')
+
+ g.minimum_value = 0
+
+ g.write("test/output/bar_manual_colors.png")
+ end
+
+ def test_bar_graph_small
+ g = Gruff::Bar.new(400)
+ g.title = "Visual Multi-Line Bar Graph Test"
+ g.labels = {
+ 0 => '5/6',
+ 1 => '5/15',
+ 2 => '5/24',
+ 3 => '5/30',
+ }
+ @datasets.each do |data|
+ g.data(data[0], data[1])
+ end
+
+ g.write("test/output/bar_keynote_small.png")
+ end
+
+ # Somewhat worthless test. Should an error be thrown?
+ # def test_nil_font
+ # g = setup_basic_graph 400
+ # g.title = "Nil Font"
+ # g.font = nil
+ # g.write "test/output/bar_nil_font.png"
+ # end
+
+
+ def test_no_line_markers
+ g = setup_basic_graph(400)
+ g.title = "No Line Markers"
+ g.hide_line_markers = true
+ g.write("test/output/bar_no_line_markers.png")
+ end
+
+ def test_no_legend
+ g = setup_basic_graph(400)
+ g.title = "No Legend"
+ g.hide_legend = true
+ g.write("test/output/bar_no_legend.png")
+ end
+
+ def test_no_title
+ g = setup_basic_graph(400)
+ g.title = "No Title"
+ g.hide_title = true
+ g.write("test/output/bar_no_title.png")
+ end
+
+ def test_no_title_or_legend
+ g = setup_basic_graph(400)
+ g.title = "No Title or Legend"
+ g.hide_legend = true
+ g.hide_title = true
+ g.write("test/output/bar_no_title_or_legend.png")
+ end
+
+ def test_set_marker_count
+ g = setup_basic_graph(400)
+ g.title = "Set marker"
+ g.marker_count = 10
+ g.write("test/output/bar_set_marker.png")
+ end
+
+ def test_set_legend_box_size
+ g = setup_basic_graph(400)
+ g.title = "Set Legend Box Size"
+ g.legend_box_size = 10.0
+ g.write("test/output/bar_set_legend_box_size_sm.png")
+
+ g = setup_basic_graph(400)
+ g.title = "Set Legend Box Size"
+ g.legend_box_size = 50.0
+ g.write("test/output/bar_set_legend_box_size_lg.png")
+ end
+
+ def test_x_y_labels
+ g = setup_basic_graph(400)
+ g.title = "X Y Labels"
+ g.x_axis_label = 'Score (%)'
+ g.y_axis_label = "Students"
+ g.write("test/output/bar_x_y_labels.png")
+ end
+
+ def test_wide_graph
+ g = setup_basic_graph('800x400')
+ g.title = "Wide Graph"
+ g.write("test/output/bar_wide_graph.png")
+
+ g = setup_basic_graph('400x200')
+ g.title = "Wide Graph Small"
+ g.write("test/output/bar_wide_graph_small.png")
+ end
+
+
+ def test_tall_graph
+ g = setup_basic_graph('400x600')
+ g.title = "Tall Graph"
+ g.write("test/output/bar_tall_graph.png")
+
+ g = setup_basic_graph('200x400')
+ g.title = "Tall Graph Small"
+ g.write("test/output/bar_tall_graph_small.png")
+ end
+
+
+ def test_one_value
+ g = Gruff::Bar.new
+ g.title = "One Value Graph Test"
+ g.labels = {
+ 0 => '1',
+ 1 => '2'
+ }
+ g.data('one', [1,1])
+
+ g.write("test/output/bar_one_value.png")
+ end
+
+
+ def test_negative
+ g = Gruff::Bar.new
+ g.title = "Pos/Neg Bar Graph Test"
+ g.labels = {
+ 0 => '5/6',
+ 1 => '5/15',
+ 2 => '5/24',
+ 3 => '5/30',
+ }
+ g.data(:apples, [-1, 0, 4, -4])
+ g.data(:peaches, [10, 8, 6, 3])
+
+ g.write("test/output/bar_pos_neg.png")
+ end
+
+
+ def test_nearly_zero
+ g = Gruff::Bar.new
+ g.title = "Nearly Zero Graph"
+ g.labels = {
+ 0 => '5/6',
+ 1 => '5/15',
+ 2 => '5/24',
+ 3 => '5/30',
+ }
+ g.data(:apples, [1, 2, 3, 4])
+ g.data(:peaches, [4, 3, 2, 1])
+ g.minimum_value = 0
+ g.maximum_value = 10
+ g.write("test/output/bar_nearly_zero_max_10.png")
+ end
+
+ def test_y_axis_increment
+ generate_with_y_axis_increment 2.0
+ generate_with_y_axis_increment 1
+ generate_with_y_axis_increment 5
+ generate_with_y_axis_increment 20
+ end
+
+ def generate_with_y_axis_increment(increment)
+ g = Gruff::Bar.new
+ g.title = "Y Axis Set to #{increment}"
+ g.labels = {
+ 0 => '5/6',
+ 1 => '5/15',
+ 2 => '5/24',
+ 3 => '5/30',
+ }
+ g.y_axis_increment = increment
+ g.data(:apples, [1, 0.2, 0.5, 0.7])
+ g.data(:peaches, [2.5, 2.3, 2, 6.1])
+ g.write("test/output/bar_y_increment_#{increment}.png")
+ end
+
+
+ def test_custom_theme
+ g = Gruff::Bar.new
+ g.title = "Custom Theme"
+ g.font = File.expand_path('CREABBRG.TTF', ENV['MAGICK_FONT_PATH'])
+ g.title_font_size = 60
+ g.legend_font_size = 32
+ g.marker_font_size = 32
+ g.theme = {
+ :colors => %w(#efd250 #666699 #e5573f #9595e2),
+ :marker_color => 'white',
+ :font_color => 'blue',
+ :background_image => "assets/pc306715.jpg"
+ }
+ g.labels = {
+ 0 => '5/6',
+ 1 => '5/15',
+ 2 => '5/24',
+ 3 => '5/30',
+ }
+ g.data(:vancouver, [1, 2, 3, 4])
+ g.data(:seattle, [2, 4, 6, 8])
+ g.data(:portland, [3, 1, 7, 3])
+ g.data(:victoria, [4, 3, 5, 7])
+ g.minimum_value = 0
+ g.write("test/output/bar_themed.png")
+ end
+
+ def test_july_enhancements
+ g = Gruff::Bar.new(600)
+ g.hide_legend = true
+ g.title = "Full speed ahead"
+ g.labels = (0..10).inject({}) { |memo, i| memo.merge({ i => (i*10).to_s}) }
+ g.data(:apples, (0..9).map { rand(20)/10.0 })
+ g.y_axis_increment = 1.0
+ g.x_axis_label = 'Score (%)'
+ g.y_axis_label = 'Students'
+ write_test_file g, 'enhancements.png'
+ end
+
+
+protected
+
+ def setup_basic_graph(size=800)
+ g = Gruff::Bar.new(size)
+ g.title = "My Bar Graph"
+ g.labels = {
+ 0 => '5/6',
+ 1 => '5/15',
+ 2 => '5/24',
+ 3 => '5/30',
+ }
+ @datasets.each do |data|
+ g.data(data[0], data[1])
+ end
+ g
+ end
+
+end
+
diff --git a/vendor/plugins/gruff/test/test_base.rb b/vendor/plugins/gruff/test/test_base.rb
new file mode 100644
index 0000000..d68be92
--- /dev/null
+++ b/vendor/plugins/gruff/test/test_base.rb
@@ -0,0 +1,8 @@
+#!/usr/bin/ruby
+
+require File.dirname(__FILE__) + "/gruff_test_case"
+
+class TestGruffBase < GruffTestCase
+
+
+end \ No newline at end of file
diff --git a/vendor/plugins/gruff/test/test_bullet.rb b/vendor/plugins/gruff/test/test_bullet.rb
new file mode 100644
index 0000000..85acce6
--- /dev/null
+++ b/vendor/plugins/gruff/test/test_bullet.rb
@@ -0,0 +1,26 @@
+# require File.dirname(__FILE__) + "/gruff_test_case"
+#
+# class TestGruffBullet < GruffTestCase
+#
+# def setup
+# @data_args = [75, 100, {
+# :target => 80,
+# :low => 50,
+# :high => 90
+# }]
+# end
+#
+# def test_bullet_graph
+# g = Gruff::Bullet.new
+# g.title = "Monthly Revenue"
+# g.data *@data_args
+# g.write("test/output/bullet_greyscale.png")
+# end
+#
+# def test_no_options
+# g = Gruff::Bullet.new
+# g.data 127, 150
+# g.write("test/output/bullet_no_options.png")
+# end
+#
+# end
diff --git a/vendor/plugins/gruff/test/test_legend.rb b/vendor/plugins/gruff/test/test_legend.rb
new file mode 100644
index 0000000..9e6d6d2
--- /dev/null
+++ b/vendor/plugins/gruff/test/test_legend.rb
@@ -0,0 +1,71 @@
+require File.dirname(__FILE__) + "/gruff_test_case"
+
+class TestGruffLegend < GruffTestCase
+
+ def setup
+ @datasets = [
+ [:Jimmy, [25, 36, 86, 39, 25, 31, 79, 88]],
+ [:Charles, [80, 54, 67, 54, 68, 70, 90, 95]],
+ [:Julie, [22, 29, 35, 38, 36, 40, 46, 57]],
+ [:Jane, [95, 95, 95, 90, 85, 80, 88, 100]],
+ [:Philip, [90, 34, 23, 12, 78, 89, 98, 88]],
+ ["Arthur", [5, 10, 13, 11, 6, 16, 22, 32]],
+ ["Vincent", [5, 10, 13, 11, 6, 16, 22, 32]],
+ ["Jake", [5, 10, 13, 11, 6, 16, 22, 32]],
+ ["Stephen", [5, 10, 13, 11, 6, 16, 22, 32]],
+ ]
+
+ @sample_labels = {
+ 0 => '5/6',
+ 1 => '5/15',
+ 2 => '5/24',
+ 3 => '5/30',
+ 4 => '6/4',
+ 5 => '6/12',
+ 6 => '6/21',
+ 7 => '6/28',
+ }
+ end
+
+ ## TODO Fix implementation
+
+ # def test_bar_legend_wrap
+ # [800, 400].each do |width|
+ # [nil, 4, 16, 30].each do |font_size|
+ # g = Gruff::Bar.new(width)
+ # g.title = "Wrapped Legend Bar Test #{font_size}pts #{width}px"
+ # g.labels = @sample_labels
+ # 0xEFD250.step(0xFF0000, 60) do |num|
+ # g.colors << "#%x" % num
+ # end
+ #
+ # @datasets.each do |data|
+ # g.data(data[0], data[1])
+ # end
+ #
+ # g.legend_font_size = font_size unless font_size.nil?
+ # g.write("test/output/bar_wrapped_legend_#{font_size}_#{width}.png")
+ # end
+ # end
+ # end
+ #
+ # def test_pie_legend_wrap
+ # [800, 400].each do |width|
+ # [nil, 4, 16, 30].each do |font_size|
+ # g = Gruff::Pie.new(width)
+ # g.title = "Wrapped Legend Pie Test #{font_size}pts #{width}px"
+ # g.labels = @sample_labels
+ # 0xEFD250.step(0xFF0000, 60) do |num|
+ # g.colors << "#%x" % num
+ # end
+ #
+ # @datasets.each do |data|
+ # g.data(data[0], data[1])
+ # end
+ #
+ # g.legend_font_size = font_size unless font_size.nil?
+ # g.write("test/output/pie_wrapped_legend_#{font_size}_#{width}.png")
+ # end
+ # end
+ # end
+end
diff --git a/vendor/plugins/gruff/test/test_line.rb b/vendor/plugins/gruff/test/test_line.rb
new file mode 100644
index 0000000..82841d3
--- /dev/null
+++ b/vendor/plugins/gruff/test/test_line.rb
@@ -0,0 +1,513 @@
+#!/usr/bin/ruby
+
+require File.dirname(__FILE__) + "/gruff_test_case"
+
+class TestGruffLine < GruffTestCase
+
+ # TODO Delete old output files once when starting tests
+
+ def test_should_render_with_transparent_theme
+ g = Gruff::Line.new(400)
+ g.title = "Transparent Background"
+ g.theme = {
+ :colors => ['black', 'grey'],
+ :marker_color => 'grey',
+ :font_color => 'black',
+ :background_colors => 'transparent'
+ }
+
+ g.labels = {
+ 0 => '5/6',
+ 1 => '5/15',
+ 2 => '5/24',
+ 3 => '5/30',
+ }
+ g.data(:apples, [-1, 0, 4, -4])
+ g.data(:peaches, [10, 8, 6, 3])
+ g.write("test/output/line_transparent.png")
+ end
+
+ def test_line_graph_with_themes
+ line_graph_with_themes()
+ line_graph_with_themes(400)
+ end
+
+ def test_one_value
+ g = Gruff::Line.new
+ g.title = "One Value"
+ g.labels = {
+ 0 => '1',
+ 1 => '2'
+ }
+ g.data('one', 1)
+
+ g.write("test/output/line_one_value.png")
+ end
+
+ def test_one_value_array
+ g = Gruff::Line.new
+ g.title = "One Value in an Array"
+ g.labels = {
+ 0 => '1',
+ 1 => '2'
+ }
+ g.data('one', [1])
+
+ g.write("test/output/line_one_value_array.png")
+ end
+
+
+ def test_should_not_hang_with_0_0_100
+ g = Gruff::Line.new(320)
+ g.title = "Hang Value Graph Test"
+ g.data('test', [0,0,100])
+
+ g.write("test/output/line_hang_value.png")
+ end
+
+ # TODO
+ # def test_fix_crash
+ # g = Gruff::Line.new(370)
+ # g.title = "Crash Test"
+ # g.data "ichi", [5]
+ # g.data "ni", [0]
+ # g.data "san", [0]
+ # g.data "shi", [0]
+ # g.write("test/output/line_crash_fix_test.png")
+ # end
+
+
+ def test_line_small_values
+ @datasets = [
+ [:small, [0.1, 0.14356, 0.0, 0.5674839, 0.456]],
+ [:small2, [0.2, 0.3, 0.1, 0.05, 0.9]]
+ ]
+
+ g = Gruff::Line.new
+ g.title = "Small Values Line Graph Test"
+ @datasets.each do |data|
+ g.data(data[0], data[1])
+ end
+ g.write("test/output/line_small.png")
+
+ g = Gruff::Line.new(400)
+ g.title = "Small Values Line Graph Test 400px"
+ @datasets.each do |data|
+ g.data(data[0], data[1])
+ end
+ g.write("test/output/line_small_small.png")
+ end
+
+ def test_line_starts_with_zero
+ @datasets = [
+ [:first0, [0, 5, 10, 8, 18]],
+ [:normal, [1, 2, 3, 4, 5]]
+ ]
+
+ g = Gruff::Line.new
+ g.title = "Small Values Line Graph Test"
+ @datasets.each do |data|
+ g.data(data[0], data[1])
+ end
+ g.write("test/output/line_small_zero.png")
+
+ g = Gruff::Line.new(400)
+ g.title = "Small Values Line Graph Test 400px"
+ @datasets.each do |data|
+ g.data(data[0], data[1])
+ end
+ g.write("test/output/line_small_small_zero.png")
+ end
+
+
+ def test_line_large_values
+ @datasets = [
+ [:large, [100_005, 35_000, 28_000, 27_000]],
+ [:large2, [35_000, 28_000, 27_000, 100_005]],
+ [:large3, [28_000, 27_000, 100_005, 35_000]],
+ [:large4, [1_238, 39_092, 27_938, 48_876]]
+ ]
+
+ g = Gruff::Line.new
+ g.title = "Very Large Values Line Graph Test"
+ g.baseline_value = 50_000
+ g.baseline_color = 'green'
+ @datasets.each do |data|
+ g.data(data[0], data[1])
+ end
+
+ g.write("test/output/line_large.png")
+ end
+
+ # def test_long_title
+ #
+ # end
+ #
+ # def test_add_colors
+ #
+ # end
+ #
+ # def test_request_too_many_colors
+ #
+ # end
+ #
+ # def test_add_data
+ #
+ # end
+
+ def test_many_datapoints
+ g = Gruff::Line.new
+ g.title = "Many Multi-Line Graph Test"
+ g.labels = {
+ 0 => 'June',
+ 10 => 'July',
+ 30 => 'August',
+ 50 => 'September',
+ }
+ g.data('many points', (0..50).collect {|i| rand(100) })
+ g.x_axis_label = "Months"
+
+ # Default theme
+ g.write("test/output/line_many.png")
+ end
+
+
+ def test_similar_high_end_values
+ @dataset = %w(29.43 29.459 29.498 29.53 29.548 29.589 29.619 29.66 29.689 29.849 29.878 29.74 29.769 29.79 29.808 29.828).collect {|i| i.to_f}
+
+ g = Gruff::Line.new
+ g.title = "Similar High End Values Test"
+ g.data('similar points', @dataset )
+ g.write("test/output/line_similar_high_end_values.png")
+
+ g = Gruff::Line.new
+ g.title = "Similar High End Values With Floor"
+ g.data('similar points', @dataset )
+ g.minimum_value = 0
+ g.y_axis_label = "Barometric Pressure"
+ g.write("test/output/line_similar_high_end_values_with_floor.png")
+ end
+
+ def test_many_lines_graph_small
+ g = Gruff::Line.new(400)
+ g.title = "Many Values Line Test 400px"
+ g.labels = {
+ 0 => '5/6',
+ 10 => '5/15',
+ 20 => '5/24',
+ 30 => '5/30',
+ 40 => '6/4',
+ 50 => '6/16'
+ }
+ %w{jimmy jane philip arthur julie bert}.each do |student_name|
+ g.data(student_name, (0..50).collect { |i| rand 100 })
+ end
+
+ # Default theme
+ g.write("test/output/line_many_lines_small.png")
+ end
+
+ def test_graph_tiny
+ g = Gruff::Line.new(300)
+ g.title = "Tiny Test 300px"
+ g.labels = {
+ 0 => '5/6',
+ 10 => '5/15',
+ 20 => '5/24',
+ 30 => '5/30',
+ 40 => '6/4',
+ 50 => '6/16'
+ }
+ %w{jimmy jane philip arthur julie bert}.each do |student_name|
+ g.data(student_name, (0..50).collect { |i| rand 100 })
+ end
+
+ # Default theme
+ g.write("test/output/line_tiny.png")
+ end
+
+ def test_no_data
+ g = Gruff::Line.new(400)
+ g.title = "No Data"
+ # Default theme
+ g.write("test/output/line_no_data.png")
+
+ g = Gruff::Line.new(400)
+ g.title = "No Data Title"
+ g.no_data_message = 'There is no data'
+ g.write("test/output/line_no_data_msg.png")
+ end
+
+
+ def test_all_zeros
+ g = Gruff::Line.new(400)
+ g.title = "All Zeros"
+
+ g.data(:gus, [0,0,0,0])
+
+ # Default theme
+ g.write("test/output/line_no_data_other.png")
+ end
+
+
+ def test_some_nil_points
+ g = Gruff::Line.new
+ g.title = "Some Nil Points"
+
+ @datasets = [
+ [:data1, [1, 2, 3, nil, 3, 5, 6]],
+ [:data2, [5, nil, nil, nil, nil, nil, 5]],
+ [:data3, [4, nil, 2, 1, 0]],
+ [:data4, [nil, nil, 3, 1, 2]]
+ ]
+
+ @datasets.each do |data|
+ g.data(*data)
+ end
+
+ # Default theme
+ g.write("test/output/line_some_nil_points.png")
+ end
+
+ def test_no_title
+ g = Gruff::Line.new(400)
+ g.labels = @labels
+ @datasets.each do |data|
+ g.data(data[0], data[1])
+ end
+
+ g.write("test/output/line_no_title.png")
+ end
+
+ def test_no_line_markers
+ g = setup_basic_graph(400)
+ g.title = "No Line Markers"
+ g.hide_line_markers = true
+ g.write("test/output/line_no_line_markers.png")
+ end
+
+ def test_no_legend
+ g = setup_basic_graph(400)
+ g.title = "No Legend"
+ g.hide_legend = true
+ g.write("test/output/line_no_legend.png")
+ end
+
+ def test_nothing_but_the_graph
+ g = setup_basic_graph(400)
+ g.title = "THIS TITLE SHOULD NOT DISPLAY!!!"
+ g.hide_line_markers = true
+ g.hide_legend = true
+ g.hide_title = true
+ g.write("test/output/line_nothing_but_the_graph.png")
+ end
+
+ def test_baseline_larger_than_data
+ g = setup_basic_graph(400)
+ g.title = "Baseline Larger Than Data"
+ g.baseline_value = 150
+ g.write("test/output/line_large_baseline.png")
+ end
+
+
+ def test_hide_dots
+ g = setup_basic_graph(400)
+ g.title = "Hide Dots"
+ g.hide_dots = true
+ g.write("test/output/line_hide_dots.png")
+ end
+
+ def test_hide_lines
+ g = setup_basic_graph(400)
+ g.title = "Hide Lines"
+ g.hide_lines = true
+ g.write("test/output/line_hide_lines.png")
+ end
+
+ def test_wide_graph
+ g = setup_basic_graph('800x400')
+ g.title = "Wide Graph"
+ g.write("test/output/line_wide_graph.png")
+
+ g = setup_basic_graph('400x200')
+ g.title = "Wide Graph Small"
+ g.write("test/output/line_wide_graph_small.png")
+ end
+
+ def test_negative
+ g = setup_pos_neg(800)
+ g.write("test/output/line_pos_neg.png")
+
+ g = setup_pos_neg(400)
+ g.title = 'Pos/Neg Line Test Small'
+ g.write("test/output/line_pos_neg_400.png")
+ end
+
+ def test_all_negative
+ g = setup_all_neg(800)
+ g.write("test/output/line_all_neg.png")
+
+ g = setup_all_neg(400)
+ g.title = 'All Neg Line Test Small'
+ g.write("test/output/line_all_neg_400.png")
+ end
+
+ def test_many_numbers
+ g = Gruff::Line.new('400x170')
+ g.title = "Line Test, Many Numbers"
+
+ data = [
+ { :date => '01',
+ :wpm => 0,
+ :errors => 0,
+ :accuracy => 0 },
+ { :date => '02',
+ :wpm => 10,
+ :errors => 2,
+ :accuracy => 80 },
+ { :date => '03',
+ :wpm => 15,
+ :errors => 0,
+ :accuracy => 100 },
+ { :date => '04',
+ :wpm => 16,
+ :errors => 2,
+ :accuracy => 87 },
+ { :date => '05',
+ :wpm => nil,
+ :errors => nil,
+ :accuracy => nil },
+ { :date => '06',
+ :wpm => 18,
+ :errors => 1,
+ :accuracy => 94 },
+ { :date => '07'},
+ { :date => '08' },
+ { :date => '09',
+ :wpm => 21,
+ :errors => 1,
+ :accuracy => 95 },
+ { :date => '10'},
+ { :date => '11'},
+ { :date => '12'},
+ { :date => '13'},
+ { :date => '14'},
+ { :date => '15'},
+ { :date => '16'},
+ { :date => '17'},
+ { :date => '18'},
+ { :date => '19',
+ :wpm => 28,
+ :errors => 5,
+ :accuracy => 82 },
+ { :date => '20'},
+ { :date => '21'},
+ { :date => '22'},
+ { :date => '23'},
+ { :date => '24'},
+ { :date => '25'},
+ { :date => '26'},
+ { :date => '27',
+ :wpm => 37,
+ :errors => 3,
+ :accuracy => 92 },
+ ]
+
+ [:wpm, :errors, :accuracy].each do |field|
+ g.data(field.to_s, data.collect {|d| d[field] })
+ end
+
+ labels = Hash.new
+ data.each_with_index do |d, i|
+ labels[i] = d[:date]
+ end
+ g.labels = labels
+
+ g.write('test/output/line_many_numbers.png')
+ end
+
+ def test_no_hide_line_no_labels
+ g = Gruff::Line.new
+ g.title = "No Hide Line No Labels"
+ @datasets.each do |data|
+ g.data(data[0], data[1])
+ end
+ g.hide_line_markers = false
+ g.write('test/output/line_no_hide.png')
+ end
+
+protected
+
+ # TODO Reset data after each theme
+ def line_graph_with_themes(size=nil)
+ g = Gruff::Line.new(size)
+ g.title = "Multi-Line Graph Test #{size}"
+ g.labels = @labels
+ g.baseline_value = 90
+ @datasets.each do |data|
+ g.data(data[0], data[1])
+ end
+ # Default theme
+ g.write("test/output/line_theme_keynote_#{size}.png")
+
+ g = Gruff::Line.new(size)
+ g.title = "Multi-Line Graph Test #{size}"
+ g.labels = @labels
+ g.baseline_value = 90
+ g.theme_37signals
+ @datasets.each do |data|
+ g.data(data[0], data[1])
+ end
+ g.write("test/output/line_theme_37signals_#{size}.png")
+
+ g = Gruff::Line.new(size)
+ g.title = "Multi-Line Graph Test #{size}"
+ g.labels = @labels
+ g.baseline_value = 90
+ g.theme_rails_keynote
+ @datasets.each do |data|
+ g.data(data[0], data[1])
+ end
+ g.write("test/output/line_theme_rails_keynote_#{size}.png")
+
+ g = Gruff::Line.new(size)
+ g.title = "Multi-Line Graph Test #{size}"
+ g.labels = @labels
+ g.baseline_value = 90
+ g.theme_odeo
+ @datasets.each do |data|
+ g.data(data[0], data[1])
+ end
+ g.write("test/output/line_theme_odeo_#{size}.png")
+ end
+
+ def setup_pos_neg(size=800)
+ g = Gruff::Line.new(size)
+ g.title = "Pos/Neg Line Graph Test"
+ g.labels = {
+ 0 => '5/6',
+ 1 => '5/15',
+ 2 => '5/24',
+ 3 => '5/30',
+ }
+ g.data(:apples, [-1, 0, 4, -4])
+ g.data(:peaches, [10, 8, 6, 3])
+ return g
+ end
+
+
+ def setup_all_neg(size=800)
+ g = Gruff::Line.new(size)
+ g.title = "All Neg Line Graph Test"
+ g.labels = {
+ 0 => '5/6',
+ 1 => '5/15',
+ 2 => '5/24',
+ 3 => '5/30',
+ }
+ g.data(:apples, [-1, -5, -20, -4])
+ g.data(:peaches, [-10, -8, -6, -3])
+ g
+ end
+
+end
diff --git a/vendor/plugins/gruff/test/test_mini_bar.rb b/vendor/plugins/gruff/test/test_mini_bar.rb
new file mode 100644
index 0000000..1850725
--- /dev/null
+++ b/vendor/plugins/gruff/test/test_mini_bar.rb
@@ -0,0 +1,32 @@
+
+require File.dirname(__FILE__) + "/gruff_test_case"
+
+class TestMiniBar < GruffTestCase
+
+ def test_simple_bar
+ setup_single_dataset
+ g = setup_basic_graph(Gruff::Mini::Bar, 200)
+ write_test_file g, 'mini_bar.png'
+ end
+
+ # def test_simple_bar_wide_dataset
+ # setup_wide_dataset
+ # g = setup_basic_graph(Gruff::Mini::Bar, 200)
+ # write_test_file g, 'mini_bar_wide_data.png'
+ # end
+ #
+ # def test_code_sample
+ # g = Gruff::Mini::Bar.new(200)
+ # g.data "Jim", [200, 500, 400]
+ # g.labels = { 0 => 'This Month', 1 => 'Average', 2 => 'Overall'}
+ # g.write "mini_bar_one_color.png"
+ #
+ # g = Gruff::Mini::Bar.new(200)
+ # g.data "Car", 200
+ # g.data "Food", 500
+ # g.data "Art", 1000
+ # g.data "Music", 16
+ # g.write "mini_bar_many_colors.png"
+ # end
+
+end
diff --git a/vendor/plugins/gruff/test/test_mini_pie.rb b/vendor/plugins/gruff/test/test_mini_pie.rb
new file mode 100644
index 0000000..87ff58a
--- /dev/null
+++ b/vendor/plugins/gruff/test/test_mini_pie.rb
@@ -0,0 +1,20 @@
+
+require File.dirname(__FILE__) + "/gruff_test_case"
+
+class TestMiniPie < GruffTestCase
+
+ def test_simple_pie
+ g = setup_basic_graph(Gruff::Mini::Pie, 200)
+ write_test_file g, 'mini_pie.png'
+ end
+
+ # def test_code_sample
+ # g = Gruff::Mini::Pie.new(200)
+ # g.data "Car", 200
+ # g.data "Food", 500
+ # g.data "Art", 1000
+ # g.data "Music", 16
+ # g.write "mini_pie.png"
+ # end
+
+end
diff --git a/vendor/plugins/gruff/test/test_mini_side_bar.rb b/vendor/plugins/gruff/test/test_mini_side_bar.rb
new file mode 100644
index 0000000..4145380
--- /dev/null
+++ b/vendor/plugins/gruff/test/test_mini_side_bar.rb
@@ -0,0 +1,37 @@
+
+require File.dirname(__FILE__) + "/gruff_test_case"
+
+class TestMiniSideBar < GruffTestCase
+
+ def test_one_color
+ # Use a single data set
+ @datasets = [
+ [:Jimmy, [25, 36, 86, 39]]
+ ]
+ @labels = {
+ 0 => 'Auto',
+ 1 => 'Entertainment',
+ 2 => 'Food',
+ 3 => 'Bus'
+ }
+
+ g = setup_basic_graph(Gruff::Mini::SideBar, 200)
+ write_test_file g, 'mini_side_bar.png'
+ end
+
+ def test_multi_color
+ # @datasets = [
+ # [:Jimmy, [25, 36, 86, 39]]
+ # ]
+ # @labels = {
+ # 0 => 'Auto',
+ # 1 => 'Entertainment',
+ # 2 => 'Food',
+ # 3 => 'Bus'
+ # }
+
+ g = setup_basic_graph(Gruff::Mini::SideBar, 200)
+ write_test_file g, 'mini_side_bar_multi_color.png'
+ end
+
+end
diff --git a/vendor/plugins/gruff/test/test_net.rb b/vendor/plugins/gruff/test/test_net.rb
new file mode 100644
index 0000000..869149d
--- /dev/null
+++ b/vendor/plugins/gruff/test/test_net.rb
@@ -0,0 +1,230 @@
+#!/usr/bin/ruby
+
+require File.dirname(__FILE__) + "/gruff_test_case"
+
+class TestGruffNet < GruffTestCase
+
+ def setup
+ @datasets = [
+ [:Jimmy, [25, 36, 86, 39, 25, 31, 79, 88]],
+ [:Charles, [80, 54, 67, 54, 68, 70, 90, 95]],
+ [:Julie, [22, 29, 35, 38, 36, 40, 46, 57]],
+ [:Jane, [95, 95, 95, 90, 85, 80, 88, 100]],
+ [:Philip, [90, 34, 23, 12, 78, 89, 98, 88]],
+ ["Arthur", [5, 10, 13, 11, 6, 16, 22, 32]],
+ ]
+
+ @sample_labels = {
+ 0 => '5/6',
+ 1 => '5/15',
+ 2 => '5/24',
+ 3 => '5/30',
+ 4 => '6/4',
+ 5 => '6/12',
+ 6 => '6/21',
+ 7 => '6/28',
+ }
+ end
+
+ def test_net_small_values
+ @datasets = [
+ [:small, [0.1, 0.14356, 0.0, 0.5674839, 0.456]],
+ [:small2, [0.2, 0.3, 0.1, 0.05, 0.9]]
+ ]
+
+ g = Gruff::Net.new
+ g.title = "Small Values Net Graph Test"
+ @datasets.each do |data|
+ g.data(data[0], data[1])
+ end
+ g.write("test/output/net_small.png")
+
+ g = Gruff::Net.new(400)
+ g.title = "Small Values Net Graph Test 400px"
+ @datasets.each do |data|
+ g.data(data[0], data[1])
+ end
+ g.write("test/output/net_small_small.png")
+ end
+
+ def test_net_starts_with_zero
+ @datasets = [
+ [:first0, [0, 5, 10, 8, 18]],
+ [:normal, [1, 2, 3, 4, 5]]
+ ]
+
+ g = Gruff::Net.new
+ g.title = "Small Values Net Graph Test"
+ @datasets.each do |data|
+ g.data(data[0], data[1])
+ end
+ g.write("test/output/net_small_zero.png")
+
+ g = Gruff::Net.new(400)
+ g.title = "Small Values Net Graph Test 400px"
+ @datasets.each do |data|
+ g.data(data[0], data[1])
+ end
+ g.write("test/output/net_small_small_zero.png")
+ end
+
+
+ def test_net_large_values
+ @datasets = [
+ [:large, [100_005, 35_000, 28_000, 27_000]],
+ [:large2, [35_000, 28_000, 27_000, 100_005]],
+ [:large3, [28_000, 27_000, 100_005, 35_000]],
+ [:large4, [1_238, 39_092, 27_938, 48_876]]
+ ]
+
+ g = Gruff::Net.new
+ g.title = "Very Large Values Net Graph Test"
+ @datasets.each do |data|
+ g.data(data[0], data[1])
+ end
+
+ g.write("test/output/net_large.png")
+ end
+
+ def test_many_datapoints
+ g = Gruff::Net.new
+ g.title = "Many Multi-Net Graph Test"
+ g.labels = {
+ 0 => 'June',
+ 10 => 'July',
+ 30 => 'August',
+ 50 => 'September',
+ }
+ g.data('many points', (0..50).collect {|i| rand(100) })
+
+ # Default theme
+ g.write("test/output/net_many.png")
+ end
+
+
+ def test_similar_high_end_values
+ g = Gruff::Net.new
+ g.title = "Similar High End Values Test"
+ g.data('similar points', %w(29.43 29.459 29.498 29.53 29.548 29.589 29.619 29.66 29.689 29.849 29.878 29.74 29.769 29.79 29.808 29.828).collect {|i| i.to_f} )
+
+ # Default theme
+ g.write("test/output/net_similar_high_end_values.png")
+ end
+
+ def test_many_nets_graph_small
+ g = Gruff::Net.new(400)
+ g.title = "Many Values Net Test 400px"
+ g.labels = {
+ 0 => '5/6',
+ 10 => '5/15',
+ 20 => '5/24',
+ 30 => '5/30',
+ 40 => '6/4',
+ 50 => '6/16'
+ }
+ %w{jimmy jane philip arthur julie bert}.each do |student_name|
+ g.data(student_name, (0..50).collect { |i| rand 100 })
+ end
+
+ # Default theme
+ g.write("test/output/net_many_nets_small.png")
+ end
+
+ def test_dots_graph_tiny
+ g = Gruff::Net.new(300)
+ g.title = "Dots Test 300px"
+ g.labels = {
+ 0 => '5/6',
+ 10 => '5/15',
+ 20 => '5/24',
+ 30 => '5/30',
+ 40 => '6/4',
+ 50 => '6/16'
+ }
+ %w{jimmy jane philip arthur julie bert}.each do |student_name|
+ g.data(student_name, (0..50).collect { |i| rand 100 })
+ end
+
+ # Default theme
+ g.write("test/output/net_dots_tiny.png")
+ end
+
+ def test_no_data
+ g = Gruff::Net.new(400)
+ g.title = "No Data"
+ # Default theme
+ g.write("test/output/net_no_data.png")
+
+ g = Gruff::Net.new(400)
+ g.title = "No Data Title"
+ g.no_data_message = 'There is no data'
+ g.write("test/output/net_no_data_msg.png")
+ end
+
+
+ def test_all_zeros
+ g = Gruff::Net.new(400)
+ g.title = "All Zeros"
+
+ g.data(:gus, [0,0,0,0])
+
+ # Default theme
+ g.write("test/output/net_no_data_other.png")
+ end
+
+ def test_no_title
+ g = Gruff::Net.new(400)
+ g.labels = @sample_labels
+ @datasets.each do |data|
+ g.data(data[0], data[1])
+ end
+
+ g.write("test/output/net_no_title.png")
+ end
+
+ def test_no_net_markers
+ g = setup_basic_graph(400)
+ g.title = "No Net Markers"
+ g.hide_line_markers = true
+ g.write("test/output/net_no_net_markers.png")
+ end
+
+ def test_no_legend
+ g = setup_basic_graph(400)
+ g.title = "No Legend"
+ g.hide_legend = true
+ g.write("test/output/net_no_legend.png")
+ end
+
+ def test_nothing_but_the_graph
+ g = setup_basic_graph(400)
+ g.title = "THIS TITLE SHOULD NOT DISPLAY!!!"
+ g.hide_line_markers = true
+ g.hide_legend = true
+ g.hide_title = true
+ g.write("test/output/net_nothing_but_the_graph.png")
+ end
+
+ def test_wide_graph
+ g = setup_basic_graph('800x400')
+ g.title = "Wide Graph"
+ g.write("test/output/net_wide_graph.png")
+
+ g = setup_basic_graph('400x200')
+ g.title = "Wide Graph Small"
+ g.write("test/output/net_wide_graph_small.png")
+ end
+
+protected
+
+ def setup_basic_graph(size=800)
+ g = Gruff::Net.new(size)
+ g.title = "My Graph Title"
+ g.labels = @sample_labels
+ @datasets.each do |data|
+ g.data(data[0], data[1])
+ end
+ return g
+ end
+
+end
diff --git a/vendor/plugins/gruff/test/test_photo.rb b/vendor/plugins/gruff/test/test_photo.rb
new file mode 100644
index 0000000..32415aa
--- /dev/null
+++ b/vendor/plugins/gruff/test/test_photo.rb
@@ -0,0 +1,41 @@
+#!/usr/bin/ruby
+
+require File.dirname(__FILE__) + "/gruff_test_case"
+
+class TestGruffPhotoBar < GruffTestCase
+
+# def setup
+# @datasets = [
+# [:Jimmy, [25, 36, 86, 39]],
+# [:Charles, [80, 54, 67, 54]],
+# # [:Charity, [0, nil, 100, 90]],
+# ]
+# end
+#
+# def test_bar_graph
+# bar_graph_sized
+# bar_graph_sized(400)
+# end
+#
+#
+# protected
+#
+# def bar_graph_sized(size=800)
+# g = Gruff::PhotoBar.new(size)
+# g.title = "Photo Bar Graph Test #{size}px"
+# g.labels = {
+# 0 => '5/6',
+# 1 => '5/15',
+# 2 => '5/24',
+# 3 => '5/30',
+# }
+# @datasets.each do |data|
+# g.data(*data)
+# end
+#
+# g.theme = 'plastik'
+#
+# g.write("test/output/photo_plastik_#{size}.png")
+# end
+
+end
diff --git a/vendor/plugins/gruff/test/test_pie.rb b/vendor/plugins/gruff/test/test_pie.rb
new file mode 100644
index 0000000..4901e2a
--- /dev/null
+++ b/vendor/plugins/gruff/test/test_pie.rb
@@ -0,0 +1,154 @@
+#!/usr/bin/ruby
+
+require File.dirname(__FILE__) + "/gruff_test_case"
+
+class TestGruffPie < GruffTestCase
+
+ def setup
+ @datasets = [
+ [:Darren, [25]],
+ [:Chris, [80]],
+ [:Egbert, [22]],
+ [:Adam, [95]],
+ [:Bill, [90]],
+ ["Frank", [5]],
+ ["Zero", [0]],
+ ]
+ end
+
+ def test_pie_graph
+ g = Gruff::Pie.new
+ g.title = "Visual Pie Graph Test"
+ @datasets.each do |data|
+ g.data(data[0], data[1])
+ end
+
+ # Default theme
+ g.write("test/output/pie_keynote.png")
+ end
+
+ def test_pie_graph_greyscale
+ g = Gruff::Pie.new
+ g.title = "Greyscale Pie Graph Test"
+ g.theme_greyscale
+ @datasets.each do |data|
+ g.data(data[0], data[1])
+ end
+
+ # Default theme
+ g.write("test/output/pie_grey.png")
+ end
+
+ def test_pie_graph_pastel
+ g = Gruff::Pie.new
+ g.theme_pastel
+ g.title = "Pastel Pie Graph Test"
+ @datasets.each do |data|
+ g.data(data[0], data[1])
+ end
+
+ # Default theme
+ g.write("test/output/pie_pastel.png")
+ end
+
+
+ def test_pie_graph_small
+ g = Gruff::Pie.new(400)
+ g.title = "Visual Pie Graph Test Small"
+ @datasets.each do |data|
+ g.data(data[0], data[1])
+ end
+
+ # Default theme
+ g.write("test/output/pie_keynote_small.png")
+ end
+
+ def test_pie_graph_nearly_equal
+ g = Gruff::Pie.new
+ g.title = "Pie Graph Nearly Equal"
+
+ g.data(:Blake, [41])
+ g.data(:Aaron, [42])
+# g.data(:Grouch, [40])
+# g.data(:Snuffleupagus, [43])
+
+ g.write("test/output/pie_nearly_equal.png")
+ end
+
+ def test_pie_graph_equal
+ g = Gruff::Pie.new
+ g.title = "Pie Graph Equal"
+
+ g.data(:Bert, [41])
+ g.data(:Adam, [41])
+
+ g.write("test/output/pie_equal.png")
+ end
+
+ def test_pie_graph_zero
+ g = Gruff::Pie.new
+ g.title = "Pie Graph One Zero"
+
+ g.data(:Bert, [0])
+ g.data(:Adam, [1])
+
+ g.write("test/output/pie_zero.png")
+ end
+
+
+ def test_pie_graph_one_val
+ g = Gruff::Pie.new
+ g.title = "Pie Graph One Val"
+
+ g.data(:Bert, 53)
+ g.data(:Adam, 29)
+
+ g.write("test/output/pie_one_val.png")
+ end
+
+
+ def test_wide
+ g = setup_basic_graph('800x400')
+ g.title = "Wide Pie"
+ g.write("test/output/pie_wide.png")
+ end
+
+ def test_label_size
+ g = setup_basic_graph()
+ g.title = "Pie With Small Legend"
+ g.legend_font_size = 10
+ g.write("test/output/pie_legend.png")
+
+ g = setup_basic_graph(400)
+ g.title = "Small Pie With Small Legend"
+ g.legend_font_size = 10
+ g.write("test/output/pie_legend_small.png")
+ end
+
+
+ def test_tiny_simple_pie
+ @datasets = (1..5).map {|n| ['Auto', [rand(100)]]}
+
+ g = setup_basic_graph 200
+ g.hide_legend = true
+ g.hide_title = true
+ g.hide_line_numbers = true
+
+ g.marker_font_size = 40.0
+ g.minimum_value = 0.0
+
+ write_test_file g, "pie_simple.png"
+ end
+
+protected
+
+ def setup_basic_graph(size=800)
+ g = Gruff::Pie.new(size)
+ g.title = "My Graph Title"
+ @datasets.each do |data|
+ g.data(data[0], data[1])
+ end
+ return g
+ end
+
+end
diff --git a/vendor/plugins/gruff/test/test_scene.rb b/vendor/plugins/gruff/test/test_scene.rb
new file mode 100644
index 0000000..7603d29
--- /dev/null
+++ b/vendor/plugins/gruff/test/test_scene.rb
@@ -0,0 +1,100 @@
+#!/usr/bin/ruby
+
+require File.dirname(__FILE__) + "/gruff_test_case"
+require 'yaml'
+
+class LayerStub < Gruff::Layer; attr_reader :base_dir, :filenames, :selected_filename; end
+
+class TestGruffScene < GruffTestCase
+
+ def test_hazy
+ g = setup_scene
+ g.weather = "cloudy"
+ g.haze = true
+ g.time = Time.mktime(2006, 7, 4, 4, 35)
+ g.write "test/output/scene_hazy_night.png"
+ end
+
+ def test_stormy_night
+ g = setup_scene
+ g.weather = "stormy"
+ g.time = Time.mktime(2006, 7, 4, 0, 0)
+ g.write "test/output/scene_stormy_night.png"
+ end
+
+
+ def test_not_hazy
+ g = setup_scene
+ g.weather = "cloudy"
+ g.haze = false
+ g.time = Time.mktime(2006, 7, 4, 6, 00)
+ g.write "test/output/scene_not_hazy_day.png"
+ end
+
+ def test_partly_cloudy
+ g = setup_scene
+ g.weather = "partly cloudy"
+ g.haze = false
+ g.time = Time.mktime(2006, 7, 4, 13, 00)
+ g.write "test/output/scene_partly_cloudy_day.png"
+ end
+
+
+ def test_stormy_day
+ g = setup_scene
+ g.weather = "stormy"
+ g.haze = false
+ g.time = Time.mktime(2006, 7, 4, 8, 00)
+ g.write "test/output/scene_stormy_day.png"
+ end
+
+
+ def test_layer
+ l = LayerStub.new(File.expand_path("../assets/city_scene", File.dirname(__FILE__)), "clouds")
+ assert_equal %w(cloudy.png partly_cloudy.png stormy.png), l.filenames
+
+ l = LayerStub.new(File.expand_path("../assets/city_scene", File.dirname(__FILE__)), "grass")
+ assert_equal 'default.png', l.selected_filename
+
+ l = LayerStub.new(File.expand_path("../assets/city_scene", File.dirname(__FILE__)), "sky")
+ l.update Time.mktime(2006, 7, 4, 12, 35) # 12:35, July 4, 2006
+ assert_equal '1200.png', l.selected_filename
+
+ l = LayerStub.new(File.expand_path("../assets/city_scene", File.dirname(__FILE__)), "sky")
+ l.update Time.mktime(2006, 7, 4, 0, 0) # 00:00, July 4, 2006
+ assert_equal '0000.png', l.selected_filename
+
+ l = LayerStub.new(File.expand_path("../assets/city_scene", File.dirname(__FILE__)), "sky")
+ l.update Time.mktime(2006, 7, 4, 23, 35) # 23:35, July 4, 2006
+ assert_equal '2000.png', l.selected_filename
+
+ l = LayerStub.new(File.expand_path("../assets/city_scene", File.dirname(__FILE__)), "sky")
+ l.update Time.mktime(2006, 7, 4, 0, 1) # 00:01, July 4, 2006
+ assert_equal '0000.png', l.selected_filename
+
+ l = LayerStub.new(File.expand_path("../assets/city_scene", File.dirname(__FILE__)), "sky")
+ l.update Time.mktime(2006, 7, 4, 2, 0) # 02:00, July 4, 2006
+ assert_equal '0200.png', l.selected_filename
+
+ l = LayerStub.new(File.expand_path("../assets/city_scene", File.dirname(__FILE__)), "sky")
+ l.update Time.mktime(2006, 7, 4, 4, 00) # 04:00, July 4, 2006
+ assert_equal '0400.png', l.selected_filename
+
+ # TODO Need number_sample folder
+ # l = LayerStub.new(File.expand_path("../assets/city_scene", File.dirname(__FILE__)), "number_sample")
+ # assert_equal %w(1.png 2.png default.png), l.filenames
+ # l.update 3
+ # assert_equal 'default.png', l.selected_filename
+ end
+
+private
+
+ def setup_scene
+ g = Gruff::Scene.new("500x100", File.expand_path("../assets/city_scene", File.dirname(__FILE__)) )
+ g.layers = %w(background haze sky clouds)
+ g.weather_group = %w(clouds)
+ g.time_group = %w(background sky)
+ g
+ end
+
+end
diff --git a/vendor/plugins/gruff/test/test_side_bar.rb b/vendor/plugins/gruff/test/test_side_bar.rb
new file mode 100644
index 0000000..7d2ea3d
--- /dev/null
+++ b/vendor/plugins/gruff/test/test_side_bar.rb
@@ -0,0 +1,12 @@
+
+require File.dirname(__FILE__) + "/gruff_test_case"
+
+class TestGruffSideBar < GruffTestCase
+
+ def test_bar_graph
+ g = setup_basic_graph(Gruff::SideBar, 800)
+ write_test_file g, 'side_bar.png'
+ end
+
+end
+
diff --git a/vendor/plugins/gruff/test/test_sidestacked_bar.rb b/vendor/plugins/gruff/test/test_sidestacked_bar.rb
new file mode 100644
index 0000000..5bcc670
--- /dev/null
+++ b/vendor/plugins/gruff/test/test_sidestacked_bar.rb
@@ -0,0 +1,89 @@
+#!/usr/bin/ruby
+
+require File.dirname(__FILE__) + "/gruff_test_case"
+
+class TestGruffSideStackedBar < GruffTestCase
+
+ def setup
+ @datasets = [
+ [:Jimmy, [25, 36, 86, 39]],
+ [:Charles, [80, 54, 67, 54]],
+ [:Julie, [22, 29, 35, 38]],
+ #[:Jane, [95, 95, 95, 90, 85, 80, 88, 100]],
+ #[:Philip, [90, 34, 23, 12, 78, 89, 98, 88]],
+ #["Arthur", [5, 10, 13, 11, 6, 16, 22, 32]],
+ ]
+ @sample_labels = {
+ 0 => '5/6',
+ 1 => '5/15',
+ 2 => '5/24'
+ }
+
+ end
+
+ def test_bar_graph
+ g = Gruff::SideStackedBar.new
+ g.title = "Visual Stacked Bar Graph Test"
+ g.labels = {
+ 0 => '5/6',
+ 1 => '5/15',
+ 2 => '5/24',
+ 3 => '5/30',
+ }
+ @datasets.each do |data|
+ g.data(data[0], data[1])
+ end
+ g.write "test/output/side_stacked_bar_keynote.png"
+ end
+
+
+ def test_bar_graph_small
+ g = Gruff::SideStackedBar.new(400)
+ g.title = "Visual Stacked Bar Graph Test"
+ g.labels = {
+ 0 => '5/6',
+ 1 => '5/15',
+ 2 => '5/24',
+ 3 => '5/30',
+ }
+ @datasets.each do |data|
+ g.data(data[0], data[1])
+ end
+ g.write "test/output/side_stacked_bar_keynote_small.png"
+ end
+
+ def test_wide
+ g = setup_basic_graph('800x400')
+ g.title = "Wide SSBar"
+ g.write "test/output/side_stacked_bar_wide.png"
+ end
+
+ def test_should_space_long_left_labels_appropriately
+ g = Gruff::SideStackedBar.new
+ g.title = "Stacked Bar Long Label"
+ g.labels = {
+ 0 => 'September',
+ 1 => 'Oct',
+ 2 => 'Nov',
+ 3 => 'Dec',
+ }
+ @datasets.each do |data|
+ g.data(data[0], data[1])
+ end
+ g.write "test/output/side_stacked_bar_long_label.png"
+ end
+
+protected
+
+ def setup_basic_graph(size=800)
+ g = Gruff::SideStackedBar.new(size)
+ g.title = "My Graph Title"
+ g.labels = @sample_labels
+ @datasets.each do |data|
+ g.data(data[0], data[1])
+ end
+ return g
+ end
+
+end
+
diff --git a/vendor/plugins/gruff/test/test_spider.rb b/vendor/plugins/gruff/test/test_spider.rb
new file mode 100644
index 0000000..99dbb2d
--- /dev/null
+++ b/vendor/plugins/gruff/test/test_spider.rb
@@ -0,0 +1,216 @@
+#!/usr/bin/ruby
+
+require File.dirname(__FILE__) + "/gruff_test_case"
+
+class TestGruffSpider < GruffTestCase
+
+ def setup
+ @datasets = [
+ [:Strength, [10]],
+ [:Dexterity, [16]],
+ [:Constitution, [12]],
+ [:Intelligence, [12]],
+ [:Wisdom, [10]],
+ ["Charisma", [16]],
+ ]
+
+# @datasets = [
+# [:Darren, [25]],
+# [:Chris, [80]],
+# [:Egbert, [22]],
+# [:Adam, [95]],
+# [:Bill, [90]],
+# ["Frank", [5]],
+# ["Zero", [0]],
+# ]
+ end
+
+ def test_spider_graph
+ g = Gruff::Spider.new(20)
+ g.title = "Spider Graph Test"
+ @datasets.each do |data|
+ g.data(data[0], data[1])
+ end
+
+ # Default theme
+ g.write("test/output/spider_keynote.png")
+ end
+
+ def test_pie_graph_small
+ g = Gruff::Spider.new(20, 400)
+ g.title = "Visual Spider Graph Test Small"
+ @datasets.each do |data|
+ g.data(data[0], data[1])
+ end
+
+ # Default theme
+ g.write("test/output/spider_small.png")
+ end
+
+ def test_spider_graph_nearly_equal
+ g = Gruff::Spider.new(50)
+ g.title = "Spider Graph Nearly Equal"
+
+ g.data(:Blake, [41])
+ g.data(:Aaron, [42])
+ g.data(:Grouch, [40])
+# g.data(:Snuffleupagus, [43])
+
+ g.write("test/output/spider_nearly_equal.png")
+ end
+
+ def test_pie_graph_equal
+ g = Gruff::Spider.new(50)
+ g.title = "Spider Graph Equal"
+
+ g.data(:Bert, [41])
+ g.data(:Adam, [41])
+ g.data(:Joe, [41])
+
+ g.write("test/output/spider_equal.png")
+ end
+
+ def test_pie_graph_zero
+ g = Gruff::Spider.new(2)
+ g.title = "Pie Graph Two One Zero"
+
+ g.data(:Bert, [0])
+ g.data(:Adam, [1])
+ g.data(:Sam, [2])
+
+ g.write("test/output/spider_zero.png")
+ end
+
+ def test_wide
+ g = setup_basic_graph('800x400')
+ g.title = "Wide spider"
+ g.write("test/output/spider_wide.png")
+ end
+
+ def test_label_size
+ g = setup_basic_graph()
+ g.title = "Spider With Small Legend"
+ g.legend_font_size = 10
+ g.write("test/output/spider_legend.png")
+
+ g = setup_basic_graph(400)
+ g.title = "Small spider With Small Legend"
+ g.legend_font_size = 10
+ g.write("test/output/spider_legend_small.png")
+ end
+
+ def test_theme_37signals
+ g = Gruff::Spider.new(20)
+ g.title = "Spider Graph Test"
+ @datasets.each do |data|
+ g.data(data[0], data[1])
+ end
+
+ g.theme_37signals
+
+ # Default theme
+ g.write("test/output/spider_37signals.png")
+ end
+
+ def test_no_axes
+ g = Gruff::Spider.new(20)
+ g.title = "Look ma, no axes"
+ g.hide_axes = true
+ @datasets.each do |data|
+ g.data(data[0], data[1])
+ end
+ g.write("test/output/spider_no_axes.png")
+
+ end
+
+ def test_no_print
+ g = Gruff::Spider.new(20)
+ g.title = "Should not print"
+ g.hide_text = true
+ @datasets.each do |data|
+ g.data(data[0], data[1])
+ end
+ g.write("test/output/spider_no_print.png")
+ end
+
+ def test_transparency
+ g = Gruff::Spider.new(20)
+ g.title = "Transparent background"
+ g.hide_text = true
+ g.transparent_background = true
+ g.hide_axes = true
+ @datasets.each do |data|
+ g.data(data[0], data[1])
+ end
+ g.write("test/output/spider_no_background.png")
+ end
+
+ def test_overlay
+ g = Gruff::Spider.new(20)
+ g.title = "George (blue) vs Sarah (white)"
+ @datasets.each do |data|
+ g.data(data[0], data[1])
+ end
+ g.write("test/output/spider_overlay_1.png")
+
+ g = Gruff::Spider.new(20)
+ g.title = "Transparent background"
+ g.hide_text = true
+ g.hide_axes = true
+ g.transparent_background = true
+ @datasets = [
+ [:Strength, [18]],
+ [:Dexterity, [10]],
+ [:Constitution, [18]],
+ [:Intelligence, [8]],
+ [:Wisdom, [14]],
+ ["Charisma", [4]],
+ ]
+ @datasets.each do |data|
+ g.data(data[0], data[1])
+ end
+ g.marker_color = "#4F6EFF"
+ g.write("test/output/spider_overlay_2.png")
+ end
+
+ def test_lots_of_data
+ g = Gruff::Spider.new(10)
+ @datasets = [[:a, [1]], [:b, [5]], [:c, [3]], [:d, [9]], [:e, [4]],
+ [:f, [7]], [:g, [0]], [:h, [4]], [:i, [6]], [:j, [0]],
+ [:k, [4]], [:l, [8]]]
+
+ @datasets.each do |data|
+ g.data(data[0], data[1])
+ end
+
+ g.title = "Sample Data"
+ g.write("test/output/spider_lots_of_data.png")
+ end
+
+ def test_lots_of_data_with_large_names
+ g = Gruff::Spider.new(10)
+ @datasets = [[:anteaters, [1]], [:bulls, [5]], [:cats, [3]], [:dogs, [9]], [:elephants, [4]],
+ [:frogs, [7]], [:giraffes, [0]], [:hamsters, [4]], [:iguanas, [6]],
+ [:jaguar, [0]], [:kangaroo, [4]], [:locust, [8]]]
+
+ @datasets.each do |data|
+ g.data(data[0], data[1])
+ end
+
+ g.title = "Zoo Inventory"
+ g.write("test/output/spider_lots_of_data_normal_names.png")
+ end
+
+
+protected
+
+ def setup_basic_graph(size=800, max = 20)
+ g = Gruff::Spider.new(max, size)
+ g.title = "My Graph Title"
+ @datasets.each do |data|
+ g.data(data[0], data[1])
+ end
+ return g
+ end
+
+end
diff --git a/vendor/plugins/gruff/test/test_stacked_bar.rb b/vendor/plugins/gruff/test/test_stacked_bar.rb
new file mode 100644
index 0000000..ab943d6
--- /dev/null
+++ b/vendor/plugins/gruff/test/test_stacked_bar.rb
@@ -0,0 +1,52 @@
+#!/usr/bin/ruby
+
+require File.dirname(__FILE__) + "/gruff_test_case"
+
+class TestGruffStackedBar < GruffTestCase
+
+ def setup
+ @datasets = [
+ [:Jimmy, [25, 36, 86, 39]],
+ [:Charles, [80, 54, 67, 54]],
+ [:Julie, [22, 29, 35, 38]],
+ ]
+ @sample_labels = {
+ 0 => '5/6',
+ 1 => '5/15',
+ 2 => '5/24'
+ }
+
+ end
+
+ def test_bar_graph
+ g = Gruff::StackedBar.new
+ g.title = "Visual Stacked Bar Graph Test"
+ g.labels = {
+ 0 => '5/6',
+ 1 => '5/15',
+ 2 => '5/24',
+ 3 => '5/30',
+ }
+ @datasets.each do |data|
+ g.data(data[0], data[1])
+ end
+ g.write "test/output/stacked_bar_keynote.png"
+ end
+
+
+ def test_bar_graph_small
+ g = Gruff::StackedBar.new(400)
+ g.title = "Visual Stacked Bar Graph Test"
+ g.labels = {
+ 0 => '5/6',
+ 1 => '5/15',
+ 2 => '5/24',
+ 3 => '5/30',
+ }
+ @datasets.each do |data|
+ g.data(data[0], data[1])
+ end
+ g.write "test/output/stacked_bar_keynote_small.png"
+ end
+
+end
diff --git a/vendor/plugins/ultrasphinx/lib/ultrasphinx/ultrasphinx.rb b/vendor/plugins/ultrasphinx/lib/ultrasphinx/ultrasphinx.rb
index 767d65f..92c85eb 100644
--- a/vendor/plugins/ultrasphinx/lib/ultrasphinx/ultrasphinx.rb
+++ b/vendor/plugins/ultrasphinx/lib/ultrasphinx/ultrasphinx.rb
@@ -98,6 +98,11 @@ sql_query_pre = ) + SQL_FUNCTIONS['postgresql']['stored_procedures'].values.join
ADAPTER = ActiveRecord::Base.connection.instance_variable_get("@config")[:adapter] rescue 'mysql'
+ # Create language plpgsql
+ if ADAPTER == "postgresql"
+ ActiveRecord::Base.connection.execute("CREATE LANGUAGE plpgsql;") rescue nil
+ end
+
# Install the stored procedures.
# XXX This shouldn't be done at every index, say the Postgres people.
SQL_FUNCTIONS[ADAPTER]['stored_procedures'].each do |key, value|