Sha256: 679e3659996a8914c8037d7e576ef94bcf787b81f3a1f073e758d66d7079290b
Contents?: true
Size: 1.48 KB
Versions: 1
Compression:
Stored size: 1.48 KB
Contents
# frozen_string_literal: true require 'descriptive_statistics/safe' require 'fileutils' require 'launchy' require 'tilt' module Attractor # base reporter class Reporter extend Forwardable attr_accessor :values def_delegator :@watcher, :watch def initialize(file_prefix: '') @calculator = Calculator.new(file_prefix: file_prefix) @values = @calculator.calculate @suggester = Suggester.new(values) @watcher = Watcher.new(file_prefix, lambda do report end) end def report @suggestions = @suggester.suggest end end # console reporter class ConsoleReporter < Reporter def report super puts 'Calculated churn and complexity' puts puts "file_path#{' ' * 53}complexity churn" puts '-' * 80 puts @values.map(&:to_s) puts puts 'Suggestions for refactorings:' @suggestions.each { |sug| puts sug.file_path } puts end end # HTML reporter class HtmlReporter < Reporter def report super puts 'Generating an HTML report' template = Tilt.new(File.expand_path('../templates/index.html.erb', __dir__)) output = template.render self FileUtils.mkdir_p './attractor_output' File.open('./attractor_output/index.html', 'w') { |file| file.write(output) } puts "Generated HTML report at #{File.expand_path './attractor_output/index.html'}" Launchy.open(File.expand_path './attractor_output/index.html') end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
attractor-0.2.1 | lib/attractor/reporter.rb |