Skip to content

Commit

Permalink
Merge pull request #255 from cdlm/checks-bikeshedding
Browse files Browse the repository at this point in the history
Allow checks file naming variants
  • Loading branch information
denisdefreyne committed Feb 27, 2013
2 parents a51cb04 + 0417cc3 commit 3100531
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions lib/nanoc/extra/checking/runner.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,17 @@ module Nanoc::Extra::Checking
# @api private
class Runner

CHECKS_FILENAME = 'Checks'
CHECKS_FILENAMES = ['Checks', 'Checks.rb', 'checks', 'checks.rb']

# @param [Nanoc::Site] site The nanoc site this runner is for
def initialize(site)
@site = site
@checks_filename = CHECKS_FILENAMES.find { |f| File.file?(f) }
end

# @return [Boolean] true if a Checks file exists, false otherwise
def has_dsl?
File.exist?(CHECKS_FILENAME)
@checks_filename && File.file?(@checks_filename)
end

# Lists all available checks on stdout.
Expand Down Expand Up @@ -66,7 +67,7 @@ def load_dsl_if_available
@dsl_loaded ||= false
if !@dsl_loaded
if self.has_dsl?
@dsl = Nanoc::Extra::Checking::DSL.from_file(CHECKS_FILENAME)
@dsl = Nanoc::Extra::Checking::DSL.from_file(@checks_filename)
else
@dsl = nil
end
Expand All @@ -77,7 +78,7 @@ def load_dsl_if_available
def require_dsl
self.load_dsl_if_available
if self.dsl.nil?
raise Nanoc::Errors::GenericTrivial, "No checks defined (no #{CHECKS_FILENAME} file present)"
raise Nanoc::Errors::GenericTrivial, "No checks defined (no #{CHECKS_FILENAMES.first} file present)"
end
end

Expand Down

0 comments on commit 3100531

Please sign in to comment.