-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRakefile
64 lines (54 loc) · 1.6 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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
require 'rake'
# Defaults
task :default => [:build]
command = 'lib/jspec/bin/jspec'
subcommand = 'run'
paths = '-p src,site/**/*.js,spec/**/*.spec,Rakefile'
desc 'Install dependencies'
task :install => ['site/javascripts/jquery.min.js',
'site/javascripts/swfobject.js'] do
# wget missing files
end
desc 'Continuously monitor code'
task :bind => [:dobind, :spec]
task :dobind do
subcommand = 'bind --actions "rake build"'
end
desc 'Run in rhino'
task :rhino => [:dorhino, :spec]
task :dorhino do
subcommand = 'bind --actions "rake build" --rhino'
end
desc 'Check specs'
task :spec => [:install, :build] do
sh "#{command} #{subcommand} #{paths}"
end
desc 'Build static resources'
multitask :build => ['site/index.html',
'spec/all.js',
'site/javascripts/playerground.js']
file 'site/index.html' => FileList['src/**/*.haml', 'src/**/*.sass'] do
sh "staticmatic build ."
end
file 'site/javascripts/playerground.js' => FileList['src/js/**/*.js'] do
# Compile playerground.js
sh "src/compile.rb"
end
# Generates all.js files
file 'spec/all.js' => FileList['spec/**/*.spec'] do
# Add 'spec/**' to recursively build all.js files.
Dir['spec'].each do |d|
gen_all d if File.directory? d
end
end
def gen_all dir
puts "Generating #{dir}"
File.open(File.join(dir, '/all.js'), 'w') do |file|
file.puts '// This file is automatically generated with `rake spec`.'
file.puts 'JSpec'
FileList[File.join(dir, '/**/*.spec')].each do |spec|
# Remove leading 'spec/'
file.puts(".exec(BASE + '%s')" % spec.sub('spec/', ''))
end
end
end