coffeescript-router 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.gitignore +3 -0
- data/Cakefile +122 -0
- data/Gemfile +4 -0
- data/LICENSE +22 -0
- data/LICENSE.txt +19 -0
- data/README.md +18 -0
- data/Rakefile +2 -0
- data/SpecRunner.html +25 -0
- data/coffeescript-router.gemspec +19 -0
- data/lib/CoffeeScript.png +0 -0
- data/lib/coffeescript-router/version.rb +5 -0
- data/lib/jasmine-1.0.2/MIT.LICENSE +20 -0
- data/lib/jasmine-1.0.2/jasmine-html.js +188 -0
- data/lib/jasmine-1.0.2/jasmine.css +166 -0
- data/lib/jasmine-1.0.2/jasmine.js +2421 -0
- data/node_modules/.bin/cake +7 -0
- data/node_modules/.bin/coffee +7 -0
- data/node_modules/.bin/uglifyjs +212 -0
- data/node_modules/coffee-script/.npmignore +11 -0
- data/node_modules/coffee-script/LICENSE +22 -0
- data/node_modules/coffee-script/README +48 -0
- data/node_modules/coffee-script/Rakefile +78 -0
- data/node_modules/coffee-script/bin/cake +7 -0
- data/node_modules/coffee-script/bin/coffee +7 -0
- data/node_modules/coffee-script/lib/browser.js +75 -0
- data/node_modules/coffee-script/lib/cake.js +76 -0
- data/node_modules/coffee-script/lib/coffee-script.js +107 -0
- data/node_modules/coffee-script/lib/command.js +274 -0
- data/node_modules/coffee-script/lib/grammar.js +591 -0
- data/node_modules/coffee-script/lib/helpers.js +66 -0
- data/node_modules/coffee-script/lib/index.js +8 -0
- data/node_modules/coffee-script/lib/lexer.js +650 -0
- data/node_modules/coffee-script/lib/nodes.js +2230 -0
- data/node_modules/coffee-script/lib/optparse.js +111 -0
- data/node_modules/coffee-script/lib/parser.js +676 -0
- data/node_modules/coffee-script/lib/repl.js +114 -0
- data/node_modules/coffee-script/lib/rewriter.js +359 -0
- data/node_modules/coffee-script/lib/scope.js +120 -0
- data/node_modules/coffee-script/package.json +27 -0
- data/node_modules/growl/History.md +16 -0
- data/node_modules/growl/Readme.md +74 -0
- data/node_modules/growl/lib/growl.js +82 -0
- data/node_modules/growl/package.json +6 -0
- data/node_modules/growl/test.js +17 -0
- data/node_modules/uglify-js/.gitignore +4 -0
- data/node_modules/uglify-js/README.html +825 -0
- data/node_modules/uglify-js/README.org +431 -0
- data/node_modules/uglify-js/bin/uglifyjs +212 -0
- data/node_modules/uglify-js/docstyle.css +75 -0
- data/node_modules/uglify-js/lib/parse-js.js +1319 -0
- data/node_modules/uglify-js/lib/process.js +1614 -0
- data/node_modules/uglify-js/lib/squeeze-more.js +22 -0
- data/node_modules/uglify-js/package.json +22 -0
- data/node_modules/uglify-js/test/beautify.js +28 -0
- data/node_modules/uglify-js/test/testparser.js +402 -0
- data/node_modules/uglify-js/test/unit/compress/expected/array1.js +1 -0
- data/node_modules/uglify-js/test/unit/compress/expected/array2.js +1 -0
- data/node_modules/uglify-js/test/unit/compress/expected/array3.js +1 -0
- data/node_modules/uglify-js/test/unit/compress/expected/array4.js +1 -0
- data/node_modules/uglify-js/test/unit/compress/expected/assignment.js +1 -0
- data/node_modules/uglify-js/test/unit/compress/expected/concatstring.js +1 -0
- data/node_modules/uglify-js/test/unit/compress/expected/const.js +1 -0
- data/node_modules/uglify-js/test/unit/compress/expected/empty-blocks.js +1 -0
- data/node_modules/uglify-js/test/unit/compress/expected/forstatement.js +1 -0
- data/node_modules/uglify-js/test/unit/compress/expected/if.js +1 -0
- data/node_modules/uglify-js/test/unit/compress/expected/ifreturn.js +1 -0
- data/node_modules/uglify-js/test/unit/compress/expected/issue10.js +1 -0
- data/node_modules/uglify-js/test/unit/compress/expected/issue11.js +1 -0
- data/node_modules/uglify-js/test/unit/compress/expected/issue13.js +1 -0
- data/node_modules/uglify-js/test/unit/compress/expected/issue14.js +1 -0
- data/node_modules/uglify-js/test/unit/compress/expected/issue16.js +1 -0
- data/node_modules/uglify-js/test/unit/compress/expected/issue17.js +1 -0
- data/node_modules/uglify-js/test/unit/compress/expected/issue20.js +1 -0
- data/node_modules/uglify-js/test/unit/compress/expected/issue21.js +1 -0
- data/node_modules/uglify-js/test/unit/compress/expected/issue25.js +1 -0
- data/node_modules/uglify-js/test/unit/compress/expected/issue27.js +1 -0
- data/node_modules/uglify-js/test/unit/compress/expected/issue28.js +1 -0
- data/node_modules/uglify-js/test/unit/compress/expected/issue29.js +1 -0
- data/node_modules/uglify-js/test/unit/compress/expected/issue30.js +1 -0
- data/node_modules/uglify-js/test/unit/compress/expected/issue34.js +1 -0
- data/node_modules/uglify-js/test/unit/compress/expected/issue4.js +1 -0
- data/node_modules/uglify-js/test/unit/compress/expected/issue48.js +1 -0
- data/node_modules/uglify-js/test/unit/compress/expected/issue50.js +1 -0
- data/node_modules/uglify-js/test/unit/compress/expected/issue53.js +1 -0
- data/node_modules/uglify-js/test/unit/compress/expected/issue54.1.js +1 -0
- data/node_modules/uglify-js/test/unit/compress/expected/issue68.js +1 -0
- data/node_modules/uglify-js/test/unit/compress/expected/issue69.js +1 -0
- data/node_modules/uglify-js/test/unit/compress/expected/issue9.js +1 -0
- data/node_modules/uglify-js/test/unit/compress/expected/strict-equals.js +1 -0
- data/node_modules/uglify-js/test/unit/compress/expected/var.js +1 -0
- data/node_modules/uglify-js/test/unit/compress/test/array1.js +3 -0
- data/node_modules/uglify-js/test/unit/compress/test/array2.js +4 -0
- data/node_modules/uglify-js/test/unit/compress/test/array3.js +4 -0
- data/node_modules/uglify-js/test/unit/compress/test/array4.js +6 -0
- data/node_modules/uglify-js/test/unit/compress/test/assignment.js +20 -0
- data/node_modules/uglify-js/test/unit/compress/test/concatstring.js +3 -0
- data/node_modules/uglify-js/test/unit/compress/test/const.js +5 -0
- data/node_modules/uglify-js/test/unit/compress/test/empty-blocks.js +4 -0
- data/node_modules/uglify-js/test/unit/compress/test/forstatement.js +10 -0
- data/node_modules/uglify-js/test/unit/compress/test/if.js +6 -0
- data/node_modules/uglify-js/test/unit/compress/test/ifreturn.js +9 -0
- data/node_modules/uglify-js/test/unit/compress/test/issue10.js +1 -0
- data/node_modules/uglify-js/test/unit/compress/test/issue11.js +3 -0
- data/node_modules/uglify-js/test/unit/compress/test/issue13.js +1 -0
- data/node_modules/uglify-js/test/unit/compress/test/issue14.js +1 -0
- data/node_modules/uglify-js/test/unit/compress/test/issue16.js +1 -0
- data/node_modules/uglify-js/test/unit/compress/test/issue17.js +4 -0
- data/node_modules/uglify-js/test/unit/compress/test/issue20.js +1 -0
- data/node_modules/uglify-js/test/unit/compress/test/issue21.js +6 -0
- data/node_modules/uglify-js/test/unit/compress/test/issue25.js +7 -0
- data/node_modules/uglify-js/test/unit/compress/test/issue27.js +1 -0
- data/node_modules/uglify-js/test/unit/compress/test/issue28.js +3 -0
- data/node_modules/uglify-js/test/unit/compress/test/issue29.js +1 -0
- data/node_modules/uglify-js/test/unit/compress/test/issue30.js +3 -0
- data/node_modules/uglify-js/test/unit/compress/test/issue34.js +3 -0
- data/node_modules/uglify-js/test/unit/compress/test/issue4.js +3 -0
- data/node_modules/uglify-js/test/unit/compress/test/issue48.js +1 -0
- data/node_modules/uglify-js/test/unit/compress/test/issue50.js +9 -0
- data/node_modules/uglify-js/test/unit/compress/test/issue53.js +1 -0
- data/node_modules/uglify-js/test/unit/compress/test/issue54.1.js +3 -0
- data/node_modules/uglify-js/test/unit/compress/test/issue68.js +5 -0
- data/node_modules/uglify-js/test/unit/compress/test/issue69.js +1 -0
- data/node_modules/uglify-js/test/unit/compress/test/issue9.js +4 -0
- data/node_modules/uglify-js/test/unit/compress/test/strict-equals.js +3 -0
- data/node_modules/uglify-js/test/unit/compress/test/var.js +3 -0
- data/node_modules/uglify-js/test/unit/scripts.js +46 -0
- data/node_modules/uglify-js/uglify-js.js +2 -0
- data/src/coffeescript/coffeescript-router.js.coffee +31 -0
- data/test/coffeescript/routerSpec.coffee +47 -0
- data/vendor/assets/javascripts/coffeescript-router.min.js +1 -0
- metadata +187 -0
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
#! /usr/bin/env node
|
|
2
|
+
// -*- js -*-
|
|
3
|
+
|
|
4
|
+
global.sys = require(/^v0\.[012]/.test(process.version) ? "sys" : "util");
|
|
5
|
+
var fs = require("fs");
|
|
6
|
+
var uglify = require("uglify-js"), // symlink ~/.node_libraries/uglify-js.js to ../uglify-js.js
|
|
7
|
+
jsp = uglify.parser,
|
|
8
|
+
pro = uglify.uglify;
|
|
9
|
+
|
|
10
|
+
var options = {
|
|
11
|
+
ast: false,
|
|
12
|
+
mangle: true,
|
|
13
|
+
mangle_toplevel: false,
|
|
14
|
+
squeeze: true,
|
|
15
|
+
make_seqs: true,
|
|
16
|
+
dead_code: true,
|
|
17
|
+
verbose: false,
|
|
18
|
+
show_copyright: true,
|
|
19
|
+
out_same_file: false,
|
|
20
|
+
max_line_length: 32 * 1024,
|
|
21
|
+
unsafe: false,
|
|
22
|
+
reserved_names: null,
|
|
23
|
+
codegen_options: {
|
|
24
|
+
ascii_only: false,
|
|
25
|
+
beautify: false,
|
|
26
|
+
indent_level: 4,
|
|
27
|
+
indent_start: 0,
|
|
28
|
+
quote_keys: false,
|
|
29
|
+
space_colon: false
|
|
30
|
+
},
|
|
31
|
+
output: true // stdout
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
var args = jsp.slice(process.argv, 2);
|
|
35
|
+
var filename;
|
|
36
|
+
|
|
37
|
+
out: while (args.length > 0) {
|
|
38
|
+
var v = args.shift();
|
|
39
|
+
switch (v) {
|
|
40
|
+
case "-b":
|
|
41
|
+
case "--beautify":
|
|
42
|
+
options.codegen_options.beautify = true;
|
|
43
|
+
break;
|
|
44
|
+
case "-i":
|
|
45
|
+
case "--indent":
|
|
46
|
+
options.codegen_options.indent_level = args.shift();
|
|
47
|
+
break;
|
|
48
|
+
case "-q":
|
|
49
|
+
case "--quote-keys":
|
|
50
|
+
options.codegen_options.quote_keys = true;
|
|
51
|
+
break;
|
|
52
|
+
case "-mt":
|
|
53
|
+
case "--mangle-toplevel":
|
|
54
|
+
options.mangle_toplevel = true;
|
|
55
|
+
break;
|
|
56
|
+
case "--no-mangle":
|
|
57
|
+
case "-nm":
|
|
58
|
+
options.mangle = false;
|
|
59
|
+
break;
|
|
60
|
+
case "--no-squeeze":
|
|
61
|
+
case "-ns":
|
|
62
|
+
options.squeeze = false;
|
|
63
|
+
break;
|
|
64
|
+
case "--no-seqs":
|
|
65
|
+
options.make_seqs = false;
|
|
66
|
+
break;
|
|
67
|
+
case "--no-dead-code":
|
|
68
|
+
options.dead_code = false;
|
|
69
|
+
break;
|
|
70
|
+
case "--no-copyright":
|
|
71
|
+
case "-nc":
|
|
72
|
+
options.show_copyright = false;
|
|
73
|
+
break;
|
|
74
|
+
case "-o":
|
|
75
|
+
case "--output":
|
|
76
|
+
options.output = args.shift();
|
|
77
|
+
break;
|
|
78
|
+
case "--overwrite":
|
|
79
|
+
options.out_same_file = true;
|
|
80
|
+
break;
|
|
81
|
+
case "-v":
|
|
82
|
+
case "--verbose":
|
|
83
|
+
options.verbose = true;
|
|
84
|
+
break;
|
|
85
|
+
case "--ast":
|
|
86
|
+
options.ast = true;
|
|
87
|
+
break;
|
|
88
|
+
case "--unsafe":
|
|
89
|
+
options.unsafe = true;
|
|
90
|
+
break;
|
|
91
|
+
case "--max-line-len":
|
|
92
|
+
options.max_line_length = parseInt(args.shift(), 10);
|
|
93
|
+
break;
|
|
94
|
+
case "--reserved-names":
|
|
95
|
+
options.reserved_names = args.shift().split(",");
|
|
96
|
+
break;
|
|
97
|
+
case "--ascii":
|
|
98
|
+
options.codegen_options.ascii_only = true;
|
|
99
|
+
break;
|
|
100
|
+
default:
|
|
101
|
+
filename = v;
|
|
102
|
+
break out;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
if (options.verbose) {
|
|
107
|
+
pro.set_logger(function(msg){
|
|
108
|
+
sys.debug(msg);
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
jsp.set_logger(function(msg){
|
|
113
|
+
sys.debug(msg);
|
|
114
|
+
});
|
|
115
|
+
|
|
116
|
+
if (filename) {
|
|
117
|
+
fs.readFile(filename, "utf8", function(err, text){
|
|
118
|
+
if (err) throw err;
|
|
119
|
+
output(squeeze_it(text));
|
|
120
|
+
});
|
|
121
|
+
} else {
|
|
122
|
+
var stdin = process.openStdin();
|
|
123
|
+
stdin.setEncoding("utf8");
|
|
124
|
+
var text = "";
|
|
125
|
+
stdin.on("data", function(chunk){
|
|
126
|
+
text += chunk;
|
|
127
|
+
});
|
|
128
|
+
stdin.on("end", function() {
|
|
129
|
+
output(squeeze_it(text));
|
|
130
|
+
});
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
function output(text) {
|
|
134
|
+
var out;
|
|
135
|
+
if (options.out_same_file && filename)
|
|
136
|
+
options.output = filename;
|
|
137
|
+
if (options.output === true) {
|
|
138
|
+
out = process.stdout;
|
|
139
|
+
} else {
|
|
140
|
+
out = fs.createWriteStream(options.output, {
|
|
141
|
+
flags: "w",
|
|
142
|
+
encoding: "utf8",
|
|
143
|
+
mode: 0644
|
|
144
|
+
});
|
|
145
|
+
}
|
|
146
|
+
out.write(text);
|
|
147
|
+
if (options.output !== true) {
|
|
148
|
+
out.end();
|
|
149
|
+
}
|
|
150
|
+
};
|
|
151
|
+
|
|
152
|
+
// --------- main ends here.
|
|
153
|
+
|
|
154
|
+
function show_copyright(comments) {
|
|
155
|
+
var ret = "";
|
|
156
|
+
for (var i = 0; i < comments.length; ++i) {
|
|
157
|
+
var c = comments[i];
|
|
158
|
+
if (c.type == "comment1") {
|
|
159
|
+
ret += "//" + c.value + "\n";
|
|
160
|
+
} else {
|
|
161
|
+
ret += "/*" + c.value + "*/";
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
return ret;
|
|
165
|
+
};
|
|
166
|
+
|
|
167
|
+
function squeeze_it(code) {
|
|
168
|
+
var result = "";
|
|
169
|
+
if (options.show_copyright) {
|
|
170
|
+
var tok = jsp.tokenizer(code), c;
|
|
171
|
+
c = tok();
|
|
172
|
+
result += show_copyright(c.comments_before);
|
|
173
|
+
}
|
|
174
|
+
try {
|
|
175
|
+
var ast = time_it("parse", function(){ return jsp.parse(code); });
|
|
176
|
+
if (options.mangle) ast = time_it("mangle", function(){
|
|
177
|
+
return pro.ast_mangle(ast, {
|
|
178
|
+
toplevel: options.mangle_toplevel,
|
|
179
|
+
except: options.reserved_names
|
|
180
|
+
});
|
|
181
|
+
});
|
|
182
|
+
if (options.squeeze) ast = time_it("squeeze", function(){
|
|
183
|
+
ast = pro.ast_squeeze(ast, {
|
|
184
|
+
make_seqs : options.make_seqs,
|
|
185
|
+
dead_code : options.dead_code,
|
|
186
|
+
keep_comps : !options.unsafe
|
|
187
|
+
});
|
|
188
|
+
if (options.unsafe)
|
|
189
|
+
ast = pro.ast_squeeze_more(ast);
|
|
190
|
+
return ast;
|
|
191
|
+
});
|
|
192
|
+
if (options.ast)
|
|
193
|
+
return sys.inspect(ast, null, null);
|
|
194
|
+
result += time_it("generate", function(){ return pro.gen_code(ast, options.codegen_options) });
|
|
195
|
+
if (!options.codegen_options.beautify && options.max_line_length) {
|
|
196
|
+
result = time_it("split", function(){ return pro.split_lines(result, options.max_line_length) });
|
|
197
|
+
}
|
|
198
|
+
return result;
|
|
199
|
+
} catch(ex) {
|
|
200
|
+
sys.debug(ex.stack);
|
|
201
|
+
sys.debug(sys.inspect(ex));
|
|
202
|
+
sys.debug(JSON.stringify(ex));
|
|
203
|
+
}
|
|
204
|
+
};
|
|
205
|
+
|
|
206
|
+
function time_it(name, cont) {
|
|
207
|
+
if (!options.verbose)
|
|
208
|
+
return cont();
|
|
209
|
+
var t1 = new Date().getTime();
|
|
210
|
+
try { return cont(); }
|
|
211
|
+
finally { sys.debug("// " + name + ": " + ((new Date().getTime() - t1) / 1000).toFixed(3) + " sec."); }
|
|
212
|
+
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
Copyright (c) 2011 Jeremy Ashkenas
|
|
2
|
+
|
|
3
|
+
Permission is hereby granted, free of charge, to any person
|
|
4
|
+
obtaining a copy of this software and associated documentation
|
|
5
|
+
files (the "Software"), to deal in the Software without
|
|
6
|
+
restriction, including without limitation the rights to use,
|
|
7
|
+
copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
8
|
+
copies of the Software, and to permit persons to whom the
|
|
9
|
+
Software is furnished to do so, subject to the following
|
|
10
|
+
conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be
|
|
13
|
+
included in all copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
16
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
|
17
|
+
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
18
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
|
19
|
+
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
|
20
|
+
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
21
|
+
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
|
22
|
+
OTHER DEALINGS IN THE SOFTWARE.
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
=
|
|
2
|
+
{
|
|
3
|
+
} } {
|
|
4
|
+
{ { } }
|
|
5
|
+
} }{ {
|
|
6
|
+
{ }{ } } _____ __ __
|
|
7
|
+
( }{ }{ { ) / ____| / _|/ _|
|
|
8
|
+
.- { { } { }} -. | | ___ | |_| |_ ___ ___
|
|
9
|
+
( ( } { } { } } ) | | / _ \| _| _/ _ \/ _ \
|
|
10
|
+
|`-..________ ..-'| | |___| (_) | | | || __/ __/
|
|
11
|
+
| | \_____\___/|_| |_| \___|\___|
|
|
12
|
+
| ;--.
|
|
13
|
+
| (__ \ _____ _ _
|
|
14
|
+
| | ) ) / ____| (_) | |
|
|
15
|
+
| |/ / | (___ ___ _ __ _ _ __ | |_
|
|
16
|
+
| ( / \___ \ / __| '__| | '_ \| __|
|
|
17
|
+
| |/ ____) | (__| | | | |_) | |_
|
|
18
|
+
| | |_____/ \___|_| |_| .__/ \__|
|
|
19
|
+
`-.._________..-' | |
|
|
20
|
+
|_|
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
CoffeeScript is a little language that compiles into JavaScript.
|
|
24
|
+
|
|
25
|
+
Install Node.js, and then the CoffeeScript compiler:
|
|
26
|
+
sudo bin/cake install
|
|
27
|
+
|
|
28
|
+
Or, if you have the Node Package Manager installed:
|
|
29
|
+
npm install -g coffee-script
|
|
30
|
+
(Leave off the -g if you don't wish to install globally.)
|
|
31
|
+
|
|
32
|
+
Compile a script:
|
|
33
|
+
coffee /path/to/script.coffee
|
|
34
|
+
|
|
35
|
+
For documentation, usage, and examples, see:
|
|
36
|
+
http://coffeescript.org/
|
|
37
|
+
|
|
38
|
+
To suggest a feature, report a bug, or general discussion:
|
|
39
|
+
http://github.com/jashkenas/coffee-script/issues/
|
|
40
|
+
|
|
41
|
+
If you'd like to chat, drop by #coffeescript on Freenode IRC,
|
|
42
|
+
or on webchat.freenode.net.
|
|
43
|
+
|
|
44
|
+
The source repository:
|
|
45
|
+
git://github.com/jashkenas/coffee-script.git
|
|
46
|
+
|
|
47
|
+
All contributors are listed here:
|
|
48
|
+
http://github.com/jashkenas/coffee-script/contributors
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
require 'rubygems'
|
|
2
|
+
require 'erb'
|
|
3
|
+
require 'fileutils'
|
|
4
|
+
require 'rake/testtask'
|
|
5
|
+
require 'json'
|
|
6
|
+
|
|
7
|
+
desc "Build the documentation page"
|
|
8
|
+
task :doc do
|
|
9
|
+
source = 'documentation/index.html.erb'
|
|
10
|
+
child = fork { exec "bin/coffee -bcw -o documentation/js documentation/coffee/*.coffee" }
|
|
11
|
+
at_exit { Process.kill("INT", child) }
|
|
12
|
+
Signal.trap("INT") { exit }
|
|
13
|
+
loop do
|
|
14
|
+
mtime = File.stat(source).mtime
|
|
15
|
+
if !@mtime || mtime > @mtime
|
|
16
|
+
rendered = ERB.new(File.read(source)).result(binding)
|
|
17
|
+
File.open('index.html', 'w+') {|f| f.write(rendered) }
|
|
18
|
+
end
|
|
19
|
+
@mtime = mtime
|
|
20
|
+
sleep 1
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
desc "Build coffee-script-source gem"
|
|
25
|
+
task :gem do
|
|
26
|
+
require 'rubygems'
|
|
27
|
+
require 'rubygems/package'
|
|
28
|
+
|
|
29
|
+
gemspec = Gem::Specification.new do |s|
|
|
30
|
+
s.name = 'coffee-script-source'
|
|
31
|
+
s.version = JSON.parse(File.read('package.json'))["version"]
|
|
32
|
+
s.date = Time.now.strftime("%Y-%m-%d")
|
|
33
|
+
|
|
34
|
+
s.homepage = "http://jashkenas.github.com/coffee-script/"
|
|
35
|
+
s.summary = "The CoffeeScript Compiler"
|
|
36
|
+
s.description = <<-EOS
|
|
37
|
+
CoffeeScript is a little language that compiles into JavaScript.
|
|
38
|
+
Underneath all of those embarrassing braces and semicolons,
|
|
39
|
+
JavaScript has always had a gorgeous object model at its heart.
|
|
40
|
+
CoffeeScript is an attempt to expose the good parts of JavaScript
|
|
41
|
+
in a simple way.
|
|
42
|
+
EOS
|
|
43
|
+
|
|
44
|
+
s.files = [
|
|
45
|
+
'lib/coffee_script/coffee-script.js',
|
|
46
|
+
'lib/coffee_script/source.rb'
|
|
47
|
+
]
|
|
48
|
+
|
|
49
|
+
s.authors = ['Jeremy Ashkenas']
|
|
50
|
+
s.email = 'jashkenas@gmail.com'
|
|
51
|
+
s.rubyforge_project = 'coffee-script-source'
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
file = File.open("coffee-script-source.gem", "w")
|
|
55
|
+
Gem::Package.open(file, 'w') do |pkg|
|
|
56
|
+
pkg.metadata = gemspec.to_yaml
|
|
57
|
+
|
|
58
|
+
path = "lib/coffee_script/source.rb"
|
|
59
|
+
contents = <<-ERUBY
|
|
60
|
+
module CoffeeScript
|
|
61
|
+
module Source
|
|
62
|
+
def self.bundled_path
|
|
63
|
+
File.expand_path("../coffee-script.js", __FILE__)
|
|
64
|
+
end
|
|
65
|
+
end
|
|
66
|
+
end
|
|
67
|
+
ERUBY
|
|
68
|
+
pkg.add_file_simple(path, 0644, contents.size) do |tar_io|
|
|
69
|
+
tar_io.write(contents)
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
contents = File.read("extras/coffee-script.js")
|
|
73
|
+
path = "lib/coffee_script/coffee-script.js"
|
|
74
|
+
pkg.add_file_simple(path, 0644, contents.size) do |tar_io|
|
|
75
|
+
tar_io.write(contents)
|
|
76
|
+
end
|
|
77
|
+
end
|
|
78
|
+
end
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
(function() {
|
|
2
|
+
var CoffeeScript, runScripts;
|
|
3
|
+
CoffeeScript = require('./coffee-script');
|
|
4
|
+
CoffeeScript.require = require;
|
|
5
|
+
CoffeeScript.eval = function(code, options) {
|
|
6
|
+
return eval(CoffeeScript.compile(code, options));
|
|
7
|
+
};
|
|
8
|
+
CoffeeScript.run = function(code, options) {
|
|
9
|
+
if (options == null) {
|
|
10
|
+
options = {};
|
|
11
|
+
}
|
|
12
|
+
options.bare = true;
|
|
13
|
+
return Function(CoffeeScript.compile(code, options))();
|
|
14
|
+
};
|
|
15
|
+
if (typeof window === "undefined" || window === null) {
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
CoffeeScript.load = function(url, callback) {
|
|
19
|
+
var xhr;
|
|
20
|
+
xhr = new (window.ActiveXObject || XMLHttpRequest)('Microsoft.XMLHTTP');
|
|
21
|
+
xhr.open('GET', url, true);
|
|
22
|
+
if ('overrideMimeType' in xhr) {
|
|
23
|
+
xhr.overrideMimeType('text/plain');
|
|
24
|
+
}
|
|
25
|
+
xhr.onreadystatechange = function() {
|
|
26
|
+
var _ref;
|
|
27
|
+
if (xhr.readyState === 4) {
|
|
28
|
+
if ((_ref = xhr.status) === 0 || _ref === 200) {
|
|
29
|
+
CoffeeScript.run(xhr.responseText);
|
|
30
|
+
} else {
|
|
31
|
+
throw new Error("Could not load " + url);
|
|
32
|
+
}
|
|
33
|
+
if (callback) {
|
|
34
|
+
return callback();
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
return xhr.send(null);
|
|
39
|
+
};
|
|
40
|
+
runScripts = function() {
|
|
41
|
+
var coffees, execute, index, length, s, scripts;
|
|
42
|
+
scripts = document.getElementsByTagName('script');
|
|
43
|
+
coffees = (function() {
|
|
44
|
+
var _i, _len, _results;
|
|
45
|
+
_results = [];
|
|
46
|
+
for (_i = 0, _len = scripts.length; _i < _len; _i++) {
|
|
47
|
+
s = scripts[_i];
|
|
48
|
+
if (s.type === 'text/coffeescript') {
|
|
49
|
+
_results.push(s);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
return _results;
|
|
53
|
+
})();
|
|
54
|
+
index = 0;
|
|
55
|
+
length = coffees.length;
|
|
56
|
+
(execute = function() {
|
|
57
|
+
var script;
|
|
58
|
+
script = coffees[index++];
|
|
59
|
+
if ((script != null ? script.type : void 0) === 'text/coffeescript') {
|
|
60
|
+
if (script.src) {
|
|
61
|
+
return CoffeeScript.load(script.src, execute);
|
|
62
|
+
} else {
|
|
63
|
+
CoffeeScript.run(script.innerHTML);
|
|
64
|
+
return execute();
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
})();
|
|
68
|
+
return null;
|
|
69
|
+
};
|
|
70
|
+
if (window.addEventListener) {
|
|
71
|
+
addEventListener('DOMContentLoaded', runScripts, false);
|
|
72
|
+
} else {
|
|
73
|
+
attachEvent('onload', runScripts);
|
|
74
|
+
}
|
|
75
|
+
}).call(this);
|