Permalink
Browse files

Compatibility with coffeescript 1.0.

  • Loading branch information...
1 parent 79bca6f commit 06f5e4d6da89201619ea890fb836dcd4955d3e47 @mauricemach mauricemach committed Dec 26, 2010
Showing with 17 additions and 14 deletions.
  1. +8 −7 bin/zappa.coffee
  2. +9 −7 lib/zappa.coffee
View
@@ -11,6 +11,7 @@ OptionParser = require('coffee-script/optparse').OptionParser
child = null
file = null
watching = []
+argv = process.argv.splice 2, process.argv.length - 2
usage = '''
Usage:
@@ -36,13 +37,13 @@ compile = (coffee_path) ->
fs.writeFile js_path, js
remove_watch_option = ->
- i = process.argv.indexOf('-w')
- process.argv.splice(i, 1) if i > -1
- i = process.argv.indexOf('--watch')
- process.argv.splice(i, 1) if i > -1
+ i = argv.indexOf('-w')
+ argv.splice(i, 1) if i > -1
+ i = argv.indexOf('--watch')
+ argv.splice(i, 1) if i > -1
spawn_child = ->
- child = spawn 'zappa', process.argv
+ child = spawn 'zappa', argv
child.stdout.on 'data', (data) ->
data = String(data)
if data.match /^Included file \".*\.coffee\"/
@@ -60,7 +61,7 @@ watch = (file) ->
spawn_child()
parser = new OptionParser switches, usage
-options = parser.parse process.argv
+options = parser.parse argv
args = options.arguments
delete options.arguments
@@ -70,7 +71,7 @@ if options.port
options.port[i] = parseInt(p)
if args.length is 0
- puts parser.help() if options.help or process.argv.length is 0
+ puts parser.help() if options.help or argv.length is 0
puts zappa.version if options.version
process.exit()
else
View
@@ -22,8 +22,9 @@ class Zappa
@ensure_app 'default' unless @current_app?
for name in 'get|post|put|del|route|at|msg|client|using|def|helper|postrender|layout|view|style'.split '|'
- @locals[name] = =>
- @current_app[name].apply @current_app, arguments
+ do (name) =>
+ @locals[name] = =>
+ @current_app[name].apply @current_app, arguments
app: (name) ->
@ensure_app name
@@ -379,11 +380,12 @@ class MessageHandler
coffeescript_support = """
var __slice = Array.prototype.slice;
var __hasProp = Object.prototype.hasOwnProperty;
- var __bind = function(func, context) {return function(){ return func.apply(context, arguments); };};
- var __extends = function(child, parent) { var ctor = function(){}; ctor.prototype = parent.prototype;
- child.prototype = new ctor(); child.prototype.constructor = child;
- if (typeof parent.extended === "function") parent.extended(child);
- child.__super__ = parent.prototype;
+ var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; };
+ var __extends = function(child, parent) {
+ for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; }
+ function ctor() { this.constructor = child; }
+ ctor.prototype = parent.prototype; child.prototype = new ctor; child.__super__ = parent.prototype;
+ return child;
};
"""

0 comments on commit 06f5e4d

Please sign in to comment.