Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use the utilities available in the global geddy object rather than re…
…-requiring utilities in nearly every file.
- Loading branch information
1 parent
95f02ea
commit ed0158e
Showing
15 changed files
with
72 additions
and
74 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
var path = require('path') | ||
var path = require('path') | ||
, config | ||
, cwd = process.cwd(); | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,25 @@ | ||
|
||
// Look through the './init' directory, and run the `init` | ||
// method for all listed files -- each `init` method should | ||
// take a callback that runs the next one. When all finished | ||
// call the original top-level callback for the whole init | ||
// process | ||
exports.init = function (app, callback) { | ||
var items = [ | ||
'router' | ||
, 'model' | ||
, 'i18n' | ||
, 'helpers' | ||
] | ||
, initItem = function () { | ||
var item = items.shift(); | ||
if (item) { | ||
item = require('./' + item); | ||
item.init(app, initItem); | ||
} | ||
else { | ||
callback(); | ||
} | ||
}; | ||
'router' | ||
, 'model' | ||
, 'i18n' | ||
, 'helpers' | ||
]; | ||
|
||
var initItem = function () { | ||
var item = items.shift(); | ||
if (item) { | ||
item = require('./' + item); | ||
item.init(app, initItem); | ||
} | ||
else { | ||
callback(); | ||
} | ||
}; | ||
initItem(); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,4 @@ | ||
var utils = require('utilities') | ||
, format | ||
var format | ||
, Format | ||
, builtInFormats; | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ed0158e
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a tough one. While I think it's a good thing that we hang some useful stuff like "log" and various utilities onto the geddy global for people building apps with Geddy, I don't think we should be depending heavily on non-explicit, magical globals throughout the framework code. This makes it harder to pull these modules apart for testing, and sometimes order-of-loading issues mean stuff isn't on the global when you expect it, and things break.
I've been slowly removing this dependence on the "geddy" global in favor of explicit requires in our framework code, which will make it way easier to write tests. I'm going to have to revert this commit, man.
Might be a good idea too, if you are going to make a large, sweeping change, to float a balloon on the mailing list, or open a pull-request for yourself, to start a quick discussion about it.
ed0158e
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can see the benefit of a global app log instance since it's a singleton, but I see no disadvantage to per-module or per-file requires for most anything else. Node caches them internally, so there's virtually no performance hit afaik.
Logs are kinda funny as well, since there's both an app log and a request log. Are we differentiating there?
ed0158e
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That makes sense @mde, thanks for explaining!
ed0158e
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@kieran Hanging various utilities on the global "geddy" object, comes mostly from the paucity of those in plain JS, and the inability to add stuff to the built-ins. (We're not taking the Prototype route here.) Most people eventually want stuff like
string.camelize
ordate.strftime
, and providing those as built-in is a nicety I think a framework like Geddy should provide. (In my mind this is similar to the Railsy String.blank.)As far as the logs go -- there are a bunch of different log-levels available. Basically 'access' goes to the access-log, and all the other levels go either to the stdout or the stderr logs. This might be a little weirder now too since I've just pushed changes to master which will make it easier for people to run their Geddy app in a single process, and allows you to pass in a custom logger.