Class: Jekyll::PreCommit::Checks::FrontMatterVariableIsNotDuplicate
- Defined in:
- lib/jekyll-pre-commit/checks/front_matter_variable_is_not_duplicate.rb
Instance Method Summary collapse
Methods inherited from Check
Constructor Details
This class inherits a constructor from Jekyll::PreCommit::Checks::Check
Instance Method Details
#check(staged, not_staged, site, args) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/jekyll-pre-commit/checks/front_matter_variable_is_not_duplicate.rb', line 5 def check(staged, not_staged, site, args) if !args["variables"] @result[:message] += "No variables to check." return @result end existing = Hash.new not_staged.each do |post| args["variables"].each do |variable| if !existing[variable] existing[variable] = Array.new end existing[variable].push(post.data[variable]) if post.data[variable] end end staged.each do |post| args["variables"].each do |variable| if existing[variable].include? post.data[variable] @result[:ok] = false @result[:message] += "#{post.data["title"]}'s #{variable} was already used. " end end end @result end |