Never been to DZone Snippets before?

Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

Init rails project script (See related posts)

From http://vinsol.com/2007/02/08/ruby-script-for-creating-new-rails-project-and-initial-svn-import-with-ignoringremoving-logother-files

   1  
   2  require 'fileutils'
   3  
   4  puts  "########################################"
   5  puts  "This script creates a new rails project and do the initial svn import with ignoring/deleting files from subversion"
   6  puts  "Please send your feedback to Akhil Bansal<bansalakhil30.10@gmail.com>"
   7  puts  "I have tested this script and it works great on my system."
   8  puts  ""
   9  puts  ""
  10  puts  "                    ###### ATTENTION #######"
  11  puts  ""
  12  puts  ""
  13  puts  "Use this script at your own risk, if your computer explodes its not my fault :-) "
  14  puts  "#######################################"
  15  
  16  puts  "Enter svn username: "
  17  username = gets.strip
  18  puts  "Enter the svn url: "
  19  svn_url =gets.strip
  20  
  21  puts  "Enter Rails Application Path:(eg: /home/akhil/ror): "
  22  app_path = gets.strip
  23  puts  "Enter Application Name: "
  24  app_name = gets.strip
  25  
  26  puts  "######################################"
  27  
  28  
  29  puts  "Please verify the following variables: "
  30  puts  "Svn Username: #{username}"
  31  puts  "Svn URL: #{svn_url}"
  32  puts  "Application Path: #{app_path}"
  33  puts  "Application name: #{app_name}"
  34  
  35  puts  "Proceed (y/n)"
  36  proceed = gets
  37  proceed = proceed.strip.upcase
  38  if proceed == 'N' 
  39      puts  "Terminating..."
  40      exit 0
  41  elsif proceed == 'Y' 
  42      if system("rails -v")
  43        s="/"
  44      elsif   system("rails.cmd -v")
  45        s="\\"
  46      else
  47          puts "Cannot find rails. Terminating..."
  48          exit 0
  49      end    
  50      app_root=app_path+s+ app_name
  51      
  52      puts  "Generating rails project: (#{app_root})"
  53      if system("rails #{app_root}")
  54        s="/"
  55      elsif   system("rails.cmd #{app_root}")
  56        s="\\"
  57      else
  58          puts "Cannot create rails project. Terminating..."
  59          exit 0
  60      end    
  61      
  62      puts  "SVNinitial import: "
  63      system("svn import #{app_root} #{svn_url} -m \"Initial Import\" --username #{username}")
  64     
  65      FileUtils.remove_dir(app_root, true)
  66     
  67      puts  "Checking out from svn: "
  68  
  69      system("svn checkout #{svn_url} #{app_root}")
  70      FileUtils.cd(app_root, :verbose => true)
  71      
  72      puts  "Removing all log files from SVN"
  73      system("svn remove log"+s+"*")
  74      puts  "commiting..."
  75      system("svn commit -m \"removing all log files from subversion \" ")
  76      puts  "Ignoring all log files under log dir"
  77      system("svn propset svn:ignore \"*.log\" log"+s)
  78      puts  "Updating and commiting..."
  79      system("svn update log"+s)
  80      system("svn commit -m \"Ignoring all files in "+s+"log"+s+" ending in .log \" ")
  81      puts  "Removing tmp directory from SVN"
  82      system("svn remove tmp"+s)
  83      puts  "commiting..."
  84      system("svn commit -m \"removing the temp directory from subversion \" ")
  85      puts  "Ignoring tmp dir"
  86      system("svn propset svn:ignore \"*\" tmp"+s)
  87      puts  "Updating and commiting again...."
  88  
  89      system("svn update tmp"+s)
  90      system("svn commit -m \"Ignore the whole tmp"+s+" directory, might not work on subdirectories? \" ")
  91      puts  "Moving database.yml to database.example"
  92      system("svn move config"+s+"database.yml config"+s+"database.example")
  93      puts  "commiting..."
  94      system("svn commit -m \"Moving database.yml to database.example to provide a template for anyone who checks out the code \" ")
  95      puts  "Ignoring database.yml , updating and commiting..."
  96      system("svn propset svn:ignore 'database.yml' config"+s)
  97      system("svn update config"+s)
  98      system("svn commit -m \"Ignoring database.yml\" ")
  99      puts  "Finished."
 100  
 101  else
 102      puts  "Unknown Input. Terminating..."
 103  	exit 0
 104  end

You need to create an account or log in to post comments to this site.


Click here to browse all 5545 code snippets

Related Posts