On 3/30/06, Joe Van Dyk <joevandyk@gmail.com>
wrote:> Anyone got a script to share that:
>
> 1. Creates a trunk directory
> 2. Creates a trunk/vendor directory
> 3. Adds the above to svn
> 4. Modifies trunk/vendor to use a certain rails revision (i.e. trunk or
1.1)
> 5. Runs trunk/vendor/rails/.../bin/rails to generate a rails directory
skeleton
> 6. Modifies the svn:ignore for the logs and config/database.yml
> 7. Moves config/database.yml to config/database.yml.sample
> 8. Adds a script/reload_everything.sh.sample script to scripts/ that
> 8a. Drops the dev and test database
> 8b. Reloads the dev and test database
> 8c. Performs migration on the dev and test database
> 8d. Runs rake load_fixtures (to populate the dev database)
> 8e. Runs rake to run the tests
> 9. Ignores script/reload_everything.sh
>
> I think that''s it. Just wondering if anyone''s done
something like
> that before I make my own. That''s generally the process I follow
when
> creating a new Rails project.
>
Fine, be that way. I made my own. Haven''t given it extensive testing
yet, and there''s little in the way of error checking.
Process: Create a svn repository, check it out, cd into it. And then
run this script. Should do most of the above. Hopefully it won''t
erase your system.
#!/usr/bin/env ruby
puts "This will create a Rails project for you!"
puts "You need to be in an (probably empty) svn project when running
this command"
puts "What''s the name of your project? (used for database
name)"
db_name = gets.chomp
puts "Do you want to track:
a) Rails 1.0
b) Rails 1.1
c) Edge Rails"
case gets.chomp
when ''a''
rails = :one_oh
when ''b''
rails = :one_one
when ''c''
rails = :edge
else
puts "You suck"
exit 1
end
puts "Creating directories and doing a svn checkout of Rails"
case rails
when :one_oh
svn = "svn export
http://dev.rubyonrails.org/svn/rails/tags/rel_1-0-0/
trunk/vendor/rails"
when :one_one
svn = "svn export
http://dev.rubyonrails.org/svn/rails/tags/rel_1-1-0/
trunk/vendor/rails"
when :edge
svn = "svn propset svn:externals \"rails
http://dev.rubyonrails.org/svn/rails/trunk/\" trunk/vendor"
end
system "mkdir trunk"
system "mkdir trunk/vendor"
system "svn add trunk trunk/vendor"
system "svn commit -m ''initial import''"
system svn
system "svn up"
system "ruby trunk/vendor/rails/railties/bin/rails trunk"
system "svn add trunk/* trunk/vendor/*"
system "svn commit -m ''adding rails stuff'' trunk"
system "sed ''s/trunk/#{ db_name }/g''
trunk/config/database.yml >
/tmp/database.yml"
system "mv /tmp/database.yml trunk/config/database.yml.sample"
system "svn del trunk/config/database.yml"
system "svn add trunk/config/database.yml.sample"
system "svn commit -m ''removing database.yml and adding a sample
one''
trunk/config/database.yml"
system "svn propset svn:ignore database.yml trunk/config"
system "svn del trunk/log/*"
system "svn commit -m ''removing logs'' trunk/log"
system "svn propset svn:ignore ''*'' trunk/log"
reload_everything_script = <<-EOF
#!/bin/sh
echo
echo " *** Dropping the database..."
echo ''drop database #{db_name}_development; '' | mysql -h
localhost -u root
echo ''drop database #{db_name}_test; '' | mysql -h localhost -u
root
echo
echo " *** Creating the database... "
echo ''create database #{db_name}_development;'' | mysql -h
localhost -u root
echo ''create database #{db_name}_test;'' | mysql -h localhost
-u root
echo
echo " *** Running the migration scripts..."
rake migrate
echo
echo " *** Loading the test fixtures... "
rake load_fixtures
echo
echo " *** Running the tests"
rake default
EOF
File.open("trunk/script/reload_everything.sh.sample", "w")
do |f|
f << reload_everything_script
end
system "chmod +x trunk/script/reload_everything.sh.sample"
system "svn add trunk/script/reload_everything.sh.sample"
system "svn propset svn:ignore reload_everything.sh trunk/script"
system "svn propset svn:ignore ''*'' trunk/db"
system "svn up"
system "svn commit -m ''committing everything'' trunk"
system "cp trunk/config/database.yml.sample trunk/config/database.yml"
system "cp trunk/script/reload_everything.sh.sample
trunk/script/reload_everything.sh"
puts "You should be ready to go! Enjoy! send feedback to Joe Van Dyk
at joe@pinkpucker.net"