Extending a non-existent parent yells at you now

Fixes #24
This commit is contained in:
Andy Meneely
2015-01-05 23:59:09 -05:00
parent 845123a283
commit 73d6eb992b
5 changed files with 45 additions and 1 deletions
+14
View File
@@ -34,6 +34,7 @@ module Squib
def self.recurse_extends(yml, key, visited )
assert_not_visited(key, visited)
return yml[key] unless has_extends?(yml, key)
return yml[key] unless parents_exist?(yml, key)
visited[key] = key
parent_keys = [yml[key]['extends']].flatten
h = {}
@@ -62,6 +63,19 @@ module Squib
!!yml[key] && yml[key].key?('extends')
end
# Checks if we have any absentee parents
# @api private
def self.parents_exist?(yml, key)
exists = true
Array(yml[key]['extends']).each do |parent|
unless yml.key?(parent)
exists = false unless
Squib.logger.error "Processing layout: '#{key}' attempts to extend a missing '#{yml[key]['extends']}'"
end
end
return exists
end
# Safeguard against malformed circular extends
# :nodoc:
# @api private