def self.init_cookbook(cookbook_name, options)
require 'chef/knife/cookbook_create'
puts '* Initializing Cookbook'
path = File.join(options[:path], cookbook_name)
create_cookbook = Chef::Knife::CookbookCreate.new
create_cookbook.name_args = [cookbook_name]
create_cookbook.config[:cookbook_path] = options[:path]
create_cookbook.config[:cookbook_copyright] = options[:copyright] || 'YOUR_COMPANY_NAME'
create_cookbook.config[:cookbook_license] = options[:license] || 'YOUR_EMAIL'
create_cookbook.config[:cookbook_email] = options[:email] || 'none'
create_cookbook.run
%w(metadata.rb recipes/default.rb).each do |file|
puts "\tRewriting #{file}"
contents = "# Encoding: utf-8\n#{File.read(File.join(path, file))}"
File.open(File.join(path, file), 'w') { |f| f.write(contents) }
end
end