Skip to content

Instantly share code, notes, and snippets.

@elfassy
Created January 17, 2012 20:20
Show Gist options
  • Select an option

  • Save elfassy/1628663 to your computer and use it in GitHub Desktop.

Select an option

Save elfassy/1628663 to your computer and use it in GitHub Desktop.

Revisions

  1. elfassy created this gist Jan 17, 2012.
    31 changes: 31 additions & 0 deletions clone_rails.thor
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,31 @@
    #!/usr/bin/env ruby
    require "rubygems" # ruby1.9 doesn't "require" it though
    require "thor"

    class CloneRails < Thor
    include Thor::Actions
    desc "new NAME, TEMPLATE", "Create a new rails app based on a template app"
    method_options :template => "template"
    def new(name)
    puts "Copying the template..."
    FileUtils.cp_r(options[:template],name)
    FileUtils.cd(name)
    puts "Generating your new application..."
    run "rails g rename_to #{name}"
    FileUtils.rm_r('vendor/plugins/Rename')

    # commit to git
    run "git init"
    run "git add ."
    run "git commit -a -m 'create initial application'"

    puts <<-eos
    ============================================================================
    Your new Rails application is ready to go.
    Don't forget to scroll up for important messages from installed generators.
    eos
    end
    end

    CloneRails.start