class Nanoc::Checking::Check
@api private
Attributes
issues[R]
Public Class Methods
create(site)
click to toggle source
# File lib/nanoc/checking/check.rb, line 27 def self.create(site) output_dir = site.config.output_dir unless File.exist?(output_dir) raise Nanoc::Checking::OutputDirNotFoundError.new(output_dir) end output_filenames = Dir[output_dir + '/**/*'].select { |f| File.file?(f) } # FIXME: ugly compiler = Nanoc::Core::Compiler.new_for(site) res = compiler.run_until_reps_built reps = res.fetch(:reps) view_context = Nanoc::Core::ViewContextForShell.new( items: site.items, reps: reps, ) context = { items: Nanoc::Core::PostCompileItemCollectionView.new(site.items, view_context), layouts: Nanoc::Core::LayoutCollectionView.new(site.layouts, view_context), config: Nanoc::Core::ConfigView.new(site.config, view_context), output_filenames: output_filenames, } new(context) end
define(ident, &block)
click to toggle source
# File lib/nanoc/checking/check.rb, line 20 def self.define(ident, &block) klass = Class.new(self) { identifier(ident) } klass.send(:define_method, :run) do instance_exec(&block) end end
new(context)
click to toggle source
Calls superclass method
# File lib/nanoc/checking/check.rb, line 55 def initialize(context) super(context) @issues = Set.new end
Public Instance Methods
add_issue(desc, subject: nil)
click to toggle source
# File lib/nanoc/checking/check.rb, line 65 def add_issue(desc, subject: nil) # Simplify subject # FIXME: do not depend on working directory if subject&.start_with?(Dir.getwd) subject = subject[(Dir.getwd.size + 1)..subject.size] end @issues << Issue.new(desc, subject, self.class) end
excluded_patterns()
click to toggle source
# File lib/nanoc/checking/check.rb, line 81 def excluded_patterns @config .fetch(:checks, {}) .fetch(:all, {}) .fetch(:exclude_files, []) .map { |pattern| Regexp.new(pattern) } end
output_filenames()
click to toggle source
@private
Calls superclass method
# File lib/nanoc/checking/check.rb, line 76 def output_filenames super.reject { |f| excluded_patterns.any? { |pat| pat.match?(f) } } end
output_html_filenames()
click to toggle source
@private
# File lib/nanoc/checking/check.rb, line 90 def output_html_filenames output_filenames.select { |f| File.extname(f) =~ /\A\.x?html?\z/ } end
run()
click to toggle source
# File lib/nanoc/checking/check.rb, line 61 def run raise NotImplementedError.new('Nanoc::Checking::Check subclasses must implement #run') end