Sha256: d3d0b218dcb89f10c66bf67b181394a22db2c1f24a9f0d8c61379e044b053588

Contents?: true

Size: 1.02 KB

Versions: 5

Compression:

Stored size: 1.02 KB

Contents

# frozen_string_literal: true

require 'descriptive_statistics/safe'
require 'fileutils'
require 'launchy'
require 'tilt'

module Attractor
  # base reporter
  class BaseReporter
    extend Forwardable
    attr_accessor :values, :file_prefix
    attr_reader :types
    def_delegator :@watcher, :watch

    def initialize(file_prefix: '', calculators:, open_browser: true)
      @file_prefix = file_prefix
      @calculators = calculators
      @open_browser = open_browser
      @values = @calculators.first.last.calculate
      @suggester = Suggester.new(values)

      @watcher = Watcher.new(file_prefix, lambda do
        report
      end)
    rescue NoMethodError => e
      raise 'There was a problem gathering churn changes'
    end

    def suggestions(quantile)
      @suggestions = @suggester.suggest(quantile)
      @suggestions
    end

    def report
      @suggestions = @suggester.suggest
      @types = Hash[@calculators.map { |calc| [calc.first, calc.last.type] }]
    end

    def render
      'Attractor'
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
attractor-2.0.1 lib/attractor/reporters/base_reporter.rb
attractor-2.0.0 lib/attractor/reporters/base_reporter.rb
attractor-1.2.0 lib/attractor/reporters/base_reporter.rb
attractor-1.1.1 lib/attractor/reporters/base_reporter.rb
attractor-1.1.0 lib/attractor/reporters/base_reporter.rb