Skip to content
This repository has been archived by the owner on Apr 17, 2018. It is now read-only.

Commit

Permalink
Add application templates for rails3
Browse files Browse the repository at this point in the history
  • Loading branch information
dbussink committed Jun 2, 2010
1 parent f16b77e commit 036eecb
Show file tree
Hide file tree
Showing 5 changed files with 154 additions and 0 deletions.
2 changes: 2 additions & 0 deletions templates/rails.rb
@@ -0,0 +1,2 @@
apply 'http://datamapper.org/templates/rails/gemfile.rb'
apply 'http://datamapper.org/templates/rails/application.rb'
31 changes: 31 additions & 0 deletions templates/rails/application.rb
@@ -0,0 +1,31 @@
# This needs to be called after one of the gemfile templates

apply 'http://datamapper.org/templates/rails/config.rb'
apply 'http://datamapper.org/templates/rails/database.yml.rb'

initializer 'jruby_monkey_patch.rb', <<-CODE
if RUBY_PLATFORM =~ /java/
# ignore the anchor to allow this to work with jruby:
# http://jira.codehaus.org/browse/JRUBY-4649

This comment has been minimized.

Copy link
@dkubb

dkubb Oct 9, 2011

Member

@dbussink this ticket looks like it's been resolved in the JRuby tracker. Do you know if it's safe to remove this monkey patch?

class Rack::Mount::Strexp
class << self
alias :compile_old :compile
def compile(str, requirements, separators, anchor)
self.compile_old(str, requirements, separators)
end
end
end
end
CODE

say ''
say '--------------------------------------------------------------------------'
say "Edit your Gemfile (don't forget to run 'bundle install' after doing that)"
say 'Generate a scaffold: rails generate scaffold Person name:string'
say 'Automigrate the DB: rake db:automigrate'
say 'Start the server: rails server'
say '--------------------------------------------------------------------------'
say 'After the sever booted, point your browser at http://localhost:3000/people'
say '--------------------------------------------------------------------------'
say ''
18 changes: 18 additions & 0 deletions templates/rails/config.rb
@@ -0,0 +1,18 @@
gsub_file 'config/application.rb', /require 'rails\/all'/ do
<<-RUBY
# Pick the frameworks you want:
require 'action_controller/railtie'
require 'dm-rails/railtie'
# require 'action_mailer/railtie'
# require 'active_resource/railtie'
# require 'rails/test_unit/railtie'
RUBY
end

gsub_file 'config/environments/development.rb', /config.action_mailer.raise_delivery_errors = false/ do
"# config.action_mailer.raise_delivery_errors = false"
end

gsub_file 'config/environments/test.rb', /config.action_mailer.delivery_method = :test/ do
"# config.action_mailer.delivery_method = :test"
end
32 changes: 32 additions & 0 deletions templates/rails/database.yml.rb
@@ -0,0 +1,32 @@
# TODO think about a better way
db_name = app_path.split('/').last

remove_file 'config/database.yml'
create_file 'config/database.yml' do
<<-YAML
defaults: &defaults
adapter: sqlite3
development:
database: #{db_name}_development.db
<<: *defaults
# Add more repositories
# repositories:
# repo1:
# adapter: postgresql
# database: sample_development
# username: the_user
# password: secrets
# host: localhost
# repo2:
# ...
test:
database: #{db_name}_app_test.db
<<: *defaults
production:
database: #{db_name}_app_production.db
<<: *defaults
YAML
end
71 changes: 71 additions & 0 deletions templates/rails/gemfile.rb
@@ -0,0 +1,71 @@
# workaround <<-GEMFILE wanting to
# execute the string subsitution
DATAMAPPER = '#{DATAMAPPER}'
RSPEC = '#{RSPEC}'

remove_file 'Gemfile'
create_file 'Gemfile' do
<<-GEMFILE
source 'http://rubygems.org'
RAILS_VERSION = '~> 3.0.0.beta3'
DM_VERSION = '~> 1.0.0.rc3'
RSPEC_VERSION = '~> 2.0.0.beta.9'
gem 'activesupport', RAILS_VERSION, :require => 'active_support'
gem 'actionpack', RAILS_VERSION, :require => 'action_pack'
gem 'actionmailer', RAILS_VERSION, :require => 'action_mailer'
gem 'railties', RAILS_VERSION, :require => 'rails'
gem 'dm-rails', DM_VERSION
gem 'dm-sqlite-adapter', DM_VERSION
# You can use any of the other available database adapters.
# This is only a small excerpt of the list of all available adapters
# Have a look at
#
# http://wiki.github.com/datamapper/dm-core/adapters
# http://wiki.github.com/datamapper/dm-core/community-plugins
#
# for a rather complete list of available datamapper adapters and plugins
# gem 'dm-mysql-adapter', DM_VERSION
# gem 'dm-postgres-adapter', DM_VERSION
# gem 'dm-oracle-adapter', DM_VERSION
# gem 'dm-sqlserver-adapter', DM_VERSION
gem 'dm-migrations', DM_VERSION
gem 'dm-types', DM_VERSION
gem 'dm-validations', DM_VERSION
gem 'dm-constraints', DM_VERSION
gem 'dm-transactions', DM_VERSION
gem 'dm-aggregates', DM_VERSION
gem 'dm-timestamps', DM_VERSION
gem 'dm-observer', DM_VERSION
group(:test) do
gem 'rspec', RSPEC_VERSION
gem 'rspec-core', RSPEC_VERSION, :require => 'rspec/core'
gem 'rspec-expectations', RSPEC_VERSION, :require => 'rspec/expectations'
gem 'rspec-mocks', RSPEC_VERSION, :require => 'rspec/mocks'
gem 'rspec-rails', '~> 2.0.0.beta.9.1'
end
# ------------------------------------------------------------------------------
# These gems are only listed here in the Gemfile because we want to pin them
# to the github repositories for as long as no stable version has been released.
# The dm-core gem is a hard dependency for dm-rails so it would get pulled in by
# simply adding dm-rails. The dm-do-adapter gem is a hard dependency for any of
# the available dm-xxx-adapters. Once we have stable gems available, pinning these
# gems to github will be optional.
gem 'dm-core', DM_VERSION
gem 'dm-do-adapter', DM_VERSION
gem 'dm-active_model', DM_VERSION
GEMFILE
end

0 comments on commit 036eecb

Please sign in to comment.