Sha256: d8282b6e848db4206bad3d90d02b1e5f6d91982b98f212b8de7a77b4bc8bf448

Contents?: true

Size: 1.45 KB

Versions: 534

Compression:

Stored size: 1.45 KB

Contents

#!/usr/bin/env ruby
require 'rubygems'
require 'activesupport'
require 'pathname'

project_name = ARGV[0]
fail("Usage:  #{File.basename(__FILE__)} new_project_name")     unless project_name
fail("Project name must only contain [a-z0-9_]")                unless project_name =~ /^[a-z0-9_]+$/

base_directory = Pathname.new(File.join(File.dirname(__FILE__), '..', '..')).realpath
project_directory = base_directory + project_name
fail("Project directory (#{project_directory}) already exists") if project_directory.exist?

template_url = "git@github.com:thoughtbot/rails-template.git"
changeme = "CHANGEME"

def run(cmd)
  puts "Running '#{cmd}'"
  out = `#{cmd}`
  if $? != 0 
    fail "Command #{cmd} failed: #$?\n#{out}" 
  end
  out
end

def search_and_replace(file, search, replace)
  if File.file?(file)
    contents = File.read(file)
    if contents[search]
      puts "Replacing #{search} with #{replace} in #{file}"
      contents.gsub!(search, replace)
      File.open(file, "w") { |f| f << contents }
    end
  end
end

run("mkdir #{project_directory}")
Dir.chdir(project_directory) or fail("Couldn't change to #{project_directory}")
run("git init")
run("git remote add template #{template_url}")
run("git pull template master")

Dir.glob("#{project_directory}/**/*").each do |file|
  search_and_replace(file, changeme, project_name)
end

run("git commit -a -m 'Initial commit'")

puts
puts "Now login to github and add a new project named '#{project_name.humanize.titleize}'"


Version data entries

534 entries across 534 versions & 29 rubygems

Version Path
headstart-0.5.1 test/rails_root/script/create_project.rb
headstart-0.5.0 test/rails_root/script/create_project.rb
headstart-0.4.2 test/rails_root/script/create_project.rb
headstart-0.4.1 test/rails_root/script/create_project.rb
headstart-0.4.0 test/rails_root/script/create_project.rb
muck-services-0.1.46 test/rails_root/script/create_project.rb
muck-raker-0.3.16 test/rails_root/script/create_project.rb
disguise-2.0.0 test/rails_root/script/create_project.rb
headstart-0.3.0 test/rails_root/script/create_project.rb
headstart-0.1.0 test/rails_root/script/create_project.rb
uploader-2.0.2 test/rails_root/script/create_project.rb
uploader-2.0.0 test/rails_root/script/create_project.rb
uploader-1.0.3 test/rails_root/script/create_project.rb
uploader-1.0.2 test/rails_root/script/create_project.rb
uploader-1.0.1 test/rails_root/script/create_project.rb
cops-0.2.0.7 test/rails_root/script/create_project.rb
uploader-1.0.0 test/rails_root/script/create_project.rb
uploader-0.2.8 test/rails_root/script/create_project.rb
muck-engine-0.4.31 test/rails_root/script/create_project.rb
muck-users-0.3.20 test/rails_root/script/create_project.rb