forked from jerrod/ey-cloud-recipes
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Rakefile
42 lines (38 loc) · 1.31 KB
/
Rakefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
TOPDIR = File.dirname(__FILE__)
desc "Test your cookbooks for syntax errors"
task :test do
puts "** Testing your cookbooks for syntax errors"
Dir[ File.join(TOPDIR, "cookbooks", "**", "*.rb") ].each do |recipe|
sh %{ruby -c #{recipe}} do |ok, res|
if ! ok
raise "Syntax error in #{recipe}"
end
end
end
end
desc "By default, run rake test"
task :default => [ :test ]
desc "Create a new cookbook (with COOKBOOK=name)"
task :new_cookbook do
create_cookbook(File.join(TOPDIR, "cookbooks"))
end
def create_cookbook(dir)
raise "Must provide a COOKBOOK=" unless ENV["COOKBOOK"]
puts "** Creating cookbook #{ENV["COOKBOOK"]}"
sh "mkdir -p #{File.join(dir, ENV["COOKBOOK"], "attributes")}"
sh "mkdir -p #{File.join(dir, ENV["COOKBOOK"], "recipes")}"
sh "mkdir -p #{File.join(dir, ENV["COOKBOOK"], "definitions")}"
sh "mkdir -p #{File.join(dir, ENV["COOKBOOK"], "libraries")}"
sh "mkdir -p #{File.join(dir, ENV["COOKBOOK"], "files", "default")}"
sh "mkdir -p #{File.join(dir, ENV["COOKBOOK"], "templates", "default")}"
unless File.exists?(File.join(dir, ENV["COOKBOOK"], "recipes", "default.rb"))
open(File.join(dir, ENV["COOKBOOK"], "recipes", "default.rb"), "w") do |file|
file.puts <<-EOH
#
# Cookbook Name:: #{ENV["COOKBOOK"]}
# Recipe:: default
#
EOH
end
end
end