index.coffee | |
---|---|
try
Util = require("util")
catch e
Util = require("sys")
Zombie = require("./browser")
Browser = Zombie.Browser | |
zombie.visit(url, callback)zombie.visit(url, options, callback)Creates a new Browser, opens window to the URL and calls the callback when done processing all events. For example: zombie = require("zombie")
| visit = (url, options, callback)->
new Browser(options).visit(url, options, callback) |
listen port, callbacklisten socket, callbacklisten callbackAsk Zombie to listen on the specified port for requests. The default port is 8091, or you can specify a socket name. The callback is invoked once Zombie is ready to accept new connections. | listen = (port, callback)->
require("./zombie/protocol").listen(port, callback) |
console.log(browser) pukes over the terminal, so we apply some sane defaults. You can override these: console.depth - How many time to recurse while formatting the object (default to zero) console.showHidden - True to show non-enumerable properties (defaults to false) | console.depth = 0
console.showHidden = false
console.log = ->
formatted = ((if typeof arg == "string" then arg else Util.inspect(arg, console.showHidden, console.depth)) for arg in arguments)
if typeof Util.format == 'function'
process.stdout.write Util.format.apply(this, formatted) + "\n"
else
process.stdout.write formatted.join(" ") + "\n"
Zombie.listen = listen
Zombie.visit = visit |
Default to debug mode if environment variable | Zombie.debug = !!process.env.DEBUG |
Export the globals from browser.coffee | module.exports = Zombie
|