Permalink
Browse files

Experimental CoffeeScript support.

  • Loading branch information...
1 parent cbdfdd4 commit 02096a2c53731822371f654b173080b0d4fbf6c3 @topfunky committed Feb 14, 2012
Showing with 15 additions and 5 deletions.
  1. +15 −5 lib/app.js
View
@@ -35,6 +35,8 @@ var fs = require('fs')
, Request = require('./request').Request
, InFlight = require('./in_flight').InFlight;
+require('coffee-script');
+
// Set up a bunch of aliases
geddy.FunctionRouter = FunctionRouter;
geddy.RegExpRouter = RegExpRouter;
@@ -44,11 +46,12 @@ geddy.model = model;
geddy.utils = utils;
var App = function () {
- var JSPAT = /\.js$/;
+ var JSPAT = /\.(js|coffee)$/;
var _getDirList = function (dirname) {
var dirList = fs.readdirSync(dir + dirname)
, fileName
+ , fileBaseName
, filePath
, ctorName
, ret = [];
@@ -58,10 +61,17 @@ var App = function () {
// Any files ending in '.js' -- e.g., 'neil_pearts.js'
if (JSPAT.test(fileName)) {
// Strip the '.js', e.g., 'neil_pearts'
- fileName = fileName.replace(JSPAT, '');
- // Convert underscores to camelCase with
- // initial cap, e.g., 'NeilPearts'
- ctorName = geddy.string.camelize(fileName, true);
+ fileBaseName = fileName.replace(JSPAT, '');
+ if (fileName.match(/\.coffee$/)) {
+ // Convert underscores to camelCase with
+ // initial cap, e.g., 'NeilPearts'
+ ctorName = geddy.string.camelize(fileBaseName, true);
+ } else {
+ fileName = fileBaseName
+ // Convert underscores to camelCase with
+ // initial cap, e.g., 'NeilPearts'
+ ctorName = geddy.string.camelize(fileName, true);
+ }
filePath = dir + dirname + '/' + fileName;
ret.push({
ctorName: ctorName

0 comments on commit 02096a2

Please sign in to comment.