Created
March 10, 2009 06:26
-
-
Save bmizerany/76777 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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