lib/squib/deck.rb in squib-0.0.6 vs lib/squib/deck.rb in squib-0.1.0
- old
+ new
@@ -113,11 +113,11 @@
Squib::logger.info { " using layout(s): #{files}" }
Array(files).each do |file|
thefile = file
thefile = "#{File.dirname(__FILE__)}/layouts/#{file}" unless File.exists?(file)
if File.exists? thefile
- yml = @layout.merge(YAML.load_file(thefile))
+ yml = @layout.merge(YAML.load_file(thefile) || {}) #load_file returns false on empty file
yml.each do |key, value|
@layout[key] = recurse_extends(yml, key, {})
end
else
puts "the file: #{thefile}"
@@ -155,11 +155,11 @@
# Does this layout entry have an extends field?
# i.e. is it a base-case or will it need recursion?
# :nodoc:
# @api private
def has_extends?(yml, key)
- yml[key].key?('extends')
+ !!yml[key] && yml[key].key?('extends')
end
# Safeguard against malformed circular extends
# :nodoc:
# @api private
@@ -167,9 +167,12 @@
if visited.key? key
raise "Invalid layout: circular extends with '#{key}'"
end
end
+ # Use Logger to show more detail on the run
+ # :nodoc:
+ # @api private
def show_info(config, layout)
Squib::logger.info "Squib v#{Squib::VERSION}"
Squib::logger.info " building #{@cards.size} #{@width}x#{@height} cards"
end