lib/cans/application.rb in cans-0.1.0 vs lib/cans/application.rb in cans-0.1.1
- old
+ new
@@ -1,8 +1,8 @@
module Cans
class Application < Sinatra::Base
- set :views, File.dirname(__FILE__) + '/views'
+ set :views, File.dirname(__FILE__) + '/views'
get '/' do
@constants = Object.constants
@modules = @constants.map{ |c| Object.const_get c}.select{ |c| c.kind_of? Module}.sort_by(&:name)
haml :index
@@ -18,16 +18,30 @@
@class_methods = @module.methods
@ancestors = @module.ancestors
@child_modules = @module.constants.map{ |c| @module.const_get c}.select{ |c| c.kind_of? Module}.sort_by(&:name)
+
haml :module
end
get '/method/*' do
@address = Address.new(params[:splat].first)
@module = @address.target_module
@method = @address.target_method
haml :method
+ end
+
+ before do
+ @historian ||= Historian.new
+ @historian.delve
+ end
+
+ helpers do
+ def link(destination, content)
+ prefix = request.env['rack.mount.prefix'] || ''
+ href = prefix + destination
+ "<a href='#{href}'>#{content}</a>"
+ end
end
end
end