Sha256: 8601123672d15d3d5c10e7ed43ecc483f550a674ec8417e8c07de668376f7c92

Contents?: true

Size: 1011 Bytes

Versions: 4

Compression:

Stored size: 1011 Bytes

Contents

module MetricFu::FlogReporter
  class Generator < MetricFu::Base::Generator
    def generate_report
      flog_hashes = []
      Dir.glob("#{@base_dir}/**/*.txt").each do |filename|
        begin
          page = Base.parse(open(filename, "r") { |f| f.read })
        rescue InvalidFlog
          puts "Invalid flog for #{filename}"
          next
        end

        next unless page

        unless MetricFu::MD5Tracker.file_already_counted?(filename)
          generate_page(filename, page)
        end
        flog_hashes << { :path => File.basename(filename, ".txt") + '.html',
                 :page => page }
      end

      generate_index(flog_hashes)
    end

    def generate_page(filename, page)
      save_html(page.to_html, File.basename(filename, ".txt"))
    end

    # should be dynamically read from the class
    def template_name
      'flog'
    end

    def generate_index(flog_hashes)
      html = ERB.new(File.read(template_file)).result(binding)
      save_html(html)
    end
  end
end

Version data entries

4 entries across 4 versions & 2 rubygems

Version Path
indirect-metric_fu-0.8.2 lib/metric_fu/flog_reporter/generator.rb
p8-metric_fu-0.8.2 lib/metric_fu/flog_reporter/generator.rb
p8-metric_fu-0.8.3 lib/metric_fu/flog_reporter/generator.rb
p8-metric_fu-0.8.4 lib/metric_fu/flog_reporter/generator.rb