Sha256: b6a6a19c4756daec4b8b4a4bcca259a0bde0726917e2e4fa57a6acc8fed8d6ba

Contents?: true

Size: 1.01 KB

Versions: 9

Compression:

Stored size: 1.01 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 = metric_file.split('/')[3].split('.')[0]
        y, m, d = date[0..3].to_i, date[4..5].to_i, date[6..7].to_i
        metrics = YAML::load(File.open(metric_file))
        
        self.clazz.each do |grapher|
          grapher.get_metrics(metrics, "#{m}/#{d}")
        end
      end
      self.clazz.each do |grapher|
        grapher.graph!
      end
    end
  end
end

Version data entries

9 entries across 9 versions & 5 rubygems

Version Path
goldstar-metric_fu-1.5.1.2 lib/base/graph.rb
metric_fu-2.0.0 lib/base/graph.rb
goldstar-metric_fu-1.5.1.1 lib/base/graph.rb
metric_fu-1.5.1 lib/base/graph.rb
metric_fu-1.5.0 lib/base/graph.rb
metric_fu-1.4.0 lib/base/graph.rb
devver-metric_fu-1.3.3 lib/base/graph.rb
edouard-metric_fu-1.2.1 lib/base/graph.rb
flyerhzm-metric_fu-1.0.0 lib/base/graph.rb