Sha256: 11763cf005ae861ce4f38bc4b1020b0d701ead991f4c097f0b86aadd05143a34

Contents?: true

Size: 1.19 KB

Versions: 1

Compression:

Stored size: 1.19 KB

Contents

# frozen_string_literal: true

require_relative "checkers/age"
require_relative "checkers/counter"
require_relative "configuration"
require_relative "formatting"
require_relative "options"
require_relative "todo_researcher"

require "forwardable"

module Glyptodont
  # Main class where all the work happens
  class Checker
    DEFAULT_THRESHOLD = 10
    DEFAULT_MAX_AGE_IN_DAYS = 14

    def initialize(args)
      @options = Options.new(args)
      @configuration = Configuration.new(directory)
    end

    def check
      todos = TodoResearcher.new(directory, ignore).research

      checks = [
        Checkers::Counter.new(todos: todos, threshold: threshold),
        Checkers::Age.new(todos: todos, threshold: max_age_in_days)
      ].freeze

      checks.each { |check| puts check.check }

      checks.all?(&:passed?)
    end

    attr_reader :configuration, :options

    extend Forwardable

    def_delegator :@configuration, :ignore
    def_delegators :@options, :directory

    def threshold
      options.threshold || configuration.threshold || DEFAULT_THRESHOLD
    end

    def max_age_in_days
      options.max_age_in_days || configuration.max_age_in_days || DEFAULT_MAX_AGE_IN_DAYS
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
glyptodont-0.2.0 lib/glyptodont/checker.rb