Skip to content

Commit

Permalink
Cleanup, bring up to date with narwhal changes.
Browse files Browse the repository at this point in the history
  • Loading branch information
Tom Robinson committed Sep 12, 2009
1 parent aa44eb0 commit fe4a046
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 23 deletions.
2 changes: 2 additions & 0 deletions bin/narwhal-johnson
Expand Up @@ -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))
53 changes: 30 additions & 23 deletions 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.