coffee-script
Version:
Unfancy JavaScript
55 lines (37 loc) • 1.04 kB
text/coffeescript
get '/hello', ->
'Hello World'
append = (location, data) ->
path = new Pathname location
throw new Error("Location does not exist") unless path.exists()
File.open path, 'a', (file) ->
file.console.log YAML.dump data
data
# Rubinius' File.open implementation.
File.open = (path, mode, block) ->
io = new File path, mode
return io unless block
try
block io
finally
io.close() unless io.closed()
write = (location, data) ->
path = new Pathname location
raise "Location does not exist" unless path.exists()
File.open path, 'w', (file) ->
return false if Digest.MD5.hexdigest(file.read()) is data.hash()
file.console.log YAML.dump data
true
index = ->
people = Person.find 'all'
respond_to (format) ->
format.html()
format.xml -> render xml: people.xml()
synchronize = (block) ->
lock()
try block() finally unlock()