Class: Nanoc::Checking::Check Private
- Inherits:
-
Nanoc::Core::Context
- Object
- Nanoc::Core::Context
- Nanoc::Checking::Check
- Extended by:
- DDPlugin::Plugin
- Includes:
- MemoWise
- Defined in:
- lib/nanoc/checking/check.rb
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Direct Known Subclasses
Nanoc::Checking::Checks::ExternalLinks, Nanoc::Checking::Checks::InternalLinks, Nanoc::Checking::Checks::MixedContent, Nanoc::Checking::Checks::Stale, Nanoc::Checking::Checks::W3CValidator
Instance Attribute Summary collapse
- #issues ⇒ Object readonly private
Class Method Summary collapse
- .create(site) ⇒ Object private
- .define(ident, &block) ⇒ Object private
Instance Method Summary collapse
- #add_issue(desc, subject: nil) ⇒ Object private
- #excluded_patterns ⇒ Object private
-
#initialize(context) ⇒ Check
constructor
private
A new instance of Check.
- #output_filenames ⇒ Object private
- #output_html_filenames ⇒ Object private
- #run ⇒ Object private
Constructor Details
#initialize(context) ⇒ Check
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of Check.
55 56 57 58 59 |
# File 'lib/nanoc/checking/check.rb', line 55 def initialize(context) super @issues = Set.new end |
Instance Attribute Details
#issues ⇒ Object (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
18 19 20 |
# File 'lib/nanoc/checking/check.rb', line 18 def issues @issues end |
Class Method Details
.create(site) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# 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:, ) 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:, } new(context) end |
.define(ident, &block) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
20 21 22 23 24 25 |
# 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 |
Instance Method Details
#add_issue(desc, subject: nil) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
65 66 67 68 69 70 71 72 73 |
# 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 ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
81 82 83 84 85 86 87 |
# 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 ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
76 77 78 |
# 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 ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
91 92 93 |
# File 'lib/nanoc/checking/check.rb', line 91 def output_html_filenames output_filenames.select { |f| File.extname(f) =~ /\A\.x?html?\z/ } end |
#run ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
61 62 63 |
# File 'lib/nanoc/checking/check.rb', line 61 def run raise NotImplementedError.new('Nanoc::Checking::Check subclasses must implement #run') end |