forked from tc/sinatra-template
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
44 additions
and
78 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
gem 'sinatra' | ||
gem 'haml' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,39 +1,8 @@ | ||
require 'spec/rake/spectask' | ||
require File.join(File.expand_path(File.dirname(__FILE__)), 'vendor', 'gems', 'environment') | ||
|
||
task :default => :test | ||
task :test => :spec | ||
|
||
if !defined?(Spec) | ||
puts "spec targets require RSpec" | ||
else | ||
desc "Run all examples" | ||
Spec::Rake::SpecTask.new('spec') do |t| | ||
t.spec_files = FileList['spec/**/*.rb'] | ||
t.spec_opts = ['-cfs'] | ||
end | ||
end | ||
Bundler.require_env(:test) | ||
|
||
namespace :db do | ||
desc 'Auto-migrate the database (destroys data)' | ||
task :migrate => :environment do | ||
DataMapper.auto_migrate! | ||
end | ||
|
||
desc 'Auto-upgrade the database (preserves data)' | ||
task :upgrade => :environment do | ||
DataMapper.auto_upgrade! | ||
end | ||
end | ||
task :default => :test | ||
|
||
namespace :gems do | ||
desc 'Install required gems' | ||
task :install do | ||
required_gems = %w{ sinatra rspec rack-test dm-core dm-validations | ||
dm-aggregates haml } | ||
required_gems.each { |required_gem| system "sudo gem install #{required_gem}" } | ||
end | ||
end | ||
Dir['tasks/*.rake'].each { |task| load task } | ||
|
||
task :environment do | ||
require 'environment' | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,26 @@ | ||
require 'rubygems' | ||
require 'sinatra' | ||
require 'environment' | ||
|
||
configure do | ||
set :views, "#{File.dirname(__FILE__)}/views" | ||
end | ||
require 'bundler' | ||
Bundler.setup | ||
|
||
error do | ||
e = request.env['sinatra.error'] | ||
Kernel.puts e.backtrace.join("\n") | ||
'Application error' | ||
end | ||
require 'sinatra' | ||
require 'haml' | ||
require 'ostruct' | ||
SiteConfig = OpenStruct.new( | ||
:title => 'Your Application Name', | ||
:author => 'Your Name', | ||
:url_base => 'http://localhost:4567/' | ||
) | ||
|
||
helpers do | ||
# add your helpers here | ||
end | ||
class Application < Sinatra::Base | ||
|
||
# root page | ||
get '/' do | ||
haml :root | ||
configure do | ||
set :public, "#{File.dirname(__FILE__)}/public" | ||
set :views, "#{File.dirname(__FILE__)}/views" | ||
set :haml, { :attr_wrapper => '"' } | ||
end | ||
|
||
get "/" do | ||
haml :index | ||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,17 @@ | ||
require 'application' | ||
|
||
set :run, false | ||
set :environment, :production | ||
disable :run | ||
|
||
use Rack::ShowExceptions | ||
use Rack::Static, :urls => [ '/favicon.ico', '/css' ], :root => "public" | ||
|
||
$LOAD_PATH.unshift("#{File.dirname(__FILE__)}/lib") | ||
Dir.glob("#{File.dirname(__FILE__)}/lib/*.rb") { |lib| require File.basename(lib, '.*') } | ||
|
||
FileUtils.mkdir_p 'log' unless File.exists?('log') | ||
log = File.new("log/sinatra.log", "a") | ||
$stdout.reopen(log) | ||
$stderr.reopen(log) | ||
|
||
run Sinatra::Application | ||
run Application |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
desc "Test" | ||
task :test do | ||
puts "Stub for test" | ||
end |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters