Sha256: bb33a1cea65612864a7778da6305b1a8681725e44cbdba3d9230ea9b66094d03
Contents?: true
Size: 1.9 KB
Versions: 3
Compression:
Stored size: 1.9 KB
Contents
# frozen_string_literal: true module Nanoc::Checking # @api private class OutputDirNotFoundError < Nanoc::Int::Errors::Generic def initialize(directory_path) super("Unable to run check against output directory at “#{directory_path}”: directory does not exist.") end end # @api private class Check < Nanoc::Int::Context extend DDPlugin::Plugin attr_reader :issues def self.define(ident, &block) klass = Class.new(::Nanoc::Checking::Check) { identifier(ident) } klass.send(:define_method, :run) do instance_exec(&block) end end 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::Int::Compiler.new_for(site) res = compiler.run_until_reps_built reps = res.fetch(:reps) compilation_context = compiler.compilation_context(reps: reps) view_context = compilation_context.create_view_context(Nanoc::Int::DependencyTracker::Null.new) context = { items: Nanoc::PostCompileItemCollectionView.new(site.items, view_context), layouts: Nanoc::LayoutCollectionView.new(site.layouts, view_context), config: Nanoc::ConfigView.new(site.config, view_context), output_filenames: output_filenames, } new(context) end def initialize(context) super(context) @issues = Set.new end def run raise NotImplementedError.new('Nanoc::Checking::Check subclasses must implement #run') end def add_issue(desc, subject: nil) @issues << Issue.new(desc, subject, self.class) end # @private def output_html_filenames output_filenames.select { |f| File.extname(f) =~ /\A\.x?html?\z/ } end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
nanoc-4.9.4 | lib/nanoc/checking/check.rb |
nanoc-4.9.3 | lib/nanoc/checking/check.rb |
nanoc-4.9.2 | lib/nanoc/checking/check.rb |