haml-more 0.4.0.a

Sign up to get free protection for your applications and to get access to all the features.
Files changed (225) hide show
  1. data/README.md +79 -0
  2. data/lib/haml/more/coffee_script.rb +137 -0
  3. data/lib/haml/more/content_for.rb +25 -0
  4. data/lib/haml/more.rb +45 -0
  5. data/lib/haml-more.rb +1 -0
  6. data/lib/sass/more.rb +16 -0
  7. data/lib/sass-more.rb +1 -0
  8. data/spec/sass/more_spec.rb +21 -0
  9. data/vendor/coffee-script/Cakefile +57 -0
  10. data/vendor/coffee-script/LICENSE +22 -0
  11. data/vendor/coffee-script/README +41 -0
  12. data/vendor/coffee-script/Rakefile +20 -0
  13. data/vendor/coffee-script/bin/cake +7 -0
  14. data/vendor/coffee-script/bin/coffee +7 -0
  15. data/vendor/coffee-script/documentation/coffee/aliases.coffee +9 -0
  16. data/vendor/coffee-script/documentation/coffee/arguments.coffee +4 -0
  17. data/vendor/coffee-script/documentation/coffee/array_comprehensions.coffee +7 -0
  18. data/vendor/coffee-script/documentation/coffee/assignment.coffee +2 -0
  19. data/vendor/coffee-script/documentation/coffee/cake_tasks.coffee +5 -0
  20. data/vendor/coffee-script/documentation/coffee/comparisons.coffee +5 -0
  21. data/vendor/coffee-script/documentation/coffee/conditionals.coffee +9 -0
  22. data/vendor/coffee-script/documentation/coffee/embedded.coffee +5 -0
  23. data/vendor/coffee-script/documentation/coffee/existence.coffee +8 -0
  24. data/vendor/coffee-script/documentation/coffee/expressions.coffee +9 -0
  25. data/vendor/coffee-script/documentation/coffee/expressions_assignment.coffee +1 -0
  26. data/vendor/coffee-script/documentation/coffee/expressions_comprehension.coffee +3 -0
  27. data/vendor/coffee-script/documentation/coffee/expressions_try.coffee +6 -0
  28. data/vendor/coffee-script/documentation/coffee/fat_arrow.coffee +6 -0
  29. data/vendor/coffee-script/documentation/coffee/functions.coffee +2 -0
  30. data/vendor/coffee-script/documentation/coffee/heredocs.coffee +5 -0
  31. data/vendor/coffee-script/documentation/coffee/multiple_return_values.coffee +5 -0
  32. data/vendor/coffee-script/documentation/coffee/object_comprehensions.coffee +4 -0
  33. data/vendor/coffee-script/documentation/coffee/object_extraction.coffee +13 -0
  34. data/vendor/coffee-script/documentation/coffee/objects_and_arrays.coffee +13 -0
  35. data/vendor/coffee-script/documentation/coffee/overview.coffee +29 -0
  36. data/vendor/coffee-script/documentation/coffee/parallel_assignment.coffee +4 -0
  37. data/vendor/coffee-script/documentation/coffee/range_comprehensions.coffee +6 -0
  38. data/vendor/coffee-script/documentation/coffee/scope.coffee +5 -0
  39. data/vendor/coffee-script/documentation/coffee/slices.coffee +6 -0
  40. data/vendor/coffee-script/documentation/coffee/soaks.coffee +1 -0
  41. data/vendor/coffee-script/documentation/coffee/splats.coffee +25 -0
  42. data/vendor/coffee-script/documentation/coffee/splices.coffee +5 -0
  43. data/vendor/coffee-script/documentation/coffee/strings.coffee +8 -0
  44. data/vendor/coffee-script/documentation/coffee/super.coffee +34 -0
  45. data/vendor/coffee-script/documentation/coffee/switch.coffee +10 -0
  46. data/vendor/coffee-script/documentation/coffee/try.coffee +7 -0
  47. data/vendor/coffee-script/documentation/coffee/while.coffee +10 -0
  48. data/vendor/coffee-script/documentation/css/docs.css +213 -0
  49. data/vendor/coffee-script/documentation/css/idle.css +63 -0
  50. data/vendor/coffee-script/documentation/css/logo.png +0 -0
  51. data/vendor/coffee-script/documentation/index.html.erb +967 -0
  52. data/vendor/coffee-script/documentation/js/aliases.js +14 -0
  53. data/vendor/coffee-script/documentation/js/arguments.js +8 -0
  54. data/vendor/coffee-script/documentation/js/array_comprehensions.js +26 -0
  55. data/vendor/coffee-script/documentation/js/assignment.js +5 -0
  56. data/vendor/coffee-script/documentation/js/cake_tasks.js +14 -0
  57. data/vendor/coffee-script/documentation/js/comparisons.js +5 -0
  58. data/vendor/coffee-script/documentation/js/conditionals.js +12 -0
  59. data/vendor/coffee-script/documentation/js/embedded.js +6 -0
  60. data/vendor/coffee-script/documentation/js/existence.js +7 -0
  61. data/vendor/coffee-script/documentation/js/expressions.js +13 -0
  62. data/vendor/coffee-script/documentation/js/expressions_assignment.js +4 -0
  63. data/vendor/coffee-script/documentation/js/expressions_comprehension.js +12 -0
  64. data/vendor/coffee-script/documentation/js/expressions_try.js +9 -0
  65. data/vendor/coffee-script/documentation/js/fat_arrow.js +15 -0
  66. data/vendor/coffee-script/documentation/js/functions.js +9 -0
  67. data/vendor/coffee-script/documentation/js/heredocs.js +4 -0
  68. data/vendor/coffee-script/documentation/js/intro.js +7 -0
  69. data/vendor/coffee-script/documentation/js/multiple_return_values.js +11 -0
  70. data/vendor/coffee-script/documentation/js/object_comprehensions.js +17 -0
  71. data/vendor/coffee-script/documentation/js/object_extraction.js +17 -0
  72. data/vendor/coffee-script/documentation/js/objects_and_arrays.js +10 -0
  73. data/vendor/coffee-script/documentation/js/overview.js +43 -0
  74. data/vendor/coffee-script/documentation/js/parallel_assignment.js +8 -0
  75. data/vendor/coffee-script/documentation/js/punctuation.js +8 -0
  76. data/vendor/coffee-script/documentation/js/range_comprehensions.js +21 -0
  77. data/vendor/coffee-script/documentation/js/scope.js +10 -0
  78. data/vendor/coffee-script/documentation/js/slices.js +6 -0
  79. data/vendor/coffee-script/documentation/js/soaks.js +4 -0
  80. data/vendor/coffee-script/documentation/js/splats.js +16 -0
  81. data/vendor/coffee-script/documentation/js/splices.js +5 -0
  82. data/vendor/coffee-script/documentation/js/strings.js +9 -0
  83. data/vendor/coffee-script/documentation/js/super.js +37 -0
  84. data/vendor/coffee-script/documentation/js/switch.js +18 -0
  85. data/vendor/coffee-script/documentation/js/try.js +10 -0
  86. data/vendor/coffee-script/documentation/js/while.js +22 -0
  87. data/vendor/coffee-script/documentation/underscore.html +627 -0
  88. data/vendor/coffee-script/examples/beautiful_code/binary_search.coffee +16 -0
  89. data/vendor/coffee-script/examples/beautiful_code/quicksort_runtime.coffee +13 -0
  90. data/vendor/coffee-script/examples/beautiful_code/regular_expression_matcher.coffee +34 -0
  91. data/vendor/coffee-script/examples/blocks.coffee +57 -0
  92. data/vendor/coffee-script/examples/code.coffee +173 -0
  93. data/vendor/coffee-script/examples/computer_science/README +4 -0
  94. data/vendor/coffee-script/examples/computer_science/binary_search.coffee +25 -0
  95. data/vendor/coffee-script/examples/computer_science/bubble_sort.coffee +11 -0
  96. data/vendor/coffee-script/examples/computer_science/linked_list.coffee +106 -0
  97. data/vendor/coffee-script/examples/computer_science/luhn_algorithm.coffee +36 -0
  98. data/vendor/coffee-script/examples/computer_science/merge_sort.coffee +19 -0
  99. data/vendor/coffee-script/examples/computer_science/selection_sort.coffee +23 -0
  100. data/vendor/coffee-script/examples/poignant.coffee +186 -0
  101. data/vendor/coffee-script/examples/potion.coffee +205 -0
  102. data/vendor/coffee-script/examples/underscore.coffee +603 -0
  103. data/vendor/coffee-script/examples/web_server.coffee +12 -0
  104. data/vendor/coffee-script/extras/CoffeeScript.tmbundle/Preferences/CoffeeScript.tmPreferences +24 -0
  105. data/vendor/coffee-script/extras/CoffeeScript.tmbundle/Syntaxes/CoffeeScript.tmLanguage +361 -0
  106. data/vendor/coffee-script/extras/CoffeeScript.tmbundle/info.plist +10 -0
  107. data/vendor/coffee-script/extras/EXTRAS +20 -0
  108. data/vendor/coffee-script/extras/coffee.vim +117 -0
  109. data/vendor/coffee-script/index.html +1847 -0
  110. data/vendor/coffee-script/lib/bin/cake +7 -0
  111. data/vendor/coffee-script/lib/bin/coffee +7 -0
  112. data/vendor/coffee-script/lib/cake.js +80 -0
  113. data/vendor/coffee-script/lib/coffee-script.js +61 -0
  114. data/vendor/coffee-script/lib/command_line.js +201 -0
  115. data/vendor/coffee-script/lib/grammar.js +564 -0
  116. data/vendor/coffee-script/lib/lexer.js +405 -0
  117. data/vendor/coffee-script/lib/narwhal.js +44 -0
  118. data/vendor/coffee-script/lib/nodes.js +1328 -0
  119. data/vendor/coffee-script/lib/optparse.js +117 -0
  120. data/vendor/coffee-script/lib/parser.js +536 -0
  121. data/vendor/coffee-script/lib/repl.js +32 -0
  122. data/vendor/coffee-script/lib/rewriter.js +383 -0
  123. data/vendor/coffee-script/lib/scope.js +114 -0
  124. data/vendor/coffee-script/package.json +7 -0
  125. data/vendor/coffee-script/src/cake.coffee +45 -0
  126. data/vendor/coffee-script/src/coffee-script.coffee +45 -0
  127. data/vendor/coffee-script/src/command_line.coffee +130 -0
  128. data/vendor/coffee-script/src/grammar.coffee +456 -0
  129. data/vendor/coffee-script/src/lexer.coffee +327 -0
  130. data/vendor/coffee-script/src/narwhal.coffee +42 -0
  131. data/vendor/coffee-script/src/nodes.coffee +1045 -0
  132. data/vendor/coffee-script/src/optparse.coffee +79 -0
  133. data/vendor/coffee-script/src/repl.coffee +23 -0
  134. data/vendor/coffee-script/src/rewriter.coffee +253 -0
  135. data/vendor/coffee-script/src/scope.coffee +75 -0
  136. data/vendor/coffee-script/test/test_arguments.coffee +34 -0
  137. data/vendor/coffee-script/test/test_array_comprehension.coffee +42 -0
  138. data/vendor/coffee-script/test/test_assignment.coffee +26 -0
  139. data/vendor/coffee-script/test/test_blocks.coffee +4 -0
  140. data/vendor/coffee-script/test/test_calling_super.coffee +42 -0
  141. data/vendor/coffee-script/test/test_chained_calls.coffee +25 -0
  142. data/vendor/coffee-script/test/test_destructuring_assignment.coffee +62 -0
  143. data/vendor/coffee-script/test/test_everything.coffee +29 -0
  144. data/vendor/coffee-script/test/test_exceptions.coffee +2 -0
  145. data/vendor/coffee-script/test/test_existence.coffee +81 -0
  146. data/vendor/coffee-script/test/test_expressions.coffee +30 -0
  147. data/vendor/coffee-script/test/test_fancy_if_statement.coffee +26 -0
  148. data/vendor/coffee-script/test/test_functions.coffee +80 -0
  149. data/vendor/coffee-script/test/test_funky_comments.coffee +25 -0
  150. data/vendor/coffee-script/test/test_heredocs.coffee +46 -0
  151. data/vendor/coffee-script/test/test_lexical_scope.coffee +10 -0
  152. data/vendor/coffee-script/test/test_literals.coffee +56 -0
  153. data/vendor/coffee-script/test/test_nested_comprehensions.coffee +11 -0
  154. data/vendor/coffee-script/test/test_newline_escaping.coffee +6 -0
  155. data/vendor/coffee-script/test/test_operations.coffee +18 -0
  156. data/vendor/coffee-script/test/test_range_comprehension.coffee +20 -0
  157. data/vendor/coffee-script/test/test_ranges_and_slices.coffee +16 -0
  158. data/vendor/coffee-script/test/test_splats.coffee +47 -0
  159. data/vendor/coffee-script/test/test_splices.coffee +5 -0
  160. data/vendor/coffee-script/test/test_switch.coffee +64 -0
  161. data/vendor/coffee-script/test/test_while.coffee +30 -0
  162. data/vendor/coffee-script/vendor/jison/Jakefile +31 -0
  163. data/vendor/coffee-script/vendor/jison/README.md +347 -0
  164. data/vendor/coffee-script/vendor/jison/bin/jison +3 -0
  165. data/vendor/coffee-script/vendor/jison/bin/json2jison +3 -0
  166. data/vendor/coffee-script/vendor/jison/examples/ansic.jison +415 -0
  167. data/vendor/coffee-script/vendor/jison/examples/basic.json +8 -0
  168. data/vendor/coffee-script/vendor/jison/examples/basic2.json +9 -0
  169. data/vendor/coffee-script/vendor/jison/examples/basic2_lex.json +16 -0
  170. data/vendor/coffee-script/vendor/jison/examples/basic_lex.json +15 -0
  171. data/vendor/coffee-script/vendor/jison/examples/calculator.jison +38 -0
  172. data/vendor/coffee-script/vendor/jison/examples/calculator.jisonlex +14 -0
  173. data/vendor/coffee-script/vendor/jison/examples/calculator.json +42 -0
  174. data/vendor/coffee-script/vendor/jison/examples/classy.json +105 -0
  175. data/vendor/coffee-script/vendor/jison/examples/classy_ast.json +126 -0
  176. data/vendor/coffee-script/vendor/jison/examples/dism.json +25 -0
  177. data/vendor/coffee-script/vendor/jison/examples/dism_lr0.json +26 -0
  178. data/vendor/coffee-script/vendor/jison/examples/json.js +80 -0
  179. data/vendor/coffee-script/vendor/jison/examples/json_ast.js +83 -0
  180. data/vendor/coffee-script/vendor/jison/examples/precedence.json +26 -0
  181. data/vendor/coffee-script/vendor/jison/examples/reduce_conflict.json +13 -0
  182. data/vendor/coffee-script/vendor/jison/lib/jison/bnf.js +43 -0
  183. data/vendor/coffee-script/vendor/jison/lib/jison/jisonlex.js +18 -0
  184. data/vendor/coffee-script/vendor/jison/lib/jison/json2jison.js +146 -0
  185. data/vendor/coffee-script/vendor/jison/lib/jison/lexer.js +224 -0
  186. data/vendor/coffee-script/vendor/jison/lib/jison/util/bnf-parser.js +383 -0
  187. data/vendor/coffee-script/vendor/jison/lib/jison/util/lex-parser.js +407 -0
  188. data/vendor/coffee-script/vendor/jison/lib/jison/util/set.js +94 -0
  189. data/vendor/coffee-script/vendor/jison/lib/jison/util/typal.js +90 -0
  190. data/vendor/coffee-script/vendor/jison/lib/jison.js +1414 -0
  191. data/vendor/coffee-script/vendor/jison/package.json +14 -0
  192. data/vendor/coffee-script/vendor/jison/src/bnf.jison +110 -0
  193. data/vendor/coffee-script/vendor/jison/src/bnf.jisonlex +25 -0
  194. data/vendor/coffee-script/vendor/jison/src/bnf.lex.json +24 -0
  195. data/vendor/coffee-script/vendor/jison/src/jisonlex.jison +129 -0
  196. data/vendor/coffee-script/vendor/jison/src/jisonlex.jisonlex +31 -0
  197. data/vendor/coffee-script/vendor/jison/src/jisonlex.lex.json +30 -0
  198. data/vendor/coffee-script/vendor/jison/tests/all-tests.js +8 -0
  199. data/vendor/coffee-script/vendor/jison/tests/grammar/bnf.js +91 -0
  200. data/vendor/coffee-script/vendor/jison/tests/grammar/bnf_parse.js +65 -0
  201. data/vendor/coffee-script/vendor/jison/tests/grammar/grammar-tests.js +10 -0
  202. data/vendor/coffee-script/vendor/jison/tests/grammar/json2jison.js +24 -0
  203. data/vendor/coffee-script/vendor/jison/tests/grammar/lex/ansic.jisonlex +115 -0
  204. data/vendor/coffee-script/vendor/jison/tests/grammar/lex/bnf.jisonlex +25 -0
  205. data/vendor/coffee-script/vendor/jison/tests/grammar/lex/bnf.lex.json +24 -0
  206. data/vendor/coffee-script/vendor/jison/tests/grammar/lex/lex_grammar.jisonlex +31 -0
  207. data/vendor/coffee-script/vendor/jison/tests/grammar/lex/lex_grammar.lex.json +30 -0
  208. data/vendor/coffee-script/vendor/jison/tests/grammar/lex.jison +119 -0
  209. data/vendor/coffee-script/vendor/jison/tests/grammar/lex.js +58 -0
  210. data/vendor/coffee-script/vendor/jison/tests/grammar/lex_parse.js +117 -0
  211. data/vendor/coffee-script/vendor/jison/tests/lexer/lexer-tests.js +6 -0
  212. data/vendor/coffee-script/vendor/jison/tests/lexer/regexplexer.js +417 -0
  213. data/vendor/coffee-script/vendor/jison/tests/parser/actions.js +311 -0
  214. data/vendor/coffee-script/vendor/jison/tests/parser/api.js +236 -0
  215. data/vendor/coffee-script/vendor/jison/tests/parser/generator.js +196 -0
  216. data/vendor/coffee-script/vendor/jison/tests/parser/lalr.js +183 -0
  217. data/vendor/coffee-script/vendor/jison/tests/parser/lr0.js +72 -0
  218. data/vendor/coffee-script/vendor/jison/tests/parser/lr1.js +119 -0
  219. data/vendor/coffee-script/vendor/jison/tests/parser/parser-tests.js +14 -0
  220. data/vendor/coffee-script/vendor/jison/tests/parser/precedence.js +237 -0
  221. data/vendor/coffee-script/vendor/jison/tests/parser/slr.js +52 -0
  222. data/vendor/coffee-script/vendor/jison/tests/parser/tables.js +126 -0
  223. data/vendor/coffee-script/vendor/jison/tests/performance.js +110 -0
  224. data/vendor/coffee-script/vendor/jison/tests/setup.js +3 -0
  225. metadata +324 -0
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/env node
2
+
3
+ process.mixin(require('sys'));
4
+
5
+ require.paths.unshift('/usr/local/lib/coffee-script/lib');
6
+
7
+ require('cake').run();
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/env node
2
+
3
+ process.mixin(require('sys'));
4
+
5
+ require.paths.unshift('/usr/local/lib/coffee-script/lib');
6
+
7
+ require('command_line').run();
@@ -0,0 +1,80 @@
1
+ (function(){
2
+ var coffee, fs, no_such_task, path, print_tasks, tasks;
3
+ var __hasProp = Object.prototype.hasOwnProperty;
4
+ // `cake` is a simplified version of Make (Rake, Jake) for CoffeeScript.
5
+ fs = require('fs');
6
+ path = require('path');
7
+ coffee = require('coffee-script');
8
+ tasks = {};
9
+ no_such_task = function no_such_task(task) {
10
+ process.stdio.writeError('No such task: "' + task + '"\n');
11
+ return process.exit(1);
12
+ };
13
+ // Mixin the Cake functionality.
14
+ process.mixin({
15
+ // Define a task with a name, a description, and the action itself.
16
+ task: function task(name, description, action) {
17
+ return tasks[name] = {
18
+ name: name,
19
+ description: description,
20
+ action: action
21
+ };
22
+ },
23
+ // Invoke another task in the Cakefile.
24
+ invoke: function invoke(name) {
25
+ if (!(tasks[name])) {
26
+ no_such_task(name);
27
+ }
28
+ return tasks[name].action();
29
+ }
30
+ });
31
+ // Display the list of Cake tasks.
32
+ print_tasks = function print_tasks() {
33
+ var _a, _b, _c, _d, _e, _f, _g, i, name, spaces, task;
34
+ _a = []; _b = tasks;
35
+ for (name in _b) { if (__hasProp.call(_b, name)) {
36
+ task = _b[name];
37
+ _a.push((function() {
38
+ spaces = 20 - name.length;
39
+ spaces = spaces > 0 ? (function() {
40
+ _c = []; _f = 0; _g = spaces;
41
+ for (_e = 0, i=_f; (_f <= _g ? i <= _g : i >= _g); (_f <= _g ? i += 1 : i -= 1), _e++) {
42
+ _c.push(' ');
43
+ }
44
+ return _c;
45
+ }).call(this).join('') : '';
46
+ return puts("cake " + name + spaces + ' # ' + task.description);
47
+ }).call(this));
48
+ }}
49
+ return _a;
50
+ };
51
+ // Running `cake` runs the tasks you pass asynchronously (node-style), or
52
+ // prints them out, with no arguments.
53
+ exports.run = function run() {
54
+ return path.exists('Cakefile', function(exists) {
55
+ var args;
56
+ if (!(exists)) {
57
+ throw new Error('Cakefile not found in ' + process.cwd());
58
+ }
59
+ args = process.ARGV.slice(2, process.ARGV.length);
60
+ return fs.readFile('Cakefile', function(err, source) {
61
+ var _a, _b, _c, arg;
62
+ eval(coffee.compile(source));
63
+ if (!(args.length)) {
64
+ return print_tasks();
65
+ }
66
+ _a = []; _b = args;
67
+ for (_c = 0; _c < _b.length; _c++) {
68
+ arg = _b[_c];
69
+ _a.push((function() {
70
+ if (!(tasks[arg])) {
71
+ no_such_task(arg);
72
+ }
73
+ return tasks[arg].action();
74
+ }).call(this));
75
+ }
76
+ return _a;
77
+ });
78
+ });
79
+ };
80
+ })();
@@ -0,0 +1,61 @@
1
+ (function(){
2
+ var lexer, parser, path;
3
+ // Set up for both the browser and the server.
4
+ if ((typeof process !== "undefined" && process !== null)) {
5
+ process.mixin(require('nodes'));
6
+ path = require('path');
7
+ lexer = new (require('lexer').Lexer)();
8
+ parser = require('parser').parser;
9
+ } else {
10
+ lexer = new Lexer();
11
+ parser = exports.parser;
12
+ this.exports = (this.CoffeeScript = {});
13
+ }
14
+ // Thin wrapper for Jison compatibility around the real lexer.
15
+ parser.lexer = {
16
+ lex: function lex() {
17
+ var token;
18
+ token = this.tokens[this.pos] || [""];
19
+ this.pos += 1;
20
+ this.yylineno = token[2];
21
+ this.yytext = token[1];
22
+ return token[0];
23
+ },
24
+ setInput: function setInput(tokens) {
25
+ this.tokens = tokens;
26
+ return this.pos = 0;
27
+ },
28
+ upcomingInput: function upcomingInput() {
29
+ return "";
30
+ },
31
+ showPosition: function showPosition() {
32
+ return this.pos;
33
+ }
34
+ };
35
+ exports.VERSION = '0.5.1';
36
+ // Compile CoffeeScript to JavaScript, using the Coffee/Jison compiler.
37
+ exports.compile = function compile(code, options) {
38
+ return (parser.parse(lexer.tokenize(code))).compile(options);
39
+ };
40
+ // Just the tokens.
41
+ exports.tokenize = function tokenize(code) {
42
+ return lexer.tokenize(code);
43
+ };
44
+ // Just the nodes.
45
+ exports.tree = function tree(code) {
46
+ return parser.parse(lexer.tokenize(code));
47
+ };
48
+ // Pretty-print a token stream.
49
+ exports.print_tokens = function print_tokens(tokens) {
50
+ var _a, _b, _c, strings, token;
51
+ strings = (function() {
52
+ _a = []; _b = tokens;
53
+ for (_c = 0; _c < _b.length; _c++) {
54
+ token = _b[_c];
55
+ _a.push('[' + token[0] + ' ' + token[1].toString().replace(/\n/, '\\n') + ']');
56
+ }
57
+ return _a;
58
+ }).call(this);
59
+ return puts(strings.join(' '));
60
+ };
61
+ })();
@@ -0,0 +1,201 @@
1
+ (function(){
2
+ var BANNER, SWITCHES, coffee, compile_script, compile_scripts, fs, lint, option_parser, options, optparse, parse_options, path, sources, usage, version, watch_scripts, write_js;
3
+ fs = require('fs');
4
+ path = require('path');
5
+ coffee = require('coffee-script');
6
+ optparse = require('optparse');
7
+ BANNER = "coffee compiles CoffeeScript source files into JavaScript.\n\nUsage:\n coffee path/to/script.coffee";
8
+ SWITCHES = [['-i', '--interactive', 'run an interactive CoffeeScript REPL'], ['-r', '--run', 'compile and run a CoffeeScript'], ['-o', '--output [DIR]', 'set the directory for compiled JavaScript'], ['-w', '--watch', 'watch scripts for changes, and recompile'], ['-p', '--print', 'print the compiled JavaScript to stdout'], ['-l', '--lint', 'pipe the compiled JavaScript through JSLint'], ['-e', '--eval', 'compile a string from the command line'], ['-t', '--tokens', 'print the tokens that the lexer produces'], ['-tr', '--tree', 'print the parse tree that Jison produces'], ['-n', '--no-wrap', 'compile without the top-level function wrapper'], ['-v', '--version', 'display CoffeeScript version'], ['-h', '--help', 'display this help message']];
9
+ options = {};
10
+ sources = [];
11
+ option_parser = null;
12
+ // The CommandLine handles all of the functionality of the `coffee` utility.
13
+ exports.run = function run() {
14
+ var flags, separator;
15
+ parse_options();
16
+ if (options.interactive) {
17
+ return require('repl');
18
+ }
19
+ if (options.eval) {
20
+ return compile_script('terminal', sources[0]);
21
+ }
22
+ if (!(sources.length)) {
23
+ usage();
24
+ }
25
+ separator = sources.indexOf('--');
26
+ flags = [];
27
+ if (separator >= 0) {
28
+ flags = sources.slice((separator + 1), sources.length);
29
+ sources = sources.slice(0, separator);
30
+ }
31
+ process.ARGV = flags;
32
+ if (options.watch) {
33
+ watch_scripts();
34
+ }
35
+ compile_scripts();
36
+ return this;
37
+ };
38
+ // The "--help" usage message.
39
+ usage = function usage() {
40
+ puts('\n' + option_parser.help() + '\n');
41
+ return process.exit(0);
42
+ };
43
+ // The "--version" message.
44
+ version = function version() {
45
+ puts("CoffeeScript version " + coffee.VERSION);
46
+ return process.exit(0);
47
+ };
48
+ // Compiles the source CoffeeScript, returning the desired JavaScript, tokens,
49
+ // or JSLint results.
50
+ compile_scripts = function compile_scripts() {
51
+ var _a, _b, _c, compile, source;
52
+ compile = function compile(source) {
53
+ return fs.readFile(source, function(err, code) {
54
+ return compile_script(source, code);
55
+ });
56
+ };
57
+ _a = []; _b = sources;
58
+ for (_c = 0; _c < _b.length; _c++) {
59
+ source = _b[_c];
60
+ _a.push(compile(source));
61
+ }
62
+ return _a;
63
+ };
64
+ // Compile a single source script, containing the given code, according to the
65
+ // requested options. Both compile_scripts and watch_scripts share this method.
66
+ compile_script = function compile_script(source, code) {
67
+ var js, o, opts;
68
+ opts = options;
69
+ o = opts.no_wrap ? {
70
+ no_wrap: true
71
+ } : {};
72
+ try {
73
+ if (opts.tokens) {
74
+ return coffee.print_tokens(coffee.tokenize(code));
75
+ } else if (opts.tree) {
76
+ return puts(coffee.tree(code).toString());
77
+ } else {
78
+ js = coffee.compile(code, o);
79
+ if (opts.run) {
80
+ return eval(js);
81
+ } else if (opts.lint) {
82
+ return lint(js);
83
+ } else if (opts.print || opts.eval) {
84
+ return puts(js);
85
+ } else {
86
+ return write_js(source, js);
87
+ }
88
+ }
89
+ } catch (err) {
90
+ if (opts.watch) {
91
+ return puts(err.message);
92
+ } else {
93
+ throw err;
94
+ }
95
+ }
96
+ };
97
+ // Watch a list of source CoffeeScript files, recompiling them every time the
98
+ // files are updated.
99
+ watch_scripts = function watch_scripts() {
100
+ var _a, _b, _c, source, watch;
101
+ watch = function watch(source) {
102
+ return process.watchFile(source, {
103
+ persistent: true,
104
+ interval: 500
105
+ }, function(curr, prev) {
106
+ if (curr.mtime.getTime() === prev.mtime.getTime()) {
107
+ return null;
108
+ }
109
+ return fs.readFile(source, function(err, code) {
110
+ return compile_script(source, code);
111
+ });
112
+ });
113
+ };
114
+ _a = []; _b = sources;
115
+ for (_c = 0; _c < _b.length; _c++) {
116
+ source = _b[_c];
117
+ _a.push(watch(source));
118
+ }
119
+ return _a;
120
+ };
121
+ // Write out a JavaScript source file with the compiled code.
122
+ write_js = function write_js(source, js) {
123
+ var dir, filename, js_path;
124
+ filename = path.basename(source, path.extname(source)) + '.js';
125
+ dir = options.output || path.dirname(source);
126
+ js_path = path.join(dir, filename);
127
+ return fs.writeFile(js_path, js);
128
+ };
129
+ // Pipe compiled JS through JSLint (requires a working 'jsl' command).
130
+ lint = function lint(js) {
131
+ var jsl;
132
+ jsl = process.createChildProcess('jsl', ['-nologo', '-stdin']);
133
+ jsl.addListener('output', function(result) {
134
+ if (result) {
135
+ return puts(result.replace(/\n/g, ''));
136
+ }
137
+ });
138
+ jsl.addListener('error', function(result) {
139
+ if (result) {
140
+ return puts(result);
141
+ }
142
+ });
143
+ jsl.write(js);
144
+ return jsl.close();
145
+ };
146
+ // Use OptionParser for all the options.
147
+ parse_options = function parse_options() {
148
+ var oparser, opts, paths;
149
+ opts = (options = {});
150
+ oparser = (option_parser = new optparse.OptionParser(SWITCHES));
151
+ oparser.banner = BANNER;
152
+ oparser.add('interactive', function() {
153
+ return opts.interactive = true;
154
+ });
155
+ oparser.add('run', function() {
156
+ return opts.run = true;
157
+ });
158
+ oparser.add('output', function(dir) {
159
+ return opts.output = dir;
160
+ });
161
+ oparser.add('watch', function() {
162
+ return opts.watch = true;
163
+ });
164
+ oparser.add('print', function() {
165
+ return opts.print = true;
166
+ });
167
+ oparser.add('lint', function() {
168
+ return opts.lint = true;
169
+ });
170
+ oparser.add('eval', function() {
171
+ return opts.eval = true;
172
+ });
173
+ oparser.add('tokens', function() {
174
+ return opts.tokens = true;
175
+ });
176
+ oparser.add('tree', function() {
177
+ return opts.tree = true;
178
+ });
179
+ oparser.add('no-wrap', function() {
180
+ return opts.no_wrap = true;
181
+ });
182
+ oparser.add('help', (function(__this) {
183
+ var __func = function() {
184
+ return usage();
185
+ };
186
+ return (function() {
187
+ return __func.apply(__this, arguments);
188
+ });
189
+ })(this));
190
+ oparser.add('version', (function(__this) {
191
+ var __func = function() {
192
+ return version();
193
+ };
194
+ return (function() {
195
+ return __func.apply(__this, arguments);
196
+ });
197
+ })(this));
198
+ paths = oparser.parse(process.ARGV);
199
+ return sources = paths.slice(2, paths.length);
200
+ };
201
+ })();