Skip to content

Commit

Permalink
Use Rack::Static and Bundler.require
Browse files Browse the repository at this point in the history
  • Loading branch information
lifo committed Aug 4, 2011
1 parent b8cd884 commit e440d90
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 10 deletions.
3 changes: 3 additions & 0 deletions lib/cramp/generators/application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ def create_root_files
template 'config.ru'
template 'Gemfile'
template 'application.rb'

empty_directory "public"
empty_directory "public/javascripts"
end

def create_config
Expand Down
5 changes: 5 additions & 0 deletions lib/cramp/generators/templates/application/Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,8 @@ gem 'activerecord'
# Generic interface to multiple Ruby template engines - https://github.com/rtomayko/tilt
# gem 'tilt'
group :development do
# Development gems
# gem 'ruby-debug19'
end
14 changes: 5 additions & 9 deletions lib/cramp/generators/templates/application/application.rb
Original file line number Diff line number Diff line change
@@ -1,15 +1,6 @@
require "rubygems"
require "bundler"

Bundler.setup(:default)

require 'cramp'
require 'http_router'
<% if active_record? %>require 'active_record'
<% end %>
# Preload application classes
Dir['./app/**/*.rb'].each {|f| require f}

module <%= app_const_base %>
class Application
Expand All @@ -33,3 +24,8 @@ def self.initialize!<% if active_record? %>
end
end
Bundler.require(:default, <%= app_const %>.env)

# Preload application classes
Dir['./app/**/*.rb'].each {|f| require f}
4 changes: 3 additions & 1 deletion lib/cramp/generators/templates/application/config.ru
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@ require './application'
# Development middlewares
if <%= app_const %>.env == 'development'
require 'async-rack'
use AsyncRack::CommonLogger

# Enable code reloading on every request
use Rack::Reloader, 0

# Serve assets from /public
use Rack::Static, :urls => ["/javascripts"], :root => File.expand_path("./public", __FILE__)
end

# Running thin :
Expand Down

0 comments on commit e440d90

Please sign in to comment.