class Nanoc::Checking::Loader

@api private

Constants

CHECKS_FILENAMES

Public Class Methods

new(config:) click to toggle source
# File lib/nanoc/checking/loader.rb, line 9
def initialize(config:)
  @config = config
end

Public Instance Methods

enabled_checks() click to toggle source
# File lib/nanoc/checking/loader.rb, line 17
def enabled_checks
  (enabled_checks_from_dsl + enabled_checks_from_config).uniq
end
run() click to toggle source
# File lib/nanoc/checking/loader.rb, line 13
def run
  dsl
end

Private Instance Methods

checks_filename() click to toggle source
# File lib/nanoc/checking/loader.rb, line 47
def checks_filename
  @_checks_filename ||= CHECKS_FILENAMES.find { |f| File.file?(f) }
end
dsl() click to toggle source
# File lib/nanoc/checking/loader.rb, line 36
def dsl
  @enabled_checks_from_dsl ||= []

  @dsl ||=
    if dsl_present?
      Nanoc::Checking::DSL.from_file(checks_filename, enabled_checks: @enabled_checks_from_dsl)
    else
      Nanoc::Checking::DSL.new(enabled_checks: @enabled_checks_from_dsl)
    end
end
dsl_present?() click to toggle source
# File lib/nanoc/checking/loader.rb, line 23
def dsl_present?
  checks_filename && File.file?(checks_filename)
end
enabled_checks_from_config() click to toggle source
# File lib/nanoc/checking/loader.rb, line 32
def enabled_checks_from_config
  @config.fetch(:checking, {}).fetch(:enabled_checks, []).map(&:to_sym)
end
enabled_checks_from_dsl() click to toggle source
# File lib/nanoc/checking/loader.rb, line 27
def enabled_checks_from_dsl
  dsl
  @enabled_checks_from_dsl
end