forked from maintainable/framework
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Rakefile
29 lines (24 loc) · 744 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
require 'yaml'
# capture arguments after task name
args = ARGV.dup
args.shift
args = args.join(' ')
# export list of tasks from mad
chdir File.dirname(__FILE__) # MAD_ROOT
task_runner = File.join('.', 'script', 'task')
tasks = YAML.load(`php #{task_runner} --yaml`)
abort unless tasks.is_a?(Hash) and tasks.key?("test")
# dynamically build rakefile
code = ""
tasks.each_pair do |name, desc|
namespaces = name.split(':')
task = namespaces.pop
namespaces.each { |n| code << "namespace :#{n} do \n" }
code << "desc \"#{desc.gsub('"', '\\"').strip}\"
task :#{task} do
sh('php #{task_runner} #{name} #{args}')
end\n"
namespaces.each { |n| code << "end\n" }
end
eval code
task :default => ["test"]