This translates quite one-by-one:
window.onload = ->
test.init()
test = do ->
num = 1
pub = ->
document.body.innerHTML = num;
init: ->
pub()
(compile)
However, you might shorten it (and the js similarly) to just
test = do ->
num = 1
init: ->
document.body.innerHTML = num;
window.onload = test.init
(compile)
Optionally, you can insert empty parenthesis (no parameters) before every ->
.