• RSS
  • Delicious
  • Digg
  • Facebook
  • Twitter
  • Linkedin
  • Youtube

Some days go I wrote a bash script for creating new rails project and initial SVN import (with ignoring/removing log/other files). And I received many comments if I could write a ruby script for this stuff. Hence here is the ruby script for creating new rails project and initial SVN import (with ignoring/removing log/other files). Copy this script to any of your directory as “create_rails_with_subversion.rb” and execute by issuing “ruby create_rails_with_subversion.rb ”
You may need command line subversion for windows.

I have tested it at my windows and linux machine, if it not work for you please let me know.

Also I love to have your comments…. :)

6 Responses so far.

  1. Danger says:

    If you put a shebang at the top of the file then it won’t require the .rb extension or need to be run by Ruby when it’s on a *nix system.
    #!/usr/bin/env ruby

    Thanks for this!

  2. Tom Chappell says:

    Nice script! There is a small bug in the handling of the ‘tmp’ directory, which can be easily corrected:

    Add the following line to the top of the file:
    require ‘find’

    Then, replace these lines…

    system(“svn commit -m \”removing the temp directory from subversion \” “)
    puts “Ignoring tmp dir”
    system(“svn propset svn:ignore \”*\” tmp”+s)
    puts “Updating and commiting again….”
    system(“svn update tmp”+s)
    system(“svn commit -m \”Ignore the whole tmp”+s+” directory, might not work on subdirectories? \” “)
    …with these lines:

    # Traverse the “tmp” subtree, ignoring directories which start with “.”,
    # marking any remaining directories with a property to ignore all files,
    # and removing any files therein from subversion.
    Find.find(“tmp”) do |path|
    if FileTest.directory?(path)
    if File.basename(path)[0] == ?.
    Find.prune # Skip this directory (e.g. “..”, “.svn”)
    else
    # Tell subversion to ignore all files in this directory.
    system(“svn propset svn:ignore \”*\” “+path)
    end
    else
    # Remove any files from subversion.
    system(“svn remove “+path)
    end
    end
    system(“svn commit -m \”removing the tmp subtree from subversion \” “)

    …and the tmp subtree will be properly excluded from subversion.

    The problem was that the old code was not marking subdirectories of ‘tmp’ with the svn:ignore property. The new code removes any stray files under tmp, and marks the ‘tmp’ directory and all subdirectories of ‘tmp’ with the svn:ignore property.

  3. osmos says:

    This sounds good, but the download link doesn’t work. Could you update the link or file?

  4. sb says:

    The download link here is broken but don’t worry, you can find a modified one here: http://topher.88-mph.net/2007/6/21/ruby-script-for-creating-a-rails-app

  5. Jerry says:

    Early bird gets the worm,


Asset Pipeline has been extracted a...

The asset pipeline which was introduced in Rails 3.1, has ...

ClientSideValidations: Add/Map mode...

https://twitter.com/bansalakhil/status/256699237230845952

Action and Page caching has been ex...

With the commit c82cf81f00f Action and Page caching has been extracted ...

turbo-sprockets-rails3: Speeds up ...

http://twitter.com/bansalakhil/status/253420357841723393

EdgeRails: ActiveRecord::SessionSto...

With the commit 3324e28804 ActiveRecord::SessionStore is extracted out of Rails into ...

Asset Pipeline has been extracted a...

The asset pipeline which was introduced in Rails 3.1, has ...

ClientSideValidations: Add/Map mode...

https://twitter.com/bansalakhil/status/256699237230845952

Action and Page caching has been ex...

With the commit c82cf81f00f Action and Page caching has been extracted ...

turbo-sprockets-rails3: Speeds up ...

http://twitter.com/bansalakhil/status/253420357841723393

EdgeRails: ActiveRecord::SessionSto...

With the commit 3324e28804 ActiveRecord::SessionStore is extracted out of Rails into ...