Sha256: a531c6ae72c0237fa839d03c5fa2e94f2ca7ec8161c5c4af92f4cb1606c24212

Contents?: true

Size: 1.14 KB

Versions: 1

Compression:

Stored size: 1.14 KB

Contents

require "rubycritic/report_generators/base_generator"
require "rubycritic/report_generators/file_generator"
require "rubycritic/report_generators/index_generator"
require "fileutils"

module Rubycritic

  class Reporter
    ASSETS_DIR = File.expand_path("../assets", __FILE__)

    def initialize(source_pathnames, smelly_pathnames)
      @source_pathnames = source_pathnames
      @smelly_pathnames = smelly_pathnames
    end

    def generate_report
      generators.each do |generator|
        FileUtils.mkdir_p(generator.file_directory)
        File.open(generator.file_pathname, "w+") do |file|
          file.write(generator.render)
        end
      end
      FileUtils.cp_r(ASSETS_DIR, BaseGenerator::REPORT_DIR)
      index_generator.file_href
    end

    private

    def generators
      file_generators + [index_generator]
    end

    def index_generator
      @index_generator ||= IndexGenerator.new(file_generators)
    end

    def file_generators
      @file_generators ||= @source_pathnames.map do |file_pathname|
        file_smells = @smelly_pathnames[file_pathname]
        FileGenerator.new(file_pathname, file_smells)
      end
    end
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rubycritic-0.0.7 lib/rubycritic/report_generators/reporter.rb