Sha256: f5259140929b2b6dc8535694e3ec0905321a40d56b4c93d23eaf67e5b6dce358

Contents?: true

Size: 1.27 KB

Versions: 1

Compression:

Stored size: 1.27 KB

Contents

module Cans
  class Application < Sinatra::Base
    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
    end

    get '/module/*' do
      @address = Address.new(params[:splat].first)
      @module = @address.target_module

      @local_instance_methods = @module.instance_methods false
      @all_instance_methods = @module.instance_methods true
      @super_instance_methods = @all_instance_methods - @local_instance_methods

      @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

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
cans-0.1.1 lib/cans/application.rb