From 3c67d54bbe3e993411564fa50ef8fb3a1e941ad5 Mon Sep 17 00:00:00 2001 From: Jeremy Ashkenas Date: Sat, 26 Dec 2009 08:57:13 -0800 Subject: [PATCH] changed bin/coffee-script to bin/coffee --- README | 2 +- Rakefile | 4 +-- bin/{coffee-script => coffee} | 0 coffee-script.gemspec | 2 +- documentation/index.html.erb | 18 ++++++------ documentation/js/array_comprehensions.js | 8 ++++- index.html | 29 ++++++++++++------- lib/coffee_script/command_line.rb | 10 +++---- .../narwhal/coffee-script.coffee | 6 ++-- lib/coffee_script/narwhal/js/coffee-script.js | 6 ++-- lib/coffee_script/nodes.rb | 7 +++++ test/unit/test_execution.rb | 8 ++--- 12 files changed, 61 insertions(+), 39 deletions(-) rename bin/{coffee-script => coffee} (100%) diff --git a/README b/README index 04fb649f..79d1679c 100644 --- a/README +++ b/README @@ -26,7 +26,7 @@ gem install coffee-script Compile a script: - coffee-script /path/to/script.coffee + coffee /path/to/script.coffee For documentation, usage, and examples, see: http://jashkenas.github.com/coffee-script/ diff --git a/Rakefile b/Rakefile index 1891f84f..51f7b2a3 100644 --- a/Rakefile +++ b/Rakefile @@ -19,7 +19,7 @@ namespace :build do desc "Compile the Narwhal interface for --interactive and --run" task :narwhal do - sh "bin/coffee-script lib/coffee_script/narwhal/*.coffee -o lib/coffee_script/narwhal/js" + sh "bin/coffee lib/coffee_script/narwhal/*.coffee -o lib/coffee_script/narwhal/js" end end @@ -27,7 +27,7 @@ end desc "Build the documentation page" task :doc do source = 'documentation/index.html.erb' - child = fork { exec "bin/coffee-script documentation/coffee/*.coffee -o documentation/js -w" } + child = fork { exec "bin/coffee documentation/coffee/*.coffee -o documentation/js -w" } at_exit { Process.kill("INT", child) } Signal.trap("INT") { exit } loop do diff --git a/bin/coffee-script b/bin/coffee similarity index 100% rename from bin/coffee-script rename to bin/coffee diff --git a/coffee-script.gemspec b/coffee-script.gemspec index b7daca48..4377b76e 100644 --- a/coffee-script.gemspec +++ b/coffee-script.gemspec @@ -20,7 +20,7 @@ Gem::Specification.new do |s| s.has_rdoc = false s.require_paths = ['lib'] - s.executables = ['coffee-script'] + s.executables = ['coffee'] s.files = Dir['bin/*', 'examples/*', 'lib/**/*', 'coffee-script.gemspec', 'LICENSE', 'README'] end \ No newline at end of file diff --git a/documentation/index.html.erb b/documentation/index.html.erb index 6bf5ece6..f6961e9c 100644 --- a/documentation/index.html.erb +++ b/documentation/index.html.erb @@ -91,12 +91,12 @@ gem install coffee-script

- Installing the gem provides the coffee-script command, which can + Installing the gem provides the coffee command, which can be used to compile CoffeeScript .coffee files into JavaScript, as well as debug them. In conjunction with - Narwhal, the coffee-script + Narwhal, the coffee command also provides direct evaluation and an interactive REPL. - When compiling to JavaScript, coffee-script writes the output + When compiling to JavaScript, coffee writes the output as .js files in the same directory by default, but output can be customized with the following options:

@@ -148,7 +148,7 @@ gem install coffee-script -e, --eval Compile and print a little snippet of CoffeeScript directly from the - command line (or from stdin). For example:
coffee-script -e "square: x => x * x." + command line (or from stdin). For example:
coffee -e "square: x => x * x." @@ -187,10 +187,10 @@ gem install coffee-script

-coffee-script path/to/script.coffee
-coffee-script --interactive
-coffee-script --watch --lint experimental.coffee
-coffee-script --print app/scripts/*.coffee > concatenation.js
+coffee path/to/script.coffee +coffee --interactive +coffee --watch --lint experimental.coffee +coffee --print app/scripts/*.coffee > concatenation.js

Language Reference

@@ -470,7 +470,7 @@ coffee-script --print app/scripts/*.coffee > concatenation.js

0.1.3 - The coffee-script command now includes --interactive, + The coffee command now includes --interactive, which launches an interactive CoffeeScript session, and --run, which directly compiles and executes a script. Both options depend on a working installation of Narwhal. diff --git a/documentation/js/array_comprehensions.js b/documentation/js/array_comprehensions.js index 636ccb49..8d13577e 100644 --- a/documentation/js/array_comprehensions.js +++ b/documentation/js/array_comprehensions.js @@ -1,5 +1,5 @@ (function(){ - var __a, __b, __c, __d, __e, __f, __g, __h, food, i, lunch, row; + var __a, __b, __c, __d, __e, __f, __g, __h, __i, __j, __k, __l, food, i, lunch, row; // Eat lunch. __a = ['toast', 'cheese', 'wine']; __d = []; @@ -17,4 +17,10 @@ __h[__f] = i % 2 === 0 ? highlight(row) : null; } __h; + // Check the first one hundred combinations. + __k = []; + for (__l=0, i=1, __j=100; i<=__j; i++, __l++) { + __k[__l] = lockpick(combinations[i]); + } + __k; })(); \ No newline at end of file diff --git a/index.html b/index.html index 615fd9be..dea5b729 100644 --- a/index.html +++ b/index.html @@ -159,12 +159,12 @@ cubed_list = __d; gem install coffee-script

- Installing the gem provides the coffee-script command, which can + Installing the gem provides the coffee command, which can be used to compile CoffeeScript .coffee files into JavaScript, as well as debug them. In conjunction with - Narwhal, the coffee-script + Narwhal, the coffee command also provides direct evaluation and an interactive REPL. - When compiling to JavaScript, coffee-script writes the output + When compiling to JavaScript, coffee writes the output as .js files in the same directory by default, but output can be customized with the following options:

@@ -216,7 +216,7 @@ gem install coffee-script -e, --eval Compile and print a little snippet of CoffeeScript directly from the - command line (or from stdin). For example:
coffee-script -e "square: x => x * x." + command line (or from stdin). For example:
coffee -e "square: x => x * x." @@ -255,10 +255,10 @@ gem install coffee-script

-coffee-script path/to/script.coffee
-coffee-script --interactive
-coffee-script --watch --lint experimental.coffee
-coffee-script --print app/scripts/*.coffee > concatenation.js
+coffee path/to/script.coffee +coffee --interactive +coffee --watch --lint experimental.coffee +coffee --print app/scripts/*.coffee > concatenation.js

Language Reference

@@ -580,7 +580,10 @@ lunch: food.eat() for # Zebra-stripe a table. highlight(row) for row, i in table if i % 2 is 0. -
var __a, __b, __c, __d, __e, __f, __g, __h, food, i, lunch, row;
+
+# Check the first one hundred combinations.
+lockpick(combinations[i]) for i in [1..100].
+
var __a, __b, __c, __d, __e, __f, __g, __h, __i, __j, __k, __l, food, i, lunch, row;
 // Eat lunch.
 __a = ['toast', 'cheese', 'wine'];
 __d = [];
@@ -598,6 +601,12 @@ __h = [];
   __h[__f] = i % 2 === 0 ? highlight(row) : null;
 }
 __h;
+// Check the first one hundred combinations.
+__k = [];
+for (__l=0, i=1, __j=100; i<=__j; i++, __l++) {
+  __k[__l] = lockpick(combinations[i]);
+}
+__k;
 

@@ -889,7 +898,7 @@ world...";

0.1.3 - The coffee-script command now includes --interactive, + The coffee command now includes --interactive, which launches an interactive CoffeeScript session, and --run, which directly compiles and executes a script. Both options depend on a working installation of Narwhal. diff --git a/lib/coffee_script/command_line.rb b/lib/coffee_script/command_line.rb index f09f400d..afa5fdab 100644 --- a/lib/coffee_script/command_line.rb +++ b/lib/coffee_script/command_line.rb @@ -5,15 +5,15 @@ require File.expand_path(File.dirname(__FILE__) + '/../coffee-script') module CoffeeScript - # The CommandLine handles all of the functionality of the `coffee-script` + # The CommandLine handles all of the functionality of the `coffee` # utility. class CommandLine BANNER = <<-EOS -coffee-script compiles CoffeeScript source files into JavaScript. +coffee compiles CoffeeScript source files into JavaScript. Usage: - coffee-script path/to/script.coffee + coffee path/to/script.coffee EOS # Seconds to pause between checks for changed source files. @@ -190,8 +190,8 @@ Usage: install_bundle exit end - opts.on_tail('--version', 'display coffee-script version') do - puts "coffee-script version #{CoffeeScript::VERSION}" + opts.on_tail('--version', 'display CoffeeScript version') do + puts "CoffeeScript version #{CoffeeScript::VERSION}" exit end opts.on_tail('-h', '--help', 'display this help message') do diff --git a/lib/coffee_script/narwhal/coffee-script.coffee b/lib/coffee_script/narwhal/coffee-script.coffee index 42bcc5ca..5271b29d 100644 --- a/lib/coffee_script/narwhal/coffee-script.coffee +++ b/lib/coffee_script/narwhal/coffee-script.coffee @@ -1,6 +1,6 @@ # This (javascript) file is generated from lib/coffee_script/narwhal/coffee-script.coffee -# Executes the `coffee-script` Ruby program to convert from CoffeeScript +# Executes the `coffee` Ruby program to convert from CoffeeScript # to Javascript. Eventually this will hopefully happen entirely within JS. # Require external dependencies. @@ -9,13 +9,13 @@ File: require('file') Readline: require('readline') # The path to the CoffeeScript Compiler. -coffeePath: File.path(module.path).dirname().dirname().dirname().dirname().dirname().join('bin', 'coffee-script') +coffeePath: File.path(module.path).dirname().dirname().dirname().dirname().dirname().join('bin', 'coffee') # Our general-purpose error handler. checkForErrors: coffeeProcess => return true if coffeeProcess.wait() is 0 system.stderr.print(coffeeProcess.stderr.read()) - throw new Error("coffee-script compile error"). + throw new Error("CoffeeScript compile error"). # Run a simple REPL, round-tripping to the CoffeeScript compiler for every # command. diff --git a/lib/coffee_script/narwhal/js/coffee-script.js b/lib/coffee_script/narwhal/js/coffee-script.js index d24c3812..4be0e13d 100644 --- a/lib/coffee_script/narwhal/js/coffee-script.js +++ b/lib/coffee_script/narwhal/js/coffee-script.js @@ -1,19 +1,19 @@ (function(){ var File, OS, Readline, checkForErrors, coffeePath; - // This (javascript) file is generated from lib/coffee_script/narwhal/coffee-script.coffee Executes the `coffee-script` Ruby program to convert from CoffeeScript + // This (javascript) file is generated from lib/coffee_script/narwhal/coffee-script.coffee Executes the `coffee` Ruby program to convert from CoffeeScript // to Javascript. Eventually this will hopefully happen entirely within JS. Require external dependencies. OS = require('os'); File = require('file'); Readline = require('readline'); // The path to the CoffeeScript Compiler. - coffeePath = File.path(module.path).dirname().dirname().dirname().dirname().dirname().join('bin', 'coffee-script'); + coffeePath = File.path(module.path).dirname().dirname().dirname().dirname().dirname().join('bin', 'coffee'); // Our general-purpose error handler. checkForErrors = function(coffeeProcess) { if (coffeeProcess.wait() === 0) { return true; } system.stderr.print(coffeeProcess.stderr.read()); - throw new Error("coffee-script compile error"); + throw new Error("CoffeeScript compile error"); }; // Run a simple REPL, round-tripping to the CoffeeScript compiler for every // command. diff --git a/lib/coffee_script/nodes.rb b/lib/coffee_script/nodes.rb index 7b73e80f..f0f63dc2 100644 --- a/lib/coffee_script/nodes.rb +++ b/lib/coffee_script/nodes.rb @@ -320,6 +320,13 @@ module CoffeeScript @exclusive end + # TODO -- figure out if we can detect if a range runs negative. + def downward? + + end + + # TODO -- figure out if we can expand ranges into the corresponding array, + # as an expression, reliably. def compile(o={}) write() end diff --git a/test/unit/test_execution.rb b/test/unit/test_execution.rb index f5335e57..0737fdd3 100644 --- a/test/unit/test_execution.rb +++ b/test/unit/test_execution.rb @@ -7,21 +7,21 @@ class ExecutionTest < Test::Unit::TestCase def test_execution_of_coffeescript sources = ['test/fixtures/execution/*.coffee'].join(' ') - assert `bin/coffee-script -r #{sources}`.match(ALLS_WELL) + assert `bin/coffee -r #{sources}`.match(ALLS_WELL) end def test_lintless_coffeescript - lint_results = `bin/coffee-script -l test/fixtures/execution/*.coffee` + lint_results = `bin/coffee -l test/fixtures/execution/*.coffee` assert lint_results.match(NO_WARNINGS) end def test_lintless_examples - lint_results = `bin/coffee-script -l examples/*.coffee` + lint_results = `bin/coffee -l examples/*.coffee` assert lint_results.match(NO_WARNINGS) end def test_lintless_documentation - lint_results = `bin/coffee-script -l documentation/coffee/*.coffee` + lint_results = `bin/coffee -l documentation/coffee/*.coffee` assert lint_results.match(NO_WARNINGS) end