class Jekyll::PreCommit::Checks::FrontMatterVariableExists

Public Instance Methods

check(staged, not_staged, site, args) click to toggle source
# File lib/jekyll-pre-commit/checks/front_matter_variable_exists.rb, line 5
def check(staged, not_staged, site, args)
  if !args["variables"]
    @result[:message] += "No variables to check."
    return @result
  end

  staged.each do |post|
    args["variables"].each do |variable|
      if !post.data[variable]
        @result[:ok] = false
        @result[:message] += "#{post.data["title"]} was missing a #{variable}. "
      end
    end
  end

  @result
end