Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Cleanup, bring up to date with narwhal changes.
- Loading branch information
Tom Robinson
committed
Sep 12, 2009
1 parent
aa44eb0
commit fe4a046
Showing
2 changed files
with
32 additions
and
23 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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]); | ||
}); |