class MetricFu::Grapher

Attributes

output_directory[RW]

Public Class Methods

get_grapher(metric) click to toggle source
# File lib/metric_fu/reporting/graphs/grapher.rb, line 14
def self.get_grapher(metric)
  graphers.find { |grapher|grapher.metric.to_s == metric.to_s }
end
graphers() click to toggle source

@return all subclassed graphers [Array<MetricFu::Grapher>]

# File lib/metric_fu/reporting/graphs/grapher.rb, line 6
def self.graphers
  @graphers
end
inherited(subclass) click to toggle source
# File lib/metric_fu/reporting/graphs/grapher.rb, line 10
def self.inherited(subclass)
  @graphers << subclass
end
new(opts = {}) click to toggle source
# File lib/metric_fu/reporting/graphs/grapher.rb, line 20
def initialize(opts = {})
  self.output_directory = opts[:output_directory]
end

Public Instance Methods

date() click to toggle source
# File lib/metric_fu/reporting/graphs/grapher.rb, line 46
def date
  not_implemented
end
get_metrics(_metrics, _sortable_prefix) click to toggle source
# File lib/metric_fu/reporting/graphs/grapher.rb, line 28
def get_metrics(_metrics, _sortable_prefix)
  not_implemented
end
graph!() click to toggle source
# File lib/metric_fu/reporting/graphs/grapher.rb, line 32
    def graph!
      labels = MultiJson.dump(@labels)
      content = <<-EOS
        var graph_title = '#{title}';
        #{build_data(data)}
        var graph_labels = #{labels};
      EOS
      File.open(File.join(output_directory, "results", output_filename), "w") { |f| f << content }
    end
output_filename() click to toggle source
# File lib/metric_fu/reporting/graphs/grapher.rb, line 50
def output_filename
  not_implemented
end
title() click to toggle source
# File lib/metric_fu/reporting/graphs/grapher.rb, line 42
def title
  not_implemented
end

Private Instance Methods

build_data(data) click to toggle source
# File lib/metric_fu/reporting/graphs/grapher.rb, line 56
def build_data(data)
  "var graph_series = [" << Array(data).map do |label, datum|
    "{name: '#{label}', data: [#{datum}]}"
  end.join(",") << "];"
end
not_implemented() click to toggle source
# File lib/metric_fu/reporting/graphs/grapher.rb, line 62
def not_implemented
  raise "#{__LINE__} in #{__FILE__} from #{caller[0]}"
end