Sha256: 65cb93f35a9519079d925b02d7fec2c238373e1492013688f2d7319179622e52

Contents?: true

Size: 756 Bytes

Versions: 1

Compression:

Stored size: 756 Bytes

Contents

require 'sinatra'

module Smoke
  class Rack < Sinatra::Base    
    set :public, File.join(File.dirname(__FILE__), '..', 'public')
    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

1 entries across 1 versions & 1 rubygems

Version Path
smoke-rack-0.0.1 lib/smoke-rack.rb