Sha256: b4ea759a71554e71936f08328d3fab25b6080d962453cd637d59354878f76779
Contents?: true
Size: 1.96 KB
Versions: 2
Compression:
Stored size: 1.96 KB
Contents
require 'sinatra/base' require 'teatime/teafile' module Teatime class Server < Sinatra::Base def self.root_path(*chunks) File.expand_path(File.join('..', *chunks), __FILE__) end def self.load_teafile(teafile) if File.exist?(teafile) Teatime::Teafile.load(teafile) end end set :teatime, load_teafile(File.join(Dir.pwd, 'Teafile')) set :views, root_path('views') set :public_folder, teatime.lib_dir get '/' do haml :index, :locals => { :js_files => js_files, :css_files => css_files } end get '/test/*' do js_test_file = File.join(*params[:splat]) send_file File.join(settings.teatime.test_dir, js_test_file) end get '/vendor/*' do js_vendor_file = File.join(*params[:splat]) send_file File.join(settings.teatime.vendor_dir, js_vendor_file) end private def vendor_js_files %w{mocha.js chai.js}.map do |file_path| File.join 'vendor', 'javascripts', File.basename(file_path) end end def vendor_css_files %w{mocha.css}.map do |file_path| File.join 'vendor', 'stylesheets', File.basename(file_path) end end def js_helper_files Dir[File.join(settings.teatime.test_dir, settings.teatime.test_helpers)].map do |helper_file| File.join 'test', helper_file.gsub(%r{^#{settings.teatime.test_dir}}, '') end end def js_lib_files Dir[File.join(settings.teatime.lib_dir, settings.teatime.lib_files)].map do |lib_file| File.join lib_file.gsub(%r{^#{settings.teatime.lib_dir}}, '') end end def js_test_files Dir[File.join(settings.teatime.test_dir, settings.teatime.test_files)].map do |test_file| File.join 'test', test_file.gsub(%r{^#{settings.teatime.test_dir}}, '') end end def js_files vendor_js_files + js_lib_files + js_helper_files + js_test_files end def css_files vendor_css_files end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
teatime-0.0.2 | lib/teatime/server.rb |
teatime-0.0.1 | lib/teatime/server.rb |