Sha256: 1fb1925ca1939e82f13e5c93785e374d8c0ef62a4743e66e7809665695039201

Contents?: true

Size: 821 Bytes

Versions: 2

Compression:

Stored size: 821 Bytes

Contents

require 'sinatra'

module Smoke
  class Rack < Sinatra::Base    
    set :public, File.join(File.dirname(__FILE__), '..', 'public')
    set :views, File.join(File.dirname(__FILE__), '..', 'views')
    set :haml, {:format => :html5, :attr_wrapper => '"'}
    enable :static
    
    mime :xml,  "application/xml"
    mime :json, "application/json"
    mime :yaml, "application/x-yaml"
    
    get '/smoke' do
      @sources = Smoke.active_sources.keys
      haml :index
    end
    
    Smoke.active_sources.keys.each do |source|
      get "/smoke/#{source.to_s}" do
        @source = source
        haml :usage
      end
      
      get "/smoke/#{source.to_s}.:format" do
        format = params[:format].to_sym
        
        content_type format
        Smoke.send(source).output(format)
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
smoke-rack-0.0.3 lib/smoke-rack.rb
smoke-rack-0.0.2 lib/smoke-rack.rb