Method: Berkshelf::CachedCookbook#validate

Defined in:
lib/berkshelf/cached_cookbook.rb

#validateObject

Raises:

  • (IOError)


151
152
153
154
155
156
157
158
159
160
161
162
163
164
# File 'lib/berkshelf/cached_cookbook.rb', line 151

def validate
  raise IOError, "No Cookbook found at: #{path}" unless path.exist?

  syntax_checker = Chef::Cookbook::SyntaxCheck.new(path.to_path)

  unless syntax_checker.validate_ruby_files
    raise Berkshelf::Errors::CookbookSyntaxError, "Invalid ruby files in cookbook: #{cookbook_name} (#{version})."
  end
  unless syntax_checker.validate_templates
    raise Berkshelf::Errors::CookbookSyntaxError, "Invalid template files in cookbook: #{cookbook_name} (#{version})."
  end

  true
end