Sha256: 2577ad2a62ca21104deb65f51f60d3f7424affac9198da0fe5936b75e7e3e768

Contents?: true

Size: 885 Bytes

Versions: 2

Compression:

Stored size: 885 Bytes

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
    def_delegator :@watcher, :watch

    def initialize(file_prefix: '', calculators:)
      @file_prefix = file_prefix
      @calculators = calculators
      @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
    end

    def render
      'Attractor'
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
attractor-1.0.1 lib/attractor/reporters/base_reporter.rb
attractor-1.0.0 lib/attractor/reporters/base_reporter.rb