Method: Chef::Cookbook::SyntaxCheck#invalid_ruby_file

Defined in:
lib/chef/cookbook/syntax_check.rb

#invalid_ruby_file(ruby_file, error_message) ⇒ Object

Debugs ruby syntax errors by printing the path to the file and any diagnostic info given in error_message



246
247
248
249
250
251
# File 'lib/chef/cookbook/syntax_check.rb', line 246

def invalid_ruby_file(ruby_file, error_message)
  file_relative_path = ruby_file[/^#{Regexp.escape(cookbook_path + File::Separator)}(.*)/, 1]
  Chef::Log.fatal("Cookbook file #{file_relative_path} has a ruby syntax error:")
  error_message.each_line { |l| Chef::Log.fatal(l.chomp) }
  false
end