Skip to content

Instantly share code, notes, and snippets.

@psyche
Forked from bmizerany/gist:76777
Created March 12, 2009 08:55
Show Gist options
  • Save psyche/77971 to your computer and use it in GitHub Desktop.
Save psyche/77971 to your computer and use it in GitHub Desktop.
require 'lib/sinatra'
module Sinatra
module Desc
@descriptions = []
class << self
attr_accessor :desc, :descriptions
end
def self.route_added(verb, path)
return if Desc.desc.nil?
Desc.descriptions << [verb, path, Desc.desc]
Desc.desc = nil
end
def self.registered(app)
app.get "/help" do
"<ul>" + Desc.descriptions.inject("") do |m, (verb, path, desc)|
m << "<li><strong>#{verb} #{path}</strong> -" +
desc + "</li>"
m
end + "</ul>"
end
end
def desc(msg)
Desc.desc = msg
end
end
register Desc
end
desc "This is a test"
post "/" do
"testing"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment