/usr/share/doc/ruby-innate/examples/app/todo/start.rb is in ruby-innate 2013.02.21-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 | require 'rubygems'
require 'innate'
require 'pstore'
LIST = PStore.new('todo.pstore')
class Todo
Innate.node '/'
layout 'default'
def index
@list = sync{|list| list.roots.map{|key| [key, list[key]] }}
end
def create
redirect_referer unless request.post? and title = request[:title]
title.strip!
sync{ LIST[title] = false } unless title.empty?
redirect_referer
end
def update
id, title, done = request[:id, :title, :done]
redirect_referer unless request.post? and id and title
done = !!done
title.strip!
if id == title
sync{ LIST[id] = done }
elsif title != ''
sync{ LIST.delete(id); LIST[title] = done }
end
redirect_referer
end
def delete
redirect_referer unless request.post? and id = request[:id]
sync{ LIST.delete(id) }
redirect_referer
end
private
def sync
Innate.sync{ LIST.transaction{ yield(LIST) }}
end
end
Innate.start
|