Class: Nanoc::Extra::Checking::Check

Inherits:
Object
  • Object
show all
Extended by:
PluginRegistry::PluginMethods
Defined in:
lib/nanoc/extra/checking/check.rb

Direct Known Subclasses

Nanoc::Extra::Checking::Checks::CSS, Nanoc::Extra::Checking::Checks::ExternalLinks, Nanoc::Extra::Checking::Checks::HTML, Nanoc::Extra::Checking::Checks::InternalLinks, Nanoc::Extra::Checking::Checks::MixedContent, Nanoc::Extra::Checking::Checks::Stale

Instance Attribute Summary (collapse)

Instance Method Summary (collapse)

Methods included from PluginRegistry::PluginMethods

all, identifier, identifiers, named, register

Constructor Details

- (Check) initialize(site)

Returns a new instance of Check



16
17
18
19
# File 'lib/nanoc/extra/checking/check.rb', line 16

def initialize(site)
  @site   = site
  @issues = Set.new
end

Instance Attribute Details

- (Object) issues (readonly)

Returns the value of attribute issues



14
15
16
# File 'lib/nanoc/extra/checking/check.rb', line 14

def issues
  @issues
end

- (Object) site (readonly)

Returns the value of attribute site



13
14
15
# File 'lib/nanoc/extra/checking/check.rb', line 13

def site
  @site
end

Instance Method Details

- (Object) add_issue(desc, params = {})



25
26
27
28
29
# File 'lib/nanoc/extra/checking/check.rb', line 25

def add_issue(desc, params = {})
  subject  = params.fetch(:subject, nil)

  @issues << Issue.new(desc, subject, self.class)
end

- (Object) output_filenames



31
32
33
34
35
36
37
# File 'lib/nanoc/extra/checking/check.rb', line 31

def output_filenames
  output_dir = @site.config[:output_dir]
  unless File.exist?(output_dir)
    raise Nanoc::Extra::Checking::OutputDirNotFoundError.new(output_dir)
  end
  Dir[output_dir + '/**/*'].select { |f| File.file?(f) }
end

- (Object) run

Raises:

  • (NotImplementedError)


21
22
23
# File 'lib/nanoc/extra/checking/check.rb', line 21

def run
  raise NotImplementedError.new('Nanoc::Extra::Checking::Check subclasses must implement #run')
end