Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

[refactor] Rename `sugarskull` to `director`

  • Loading branch information...
commit 0a9c976382a2dadca3a9cb7305223a500224f75b 1 parent 6f8d060
@indexzero indexzero authored
View
18 README.md
@@ -223,7 +223,7 @@ An object literal that contains nested route definitions. A potentially nested s
<a name="adhoc-routing"></a>
## Adhoc Routing
-When developing large client-side or server-side applications it is not always possible to define routes in one location. Usually individual decoupled components register their own routes with the application router. We refer to this as _Adhoc Routing._ Lets take a look at the API `sugarskull` exposes for adhoc routing:
+When developing large client-side or server-side applications it is not always possible to define routes in one location. Usually individual decoupled components register their own routes with the application router. We refer to this as _Adhoc Routing._ Lets take a look at the API `director` exposes for adhoc routing:
**Client-side Routing**
@@ -255,7 +255,7 @@ When developing large client-side or server-side applications it is not always p
In large web appliations, both [Client-side](#client-side) and [Server-side](#server-side), routes are often scoped within a few individual resources. Director exposes a simple way to do this for [Adhoc Routing](#adhoc-routing) scenarios:
``` js
- var router = new sugarskull.http.Router();
+ var router = new director.http.Router();
//
// Create routes inside the `/users` scope.
@@ -289,7 +289,7 @@ In large web appliations, both [Client-side](#client-side) and [Server-side](#se
<a name="routing-events"></a>
## Routing Events
-In `sugarskull`, a "routing event" is a named property in the [Routing Table](#routing-table) which can be assigned to a function or an Array of functions to be called when a route is matched in a call to `router.dispatch()`.
+In `director`, a "routing event" is a named property in the [Routing Table](#routing-table) which can be assigned to a function or an Array of functions to be called when a route is matched in a call to `router.dispatch()`.
* **on:** A function or Array of functions to execute when the route is matched.
* **before:** A function or Array of functions to execute before calling the `on` method(s).
@@ -302,10 +302,10 @@ In `sugarskull`, a "routing event" is a named property in the [Routing Table](#r
<a name="configuration"></a>
## Configuration
-Given the flexible nature of `sugarskull` there are several options available for both the [Client-side](#client-side) and [Server-side](#server-side). These options can be set using the `.configure()` method:
+Given the flexible nature of `director` there are several options available for both the [Client-side](#client-side) and [Server-side](#server-side). These options can be set using the `.configure()` method:
``` js
- var router = new sugarskull.Router(routes).configure(options);
+ var router = new director.Router(routes).configure(options);
```
The `options` are:
@@ -379,10 +379,10 @@ When you are using the same route fragments it is more descriptive to define the
``` js
//
- // Create a router. This could also be sugarskull.cli.Router() or
- // sugarskull.http.Router().
+ // Create a router. This could also be director.cli.Router() or
+ // director.http.Router().
//
- var router = new sugarskull.Router();
+ var router = new director.Router();
//
// A route could be defined using the `userId` explicitly.
@@ -494,7 +494,7 @@ Can be assigned the value of `forward` or `backward`. The recurse option will de
<a name="async-routing"></a>
## Async Routing
-Before diving into how Sugarskull exposes async routing, you should understand [Route Recursion](#route-recursion). At it's core route recursion is about evaluating a series of functions gathered when traversing the [Routing Table](#routing-table).
+Before diving into how Director exposes async routing, you should understand [Route Recursion](#route-recursion). At it's core route recursion is about evaluating a series of functions gathered when traversing the [Routing Table](#routing-table).
Normally this series of functions is evaluated synchronously. In async routing, these functions are evaluated asynchronously. Async routing can be extremely useful both on the client-side and the server-side:
View
6 bin/build
@@ -6,7 +6,7 @@ var surgeon = new Codesurgeon;
var path = require('path');
var root = path.join(__dirname, '..');
-var lib = path.join(root, 'lib', 'sugarskull');
+var lib = path.join(root, 'lib', 'director');
//
// Distill and package the browser version.
@@ -68,10 +68,10 @@ surgeon
// write the debuggable version of the file. This file will
// get renamed to include the version from the package.json
//
- .write(root + '/build/sugarskull.js')
+ .write(root + '/build/director.js')
//
// now lets make a minified version for production use.
//
.uglify()
- .write(root + '/build/sugarskull.min.js')
+ .write(root + '/build/director.min.js')
;
View
2  build/sugarskull-1.0.0.js → build/director-1.0.0.js
@@ -9,7 +9,7 @@
/*
- * browser.js: Browser specific functionality for sugarskull.
+ * browser.js: Browser specific functionality for director.
*
* (C) 2011, Nodejitsu Inc.
* MIT LICENSE
View
0  build/sugarskull-1.0.0.min.js → build/director-1.0.0.min.js
File renamed without changes
View
6 examples/http.js
@@ -1,7 +1,7 @@
var http = require('http'),
- sugarskull = require('../lib/sugarskull');
+ director = require('../lib/director');
-var router = new sugarskull.http.Router();
+var router = new director.http.Router();
var server = http.createServer(function (req, res) {
router.dispatch(req, res, function (err) {
@@ -18,4 +18,4 @@ router.get(/foo/, function () {
});
server.listen(8080);
-console.log('vanilla http server with sugarskull running on 8080');
+console.log('vanilla http server with director running on 8080');
View
6 lib/director.js
@@ -0,0 +1,6 @@
+
+
+
+exports.Router = require('./director/router').Router;
+exports.http = require('./director/http');
+exports.cli = require('./director/cli');
View
2  lib/sugarskull/browser.js → lib/director/browser.js
@@ -1,6 +1,6 @@
/*
- * browser.js: Browser specific functionality for sugarskull.
+ * browser.js: Browser specific functionality for director.
*
* (C) 2011, Nodejitsu Inc.
* MIT LICENSE
View
10 lib/sugarskull/cli.js → lib/director/cli.js
@@ -1,17 +1,17 @@
var util = require('util'),
- sugarskull = require('../sugarskull'),
+ director = require('../director'),
optimist = require('optimist');
var Router = exports.Router = function (routes) {
- sugarskull.Router.call(this, routes);
+ director.Router.call(this, routes);
this.recurse = 'backward';
};
//
-// Inherit from `sugarskull.Router`.
+// Inherit from `director.Router`.
//
-util.inherits(Router, sugarskull.Router);
+util.inherits(Router, director.Router);
//
// ### function configure (options)
@@ -20,7 +20,7 @@ util.inherits(Router, sugarskull.Router);
//
Router.prototype.configure = function (options) {
options = options || {};
- sugarskull.Router.prototype.configure.call(this, options);
+ director.Router.prototype.configure.call(this, options);
//
// Delimiter must always be `\s` in CLI routing.
View
10 lib/sugarskull/http/index.js → lib/director/http/index.js
@@ -2,7 +2,7 @@
var events = require('events'),
qs = require('querystring'),
util = require('util'),
- sugarskull = require('../../sugarskull');
+ director = require('../../director');
//
// ### Expose all HTTP methods and responses
@@ -11,7 +11,7 @@ exports.methods = require('./methods');
exports.responses = require('./responses');
var Router = exports.Router = function (routes) {
- sugarskull.Router.call(this, routes);
+ director.Router.call(this, routes);
//
// ### Extend the `Router` prototype with all of the RFC methods.
@@ -21,9 +21,9 @@ var Router = exports.Router = function (routes) {
};
//
-// Inherit from `sugarskull.Router`.
+// Inherit from `director.Router`.
//
-util.inherits(Router, sugarskull.Router);
+util.inherits(Router, director.Router);
Router.prototype.on = function (method, path) {
var args = Array.prototype.slice.call(arguments, 2),
@@ -34,7 +34,7 @@ Router.prototype.on = function (method, path) {
route.stream = true;
}
- sugarskull.Router.prototype.on.call(this, method, path, route);
+ director.Router.prototype.on.call(this, method, path, route);
}
//
View
0  lib/sugarskull/http/methods.js → lib/director/http/methods.js
File renamed without changes
View
0  lib/sugarskull/http/responses.js → lib/director/http/responses.js
File renamed without changes
View
2  lib/sugarskull/router.js → lib/director/router.js
@@ -370,7 +370,7 @@ Router.prototype.invoke = function (fns, thisArg, callback) {
// #### @path {string} Path to find in the `routes` table.
// #### @routes {Object} Partial routing table to match against
// #### @regexp {string} Partial regexp representing the path to `routes`.
-// Core routing logic for `sugarskull.Router`: traverses the
+// Core routing logic for `director.Router`: traverses the
// specified `path` within `this.routes` looking for `method`
// returning any `fns` that are found.
//
View
6 lib/sugarskull.js
@@ -1,6 +0,0 @@
-
-
-
-exports.Router = require('./sugarskull/router').Router;
-exports.http = require('./sugarskull/http');
-exports.cli = require('./sugarskull/cli');
View
6 package.json
@@ -1,5 +1,5 @@
{
- "name": "sugarskull",
+ "name": "director",
"description": "A Client Side Router for Single Page Apps",
"author": "Nodejitsu Inc <info@nodejitsu.com>",
"version": "1.0.1",
@@ -10,7 +10,7 @@
],
"repository": {
"type": "git",
- "url": "http://github.com/flatiron/sugarskull.git"
+ "url": "http://github.com/flatiron/director.git"
},
"keywords": ["URL", "router", "http", "cli", "flatiron", "client side"],
"dependencies": {
@@ -24,7 +24,7 @@
"colors": "0.5.x"
},
"ender": "./build/ender.js",
- "main": "./lib/sugarskull",
+ "main": "./lib/director",
"engines": { "node": ">= 0.4.0" },
"scripts": {
"test": "vows --spec test/server/*/*-test.js"
View
4 test/browser/adhoc-harness.html
@@ -2,7 +2,7 @@
<html lang="en-US">
<head>
<meta charset="UTF-8">
- <title>SugarSkull Tests</title>
+ <title>Director Tests</title>
<link rel="stylesheet" type="text/css" href="helpers/qunit.css" media="all">
</head>
<body>
@@ -15,7 +15,7 @@ <h2 id="qunit-userAgent"></h2>
<script type="text/javascript" src="helpers/jquery.js"></script>
<script type="text/javascript" src="helpersqunit.js"></script>
-<script type="text/javascript" src="../../build/sugarskull-1.0.0.js"></script>
+<script type="text/javascript" src="../../build/director-1.0.0.js"></script>
<script type="text/javascript" src="helpers/adhoc.js"></script>
</body>
</html>
View
2  test/browser/helpers/api.js
@@ -1,4 +1,4 @@
-module("SugarSkull.js", {
+module("Director.js", {
setup: function() {
window.location.hash = "";
shared = {};
View
6 test/browser/routes-harness.html
@@ -2,12 +2,12 @@
<html lang="en-US">
<head>
<meta charset="UTF-8">
- <title>SugarSkull Tests</title>
+ <title>Director Tests</title>
<link rel="stylesheet" type="text/css" href="helpers/qunit.css" media="all">
</head>
<body>
<h1 id="qunit-header">
- <img src="../../img/sugarskull.png" width="448" height="80" alt="Sugarskull">
+ <img src="../../img/director.png" width="448" height="80" alt="Director">
</h1><br/>
<h2 id="qunit-banner"></h2>
<div id="qunit-testrunner-toolbar"></div>
@@ -17,7 +17,7 @@ <h2 id="qunit-userAgent"></h2>
<script type="text/javascript" src="helpers/jquery.js"></script>
<script type="text/javascript" src="helpers/qunit.js"></script>
-<script type="text/javascript" src="../../build/sugarskull-1.0.0.js"></script>
+<script type="text/javascript" src="../../build/director-1.0.0.js"></script>
<script type="text/javascript" src="helpers/api.js"></script>
<script type="text/javascript" src="routes-test.js"></script>
</body>
View
8 test/server/cli/dispatch-test.js
@@ -9,12 +9,12 @@
var assert = require('assert'),
vows = require('vows'),
eyes = require('eyes'),
- sugarskull = require('../../../lib/sugarskull');
+ director = require('../../../lib/director');
-vows.describe('sugarskull/cli/dispatch').addBatch({
- "An instance of sugarskull.cli.Router": {
+vows.describe('director/cli/dispatch').addBatch({
+ "An instance of director.cli.Router": {
topic: function () {
- var router = new sugarskull.cli.Router(),
+ var router = new director.cli.Router(),
that = this;
that.matched = {};
View
8 test/server/cli/path-test.js
@@ -9,11 +9,11 @@
var assert = require('assert'),
vows = require('vows'),
eyes = require('eyes'),
- sugarskull = require('../../../lib/sugarskull');
+ director = require('../../../lib/director');
-vows.describe('sugarskull/cli/path').addBatch({
- "An instance of sugarskull.cli.Router": {
- topic: new sugarskull.cli.Router(),
+vows.describe('director/cli/path').addBatch({
+ "An instance of director.cli.Router": {
+ topic: new director.cli.Router(),
"the path() method": {
"should create the correct nested routing table": function (router) {
function noop () {}
View
8 test/server/core/dispatch-test.js
@@ -9,17 +9,17 @@
var assert = require('assert'),
vows = require('vows'),
eyes = require('eyes'),
- sugarskull = require('../../../lib/sugarskull');
+ director = require('../../../lib/director');
-vows.describe('sugarskull/router/dispatch').addBatch({
- "An instance of sugarskull.Router": {
+vows.describe('director/router/dispatch').addBatch({
+ "An instance of director.Router": {
topic: function () {
var that = this;
that.matched = {};
that.matched['foo'] = [];
that.matched['f*'] = []
- var router = new sugarskull.Router({
+ var router = new director.Router({
'/foo': {
before: function () { that.matched.foo.push('before foo') },
on: function () { that.matched.foo.push('on foo') },
View
8 test/server/core/insert-test.js
@@ -8,11 +8,11 @@
var assert = require('assert'),
vows = require('vows'),
- sugarskull = require('../../../lib/sugarskull');
+ director = require('../../../lib/director');
-vows.describe('sugarskull/router/insert').addBatch({
- "An instance of sugarskull.Router": {
- topic: new sugarskull.Router(),
+vows.describe('director/router/insert').addBatch({
+ "An instance of director.Router": {
+ topic: new director.Router(),
"the insert() method": {
"'on', ['foo', 'bar']": function (router) {
function route () { }
View
10 test/server/core/mount-test.js
@@ -9,7 +9,7 @@
var assert = require('assert'),
vows = require('vows'),
eyes = require('eyes'),
- sugarskull = require('../../../lib/sugarskull');
+ director = require('../../../lib/director');
function assertRoute (fn, path, route) {
if (path.length === 1) {
@@ -21,10 +21,10 @@ function assertRoute (fn, path, route) {
assertRoute(fn, path, route);
}
-vows.describe('sugarskull/router/mount').addBatch({
- "An instance of sugarskull.Router": {
+vows.describe('director/router/mount').addBatch({
+ "An instance of director.Router": {
"with no preconfigured params": {
- topic: new sugarskull.Router(),
+ topic: new director.Router(),
"the mount() method": {
"should sanitize the routes correctly": function (router) {
function foobar () { }
@@ -63,7 +63,7 @@ vows.describe('sugarskull/router/mount').addBatch({
},
"with preconfigured params": {
topic: function () {
- var router = new sugarskull.Router();
+ var router = new director.Router();
router.param('city', '([\\w\\-]+)');
router.param(':country', /([A-Z][A-Za-z]+)/);
router.param(':zip', /([\d]{5})/);
View
8 test/server/core/path-test.js
@@ -9,17 +9,17 @@
var assert = require('assert'),
vows = require('vows'),
eyes = require('eyes'),
- sugarskull = require('../../../lib/sugarskull');
+ director = require('../../../lib/director');
-vows.describe('sugarskull/router/path').addBatch({
- "An instance of sugarskull.Router": {
+vows.describe('director/router/path').addBatch({
+ "An instance of director.Router": {
topic: function () {
var that = this;
that.matched = {};
that.matched['foo'] = [];
that.matched['newyork'] = [];
- var router = new sugarskull.Router({
+ var router = new director.Router({
'/foo': function () { that.matched['foo'].push('foo'); }
});
return router;
View
2  test/server/helpers/macros.js
@@ -1,5 +1,5 @@
/*
- * macros.js: Test macros for sugarskull tests.
+ * macros.js: Test macros for director tests.
*
* (C) 2011, Nodejitsu Inc.
* MIT LICENSE
View
12 test/server/http/methods-test.js
@@ -8,13 +8,13 @@
var assert = require('assert'),
vows = require('vows'),
- sugarskull = require('../../../lib/sugarskull');
+ director = require('../../../lib/director');
-vows.describe('sugarskull/http/methods').addBatch({
- "When using sugarskull": {
- "an instance of sugarskull.http.Router should have all relevant RFC methods": function () {
- var router = new sugarskull.http.Router();
- sugarskull.http.methods.forEach(function (method) {
+vows.describe('director/http/methods').addBatch({
+ "When using director": {
+ "an instance of director.http.Router should have all relevant RFC methods": function () {
+ var router = new director.http.Router();
+ director.http.methods.forEach(function (method) {
assert.isFunction(router[method.toLowerCase()]);
});
}
Please sign in to comment.
Something went wrong with that request. Please try again.