Permalink
Browse files

More work to get rid of local utils

  • Loading branch information...
1 parent eb45ebc commit d07c27b6a19c4cbdb4dce9da1b77d3c0a65b4941 mde committed Aug 14, 2012
View
@@ -65,7 +65,7 @@ var App = function () {
if (JSPAT.test(fileName)) {
if(fileName.match(/\.coffee$/)) {
// fileName is a CoffeeScript file so try to require it
- usingCoffee = usingCoffee || utils.file.dependency('coffee-script');
+ usingCoffee = usingCoffee || utils.file.requireLocal('coffee-script');
}
// Strip the extension from the file name
fileName = fileName.replace(JSPAT, '');
@@ -117,7 +117,7 @@ var App = function () {
utils.file.existsSync(path.join(appAdaptersPath, adapterName.toLowerCase() + '.coffee'))) {
if(utils.file.existsSync(path.join(appAdaptersPath, adapterName.toLowerCase() + '.coffee'))) {
- usingCoffee = usingCoffee || utils.file.dependency('coffee-script');
+ usingCoffee = usingCoffee || utils.file.requireLocal('coffee-script');
}
adapterPath = path.join(appAdaptersPath, adapterName.toLowerCase());
geddy.model.adapter[item.ctorName] = require(adapterPath)[adapterName];
@@ -174,7 +174,7 @@ var App = function () {
, _loadRouter = function (next) {
routerCsFile = path.join(cwd, '/config/router.coffee');
if(utils.file.existsSync(routerCsFile)) {
- usingCoffee = usingCoffee || utils.file.dependency('coffee-script');
+ usingCoffee = usingCoffee || utils.file.requireLocal('coffee-script');
}
router = require(path.join(cwd, '/config/router'));
router = router.router || router;
@@ -322,7 +322,7 @@ var App = function () {
if(fileBaseName === 'init') {
if(fileExt === '.coffee') {
// fileName is a CoffeeScript file so try to require it
- usingCoffee = usingCoffee || utils.file.dependency('coffee-script');
+ usingCoffee = usingCoffee || utils.file.requireLocal('coffee-script');
}
require(path.join(cwd, 'config', fileName));
}
@@ -337,11 +337,11 @@ var App = function () {
, _afterStart = function(next) {
geddy.server.listeners('request');
- // Load socket.io if it's enabled. This get's run after
+ // Load socket.io if it's enabled. This gets run after
// the server starts listening for requests. Socket.io
// won't work if we start it before.
if (geddy.config.socketIo) {
- geddy.io = utils.file.dependency('socket.io').listen(geddy.server);
+ geddy.io = utils.file.requireLocal('socket.io').listen(geddy.server);
}
try {
require(path.join(cwd, 'config', 'after_start'));
View
@@ -63,7 +63,7 @@ Master.prototype = new (function () {
if(fileBaseName === this.config.environment || fileBaseName === 'environment') {
if(fileExt === '.coffee') {
// fileName is a CoffeeScript file so try to require it
- usingCoffee = usingCoffee || file.dependency('coffee-script');
+ usingCoffee = usingCoffee || file.requireLocal('coffee-script');
}
appBaseConfig = require(dir + '/config/environment');
appEnvConfig = require(dir + '/config/' + this.config.environment);
@@ -145,7 +145,7 @@ Master.prototype = new (function () {
, port;
if (this.config.metrics) {
port = this.config.metrics.port;
- metrics = file.dependency('metrics');
+ metrics = file.requireLocal('metrics');
this.stdoutLog.info('Metrics server started on port ' + port);
this.metricsServer = new metrics.Server(port);
}
@@ -1,7 +1,5 @@
-try {
- var file = require('utilities').file
- , metrics = file.dependency('metrics');
-} catch(err) {}
+var file = require('utilities').file
+ , metrics;
var dispatch = {
readyForRetirement: function (msg) {
@@ -47,6 +45,7 @@ var dispatch = {
, createMetric: function (msg) {
if (this.metricsServer) {
+ metrics = metrics || file.requireLocal('metrics');
msg.type = msg.type[0].toUpperCase() + msg.type.substring(1)
this.metricsServer.addMetric(msg.eventType, new metrics[msg.type]);
}
@@ -1,5 +1,5 @@
var file = require('utilities').file
- , mongo = file.dependency('mongodb-wrapper');
+ , mongo = file.requireLocal('mongodb-wrapper');
var Mongo = function (config) {
if (!geddy.config.db.mongo) throw "No Mongo config defined.";
@@ -1,5 +1,5 @@
var file = require('utilities').file
- , riak = file.dependency('riak-js');
+ , riak = file.requireLocal('riak-js');
//require('riak-js').getClient()
View
@@ -35,7 +35,6 @@ var VERSION = '0.1.0'
, restartMode = false;
try {
- metrics = utils.file.dependency('metrics')
} catch(err) {}
/**
@@ -124,9 +123,8 @@ var server = module.exports = new function () {
* Start the metrics server
*/
, _doMetricsTracking = function () {
- if (metrics) {
- this.metricsServer = new metrics.Server(this.config.metricsPort || 9091);
- }
+ metrics = metrics || utils.file.requireLocal('metrics');
+ this.metricsServer = new metrics.Server(this.config.metricsPort || 9091);
}
/**
@@ -29,7 +29,7 @@ Config section should look like this:
*/
var file = require('utilities').file
- , Memcached = file.dependency('memcached');
+ , Memcached = file.requireLocal('memcached');
var Memcache = function (callback) {
this.setup(callback);
@@ -37,7 +37,7 @@ Config section should look like this:
If don't provide an expiry in your config file your sessions will live forever.
*/
var file = require('utilities').file
- , mongo = file.dependency('mongodb-wrapper');
+ , mongo = file.requireLocal('mongodb-wrapper');
var MongoDB = function (callback) {
this.setup(callback);
@@ -34,7 +34,7 @@ Config section should look like this:
'server' is your Redis server.
*/
var file = require('utilities').file
- , RedisServer = file.dependency('redis');
+ , RedisServer = file.requireLocal('redis');
var Redis = function (callback) {
this.setup(callback);
@@ -23,7 +23,7 @@ handlebars.Template = function(params) {
params = params || {};
// Try to require Handlebars or error out
- file.dependency('handlebars');
+ file.requireLocal('handlebars');
this.mode = null;
this.truncate = false;
@@ -23,7 +23,7 @@ jade.Template = function(params) {
params = params || {};
// Try to require Jade or error out
- file.dependency('jade');
+ file.requireLocal('jade');
this.mode = null;
this.truncate = false;
@@ -22,12 +22,8 @@ var file = require('utilities').file
mustache.Template = function(params) {
params = params || {};
- // Try to require Jade or error out
- file.dependency('handlebars', [
- "To use Handlebars you will need to install it: [sudo] npm install [-g] handlebars"
- , ""
- , "Mustache, Handlebars same thing, so we're installing Handlebars. http://is.gd/kYTJyS"
- ].join('\n'));
+ // Try to require Handlebars or error out
+ file.requireLocal('handlebars');
this.mode = null;
this.truncate = false;
View
@@ -1,64 +0,0 @@
-/*
- * Geddy JavaScript Web development framework
- * Copyright 2112 Matthew Eernisse (mde@fleegix.org)
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
-*/
-var array = require('../../lib/utils/array').array
- , assert = require('assert')
- , tests = {};
-
-tests = {
-
- 'test basic humanize for array': function () {
- var data = array.humanize(["array", "array", "array"])
- , actual = "array, array and array";
- assert.equal(data, actual);
- }
-
-, 'test humanize with two items for array': function() {
- var data = array.humanize(["array", "array"])
- , actual = "array and array";
- assert.equal(data, actual);
- }
-
-, 'test humanize with two items for array': function() {
- var data = array.humanize(["array"])
- , actual = "array";
- assert.equal(data, actual);
- }
-
-, 'test basic included for array': function() {
- var test = ["array"]
- , data = array.included("array", test)
- , actual = test;
- assert.equal(data, actual);
- }
-
-, 'test false included for array': function() {
- var data = array.included("nope", ["array"])
- , actual = false;
- assert.equal(data, actual);
- }
-
-, 'test false boolean included for array': function() {
- var test = ["array", false]
- , data = array.included(false, test)
- , actual = test;
- assert.equal(data, actual);
- }
-
-};
-
-module.exports = tests;
View
@@ -1,69 +0,0 @@
-/*
- * Geddy JavaScript Web development framework
- * Copyright 2112 Matthew Eernisse (mde@fleegix.org)
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
-*/
-var date = require('../../lib/utils/date').date
- , assert = require('assert')
- , tests = {}
- , _date = new Date();
-
-tests = {
-
- 'test strftime for date': function() {
- var data = date.strftime(_date, "%w")
- , actual = _date.getDay();
- assert.equal(data, actual);
- }
-
-, 'test leftPad for date': function() {
- var data = date.leftPad("geddy", 7, " ")
- , actual = " geddy";
- assert.equal(data, actual);
- }
-
-, 'test calcCentury using current year for date': function() {
- var data = date.calcCentury()
- , actual = '21';
- assert.equal(data, actual);
- }
-
-, 'test calcCentury using 20th century year for date': function() {
- var data = date.calcCentury(2000)
- , actual = '20';
- assert.equal(data, actual);
- }
-
-, 'test calcCentury using 1st century year for date': function() {
- var data = date.calcCentury(10)
- , actual = '1';
- assert.equal(data, actual);
- }
-
-, 'test getMeridiem for date': function() {
- var data = date.getMeridiem(_date.getHours())
- , actual = (_date.getHours() > 11) ? 'PM' : 'AM';
- assert.equal(data, actual);
- }
-
-, 'test leftPad for date': function() {
- var data = date.leftPad("geddy", 7, " ")
- , actual = " geddy";
- assert.equal(data, actual);
- }
-
-};
-
-module.exports = tests;
View
@@ -1,45 +0,0 @@
-/*
- * Geddy JavaScript Web development framework
- * Copyright 2112 Matthew Eernisse (mde@fleegix.org)
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
-*/
-
-var Stream = require('stream').Stream
- , EventEmitter = require('events').EventEmitter
- , EventBuffer = require('../../lib/utils/event_buffer.js').EventBuffer
- , assert = require('assert')
- , tests;
-
-tests = {
-
- 'test basic event buffer functionality': function () {
- var source = new Stream()
- , dest = new EventEmitter()
- , buff = new EventBuffer(source)
- , data = '';
- dest.on('data', function(d) { data += d; });
- source.writeable = true;
- source.readable = true;
- source.emit('data', 'abcdef');
- source.emit('data', '123456');
- buff.sync(dest);
- assert.equal('abcdef123456', data);
- source.emit('data', '---');
- assert.equal('abcdef123456---', data);
- }
-
-};
-
-module.exports = tests;
Oops, something went wrong.

0 comments on commit d07c27b

Please sign in to comment.