Created
October 16, 2011 14:35
-
-
Save davidglassborow/1290936 to your computer and use it in GitHub Desktop.
Rails 3.1 Template for DataMapper 1.2.0.rc2
This file contains hidden or 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 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' | |
inject_into_file 'app/controllers/application_controller.rb', | |
"require 'dm-rails/middleware/identity_map'\n", | |
:before => 'class ApplicationController' | |
inject_into_class 'app/controllers/application_controller.rb', | |
'ApplicationController', | |
" use Rails::DataMapper::Middleware::IdentityMap\n" | |
say '' | |
say '---------------------------------------------------------------------------' | |
say "Edit your Gemfile (do not forget to run 'bundle install' after doing that)" | |
say "Some of the following commands assume that you passed the --binstubs option" | |
say "to bundle install. If you haven't done so, use 'bundle exec rake' where the" | |
say "examples below use './bin/rake'" | |
say '---------------------------------------------------------------------------' | |
say 'If you want to use rspec for testing, you first need to uncomment the line' | |
say "that declares it in the Gemfile. The you need to run 'bundle install' again" | |
say "Once that's done, you need to actually install it into your app and update" | |
say "your spec_helper as shown in the dm-rails README" | |
say '---------------------------------------------------------------------------' | |
say 'Install rspec (optional): rails g rspec:install' | |
say 'Have a look at the dm-rails README: http://github.com/datamapper/dm-rails' | |
say '---------------------------------------------------------------------------' | |
say 'Have a look at available rake tasks: ./bin/rake -T' | |
say 'Generate a simple scaffold: rails g scaffold Person name:string' | |
say 'Create, automigrate and seed the DB: ./bin/rake db:setup' | |
say 'Start the server: rails server' | |
say '---------------------------------------------------------------------------' | |
say 'After the sever booted, point your browser at http://localhost:3000/people' | |
say '---------------------------------------------------------------------------' | |
say '' |
This file contains hidden or 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
# workaround <<-GEMFILE wanting to | |
# execute the string subsitution | |
DATAMAPPER = '#{DATAMAPPER}' | |
RSPEC = '#{RSPEC}' | |
database = options[:database] | |
database = 'postgres' if database == 'postgresql' | |
database = 'sqlite' if database == 'sqlite3' | |
remove_file 'Gemfile' | |
create_file 'Gemfile' do | |
<<-GEMFILE | |
source :rubygems | |
RAILS_VERSION = '~> 3.1.1' | |
DM_VERSION = '~> 1.2.0.rc2' | |
gem 'tzinfo', '~> 0.3.30' | |
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', '~> 1.2.0.rc2' | |
gem 'dm-#{database}-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-sqlite-adapter', DM_VERSION | |
# 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 'data_mapper', DM_VERSION | |
gem 'dm-observer', DM_VERSION | |
group :development, :test do | |
# Uncomment this if you want to use rspec for testing your application | |
# gem 'rspec-rails', '~> 2.6.1' | |
# To get a detailed overview about what queries get issued and how long they take | |
# have a look at rails_metrics. Once you bundled it, you can run | |
# | |
# rails g rails_metrics Metric | |
# rake db:automigrate | |
# | |
# to generate a model that stores the metrics. You can access them by visiting | |
# | |
# /rails_metrics | |
# | |
# in your rails application. | |
# gem 'rails_metrics', '~> 0.1', :git => 'git://github.com/engineyard/rails_metrics' | |
end | |
GEMFILE | |
end |
This file contains hidden or 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
apply 'https://raw.github.com/gist/1273212/gemfile.rb' | |
apply 'https://raw.github.com/gist/1273212/application.rb' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment