45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
|
# File 'lib/chef/knife/cookbook_doc.rb', line 45
def run
unless (cookbook_dir = name_args.first)
ui.fatal 'Please provide cookbook directory as an argument'
exit(1)
end
cookbook_dir = File.realpath(cookbook_dir)
model = ReadmeModel.new(cookbook_dir, config)
template = File.read(config[:template_file])
eruby = Erubis::Eruby.new(template)
result = eruby.result(model.get_binding)
File.open("#{cookbook_dir}/#{config[:output_file]}", 'wb') do |f|
result.each_line do |line|
f.write line.gsub(/[ \t\r\n]*$/,'')
f.write "\n"
end
end
end
|