forked from jywarren/cartagen
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Rakefile
71 lines (57 loc) · 1.53 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
65
66
67
68
69
70
71
require 'date'
desc "builds cartagen.js"
task :build do
build
end
desc "automatically builds cartagen.js when something in src/ changes"
task :autobuild do
build
require 'lib/filesystemwatcher'
watcher = FileSystemWatcher.new
watcher.addDirectory 'src', '**/*.js'
watcher.sleepTime = 2
watcher.start do |status,file|
if ([FileSystemWatcher::CREATED,
FileSystemWatcher::MODIFIED,
FileSystemWatcher::DELETED].include? status)
begin
build
rescue
puts "//// !!! Build failed !!! ////"
puts $!
end
end
end
watcher.join()
end
desc "builds the API docs"
task :docs do
Dir.chdir 'lib/jsdoc'
puts `java -jar jsrun.jar app/main.js -v -t=templates/mad/ -d=../../../api/ -a -r=2 ../../src/`
end
desc "builds the API docs, debug run"
task :docs_debug do
Dir.chdir 'lib/jsdoc'
puts `java -jar jsdebug.jar app/main.js -v -t=templates/mad/ -d=../../../api/ -a -r=2 ../../src/`
end
desc "Finds while file a source line is in"
task :which, :line do |t, args|
lines = Marshal.load IO.read('.line_data.dat')
puts lines[args.line.to_i]
end
def build
puts 'building... '+DateTime.now.to_s
$:.push 'lib/sprockets'
require 'sprockets'
secretary = Sprockets::Secretary.new(
:load_path => ['src'],
:source_files => ['src/cartagen.js']
)
lines = Marshal.dump secretary.preprocessor.lines
File.open '.line_data.dat', 'w' do |f|
f.print lines
end
concatenation = secretary.concatenation
concatenation.save_to("cartagen.js")
puts "Build finished"
end