Sha256: d7f04028c46708ae332f9da298a4d1e109214dc0518ff2c0eae890b4be77bb6b

Contents?: true

Size: 1.16 KB

Versions: 28

Compression:

Stored size: 1.16 KB

Contents

module MetricFu

  def self.graph
    @graph ||= Graph.new
  end

  class Graph

    attr_accessor :clazz

    def initialize
      self.clazz = []
    end

    def add(graph_type, graph_engine)
      grapher_name = graph_type.to_s.gsub(/\/(.?)/) { "::#{$1.upcase}" }.gsub(/(?:^|_)(.)/) { $1.upcase } + graph_engine.to_s.capitalize + "Grapher"
      self.clazz.push MetricFu.const_get(grapher_name).new
    end


    def generate
      return if self.clazz.empty?
      puts "Generating graphs"
      Dir[File.join(MetricFu.data_directory, '*.yml')].sort.each do |metric_file|
        puts "Generating graphs for #{metric_file}"
        date_parts = year_month_day_from_filename(metric_file)
        metrics = YAML::load(File.open(metric_file))

        self.clazz.each do |grapher|
          grapher.get_metrics(metrics, "#{date_parts[:m]}/#{date_parts[:d]}")
        end
      end
      self.clazz.each do |grapher|
        grapher.graph!
      end
    end

    private
    def year_month_day_from_filename(path_to_file_with_date)
      date = path_to_file_with_date.match(/\/(\d+).yml$/)[1]
      {:y => date[0..3].to_i, :m => date[4..5].to_i, :d => date[6..7].to_i}
    end
  end
end

Version data entries

28 entries across 28 versions & 4 rubygems

Version Path
metric_fu-4.2.0 lib/metric_fu/metrics/graph.rb
metric_fu-4.1.3 lib/metric_fu/metrics/graph.rb
metric_fu-4.1.2 lib/metric_fu/metrics/graph.rb
metric_fu-4.1.1 lib/metric_fu/metrics/graph.rb
metric_fu-4.1.0 lib/metric_fu/metrics/graph.rb
metric_fu-4.0.0 lib/metric_fu/metrics/graph.rb
metric_fu-3.0.1 lib/metric_fu/metrics/graph.rb
metric_fu-3.0.0 lib/metric_fu/metrics/graph.rb
metric_fu-2.1.4.pre5 lib/metric_fu/metrics/graph.rb
metric_fu-2.1.4.pre4 lib/metric_fu/metrics/graph.rb
metric_fu-2.1.4.pre2 lib/metric_fu/metrics/graph.rb
metric_fu-2.1.4.pre lib/metric_fu/metrics/graph.rb
metric_fu-2.1.3.7.18.1 lib/metrics/graph.rb
metric_fu-2.1.3.7.19 lib/metrics/graph.rb
metric_fu-2.1.3.6 lib/metrics/graph.rb
metric_fu-2.1.3.5 lib/metrics/graph.rb
metric_fu-2.1.3.4 lib/metrics/graph.rb
bf4-metric_fu-2.1.3.4 lib/base/graph.rb
bf4-metric_fu-2.1.3.3 lib/base/graph.rb
bf4-metric_fu-2.1.3.2 lib/base/graph.rb