Skip to content

Commit

Permalink
Updated gchart engine so that gem is only loaded when necessary
Browse files Browse the repository at this point in the history
  • Loading branch information
cayblood committed Aug 19, 2009
1 parent 62e5bd6 commit a36477a
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 4 deletions.
12 changes: 9 additions & 3 deletions lib/graphs/engines/gchart.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
require 'gchart'

module MetricFu
module GchartGrapher
COLORS = %w{009999 FF7400 A60000 008500 E6399B 344AD7 00B860 D5CCB9}
Expand All @@ -23,6 +21,14 @@ def determine_y_axis_scale(values)

class Grapher
include MetricFu::GchartGrapher

def self.require_graphing_gem
require 'gchart'
rescue LoadError
puts "#"*99 + "\n" +
"If you want to use google charts for graphing, you'll need to install the googlecharts rubygem." +
"\n" + "#"*99
end
end

class FlayGchartGrapher < FlayGrapher
Expand Down Expand Up @@ -57,7 +63,7 @@ def graph!
:filename => File.join(MetricFu.output_directory, 'flog.png'))
end
end

class RcovGchartGrapher < RcovGrapher
def graph!
determine_y_axis_scale(self.rcov_percent)
Expand Down
7 changes: 7 additions & 0 deletions lib/graphs/grapher.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
module MetricFu
class Grapher
def initialize
self.class.require_graphing_gem
end

def self.require_graphing_gem
# to be overridden by charting engines
end
end
end
1 change: 0 additions & 1 deletion lib/templates/awesome/awesome_template.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ def write

# Copy Bluff javascripts to output directory
Dir[File.join(this_directory, '..', 'javascripts', '*')].each do |f|
puts "Copying #{f} to #{File.join(MetricFu.output_directory, File.basename(f))}"
File.copy(f, File.join(MetricFu.output_directory, File.basename(f)))
end

Expand Down

0 comments on commit a36477a

Please sign in to comment.