require 'innate' require 'yaml/store' STORE = YAML::Store.new('games.yaml') def STORE.[](key) transaction{|s| super } end def STORE.[]=(key, value) transaction{|s| super } end def STORE.each(&block) YAML.load_file('games.yaml').sort_by{|k,v| -v }.each(&block) end STORE['Pacman'] = 1 class Games Innate.node('/') def index TEMPLATE end def create STORE[request[:name]] ||= 0 if request.post? redirect_referrer end def vote(name) STORE[url_decode(name)] += 1 redirect_referrer end TEMPLATE = <<-'T'.strip Top Retro Games

Vote on your favorite Retro Game

    <% STORE.each do |name, votes| %>
  1. <%= Games.a("Vote", "/vote/#{u name}") %> <%= "%5d => %s" % [votes, name] %>
  2. <% end %>
T end Innate.start