Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow checks file naming variants #255

Merged
merged 1 commit into from
Feb 27, 2013
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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