-
Notifications
You must be signed in to change notification settings - Fork 3
/
Rakefile
65 lines (52 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
require 'rubygems'
RUBYJS_BIN = File.join ".", "bin", "rubyjs"
task :gen_tests do
ruby "test/gen_browser_test_suite.rb"
end
task :run_tests do
ruby "test/run_tests.rb"
end
task :default => :gen_tests
rule ".js" => ".rb" do |t|
klass = t.source.pathmap("%n").
split(/_/).collect { |part| part.capitalize}.join
sh "#{RUBYJS_BIN} -O PrettyPrint -d -m #{klass} -o #{t.name} #{t.source}"
end
rule ".html" => ".js" do |t|
File.open(t.name, "w") do |file|
file.puts <<EOHTML
<html>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body>
<script src="#{t.source.pathmap("%f")}"></script>
</body>
</html>
EOHTML
end
end
desc "Generate a rubyspec file that github won't complain about"
task :generate_gemspec do
files = Dir['**/*'].reject { |file|
file if [/^nbproject/, /^examples/, /~$/, /\.gem$/, /test\/.*.js/, /test\/.*.html/ ].detect { |exp| file =~ exp }
}.map {|entry| "'#{entry}'"}.join(", \n")
File.open("rubyjs.gemspec", "w") do |f|
f.puts <<EOF
spec = Gem::Specification.new do |s|
s.name = 'rubyjs'
s.version = '0.8.2'
s.summary = 'RubyJS is a Ruby to Javascript Compiler. This is a fork with some added features. Orignally by Michael Neumann'
s.files = [#{files}]
s.add_dependency('ParseTree', '>= 2.1.1')
s.required_ruby_version = ">= 1.8.6"
s.require_path = 'src'
s.bindir = 'bin'
s.executables = ['rubyjs']
s.author = "Chris Nelson"
s.email = "[email protected]"
end
EOF
end
end