Permalink
Browse files

Cleanup, bring up to date with narwhal changes.

  • Loading branch information...
1 parent aa44eb0 commit fe4a046699b7009bfe36ff727b14c2d414c0295b Tom Robinson committed Sep 12, 2009
Showing with 32 additions and 23 deletions.
  1. +2 −0 bin/narwhal-johnson
  2. +30 −23 bootstrap.js
View
2 bin/narwhal-johnson
@@ -2,5 +2,7 @@
require 'johnson'
+ENV['NARWHAL_PLATFORM_HOME'] ||= File.dirname(File.dirname($0))
+
bootstrap = File.join(ENV['NARWHAL_PLATFORM_HOME'], 'bootstrap.js')
Johnson.evaluate(File.read(bootstrap))
View
53 bootstrap.js
@@ -1,42 +1,49 @@
-(function (evalGlobal) {
+(function (global, evalGlobal) {
- var _print = function(path) {
+ var print = function(path) {
Ruby.puts(path);
};
- var _read = function(path) {
+ var read = function(path) {
return Ruby.File.read(path);
};
- var _isFile = function(path) {
+ var isFile = function(path) {
return Ruby.File['file?'](path);
};
+ var evaluate = function (text) {
+ // TODO maybe something better here:
+ return eval(
+ "(function(require,exports,module,system,print){" +
+ text +
+ "/**/\n})"
+ );
+ }
+
var prefix = Ruby.ENV['NARWHAL_HOME'];
+ var enginePrefix = Ruby.ENV['NARWHAL_ENGINE_HOME'];
+
+ var narwhal = eval(read(prefix + "/narwhal.js"))
- eval(_read(prefix + "/narwhal.js"))({
- global: this,
+ narwhal({
+ global: global,
evalGlobal: evalGlobal,
- platform: 'johnson',
- platforms: ['johnson', 'default'],
- print: _print,
- evaluate: function (text) {
- // TODO maybe something better here:
- return eval(
- "(function(require,exports,module,system,print){" +
- text +
- "/**/\n})"
- );
- },
+ engine: 'johnson',
+ engines: ['johnson', 'default'],
+ prefix: prefix,
+ prefixes: [enginePrefix, prefix],
+ print: print,
fs: {
- read: _read,
- isFile: _isFile
+ read: read,
+ isFile: isFile
},
- prefix: prefix,
- debug: true,
- verbose: true
+ evaluate: evaluate,
+ os : Ruby.RUBY_PLATFORM,
+ debug: Ruby.ENV['NARWHAL_DEBUG'],
+ verbose: Ruby.ENV['NARWHAL_VERBOSE']
});
-}).call(this, function () {
+})(this, function () {
return eval(arguments[0]);
});

0 comments on commit fe4a046

Please sign in to comment.