#!/usr/bin/env ruby
require 'rubygems'
require 'sinatra/base'
require 'vegas'

class SammyTest < Sinatra::Application

  set :public, File.expand_path(File.dirname(__FILE__))

  get '/' do
    content_type 'text/html'
    read_relative_file 'index.html'
  end

  get /\/(lib|vendor)\/(.*)/ do
    filename = File.join(params['captures'][0],params['captures'][1])
    content_type File.extname(filename)
    read_relative_file '..', filename
  end

  def read_relative_file(*args)
    File.read(File.join(File.expand_path(File.dirname(__FILE__)), *args))
  end

end

Vegas::Runner.new(SammyTest, 'sammy_test_server')