-
Notifications
You must be signed in to change notification settings - Fork 45
/
Rakefile
40 lines (33 loc) · 814 Bytes
/
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
RECIPES_PATH = "./recipes"
LIB_PATH = "./lib"
$LOAD_PATH.unshift(LIB_PATH)
def is_a_recipe?(filename)
Dir.foreach(RECIPES_PATH) do |item|
next if item == '.' || item == '..'
return true if filename == item
end
false
end
task :default => :list
desc "Shows all recipes available"
task :list do
puts "Available recipes:"
puts "-----------------"
Dir.foreach(RECIPES_PATH) do |item|
next if item == '.' || item == '..'
puts item
end
end
desc "Compiles a given recipe"
task :compile, :recipe do |t, args|
recipe = args.recipe
args.with_defaults(:recipe => "Usage: rake 'compile[<recipe_name>]'")
if !is_a_recipe?(recipe)
puts "Incorrect recipe!"
exit
end
path = "#{RECIPES_PATH}/#{recipe}"
puts "Compiling #{recipe}"
puts "-------------------"
load path
end