forked from foca/utility_scripts
-
Notifications
You must be signed in to change notification settings - Fork 3
/
railify
executable file
·160 lines (130 loc) · 4.94 KB
/
railify
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
#!/usr/bin/env ruby
# Generate a rails app (using EDGE rails), set up a git repo for it, install GemsOnRails,
# haml, rspec, and make_resourceful
#
# USAGE: $0 some_app_name
#
# See http://github.com/foca/utility_scripts/ for the latest version
# Released under a WTFP license (http://sam.zoy.org/wtfpl/)
RAILS_GIT_CHECKOUT = '/Users/cptfinch/developments/rails/apps/rails_git_checkout/rails'
module Helpers
LINE = 80
def announcing(msg)
print msg
yield
print "." * (LINE - msg.size - 6)
puts "\e[32m[DONE]\e[0m"
end
def silent(command)
# system "#{command} &> /dev/null"
system "#{command}"
end
def templates
{ :gitignore => %w[config/database.yml tmp/* log/*.log db/*.sqlite3 public/stylesheets/application.css] * "\n",
:routes => ["ActionController::Routing::Routes.draw do |map|", "end"] * "\n" }
end
def gitci(message)
silent 'git add .'
silent "git commit -m '#{message}'"
end
def braid(repo, dir, type="git")
silent "braid add #{repo} --type #{type} #{dir}"
silent "git merge braid/track"
end
def rake(task, args={})
args = args.map {|name,value| "#{name.to_s.upcase}=#{value}"}.join(" ")
silent "rake #{task} #{args}"
end
def gitsub(repo, dir)
silent "git submodule add #{repo} #{dir}"
end
end
if __FILE__ == $0
include Helpers
app_name = ARGV.first
announcing "Updating EDGE rails (git pull)" do
Dir.chdir(RAILS_GIT_CHECKOUT) { silent "git pull" }
end
announcing "Creating application layout" do
silent "ruby #{RAILS_GIT_CHECKOUT}/railties/bin/rails #{app_name}"
end
Dir.chdir(app_name) do
announcing "Setting up rails app" do
silent "rm README"
silent "rm public/index.html"
silent "rm log/*.log"
silent "rm public/images/rails.png"
silent "cp config/database.{,sample.}yml"
silent "rm -r test"
# File.open("config/routes.rb", "w") {|f| f << templates[:routes] }
end
announcing "Creating databases" do
rake "db:create"
rake "db:create", :rails_env => "test"
end
announcing "Configuring git repo" do
silent "git init"
File.open(".gitignore", "w") {|f| f << templates[:gitignore] }
silent "touch {tmp,log}/.gitignore"
gitci "Basic rails app structure"
end
announcing "Freezing rails" do
silent "git submodule add git://github.com/rails/rails.git vendor/rails"
silent "git submodule init"
end
announcing "Installing GemsOnrails" do
silent "gemsonrails"
gitci "Froze GemsOnRails plugin"
end
announcing "Installing haml" do
silent "haml --rails ."
rake "gems:freeze", :gem => "haml"
gitci "Froze haml gem and plugin"
end
announcing "Installing RSpec" do
silent "git submodule add git://github.com/dchelimsky/rspec.git vendor/plugins/rspec"
silent "git submodule add git://github.com/dchelimsky/rspec-rails.git vendor/plugins/rspec-rails"
silent "git submodule init"
end
announcing "Generating RSpec base files" do
silent "script/generate rspec"
gitci "Added RSpec base files"
end
announcing "Installing make_resourceful" do
silent "git submodule add git://github.com/jcfischer/make_resourceful.git vendor/plugins/make_resourceful"
silent "git submodule init"
gitci "Installed make_resourceful plugin"
end
announcing "Installing sexy_scaffold" do
silent "git submodule add git://github.com/dfischer/sexy_scaffold.git vendor/plugins/sexy_scaffold"
silent "git submodule init"
gitci "Installed sexy_scaffold plugin"
end
announcing "Installing rspec_on_crack" do
silent "git submodule add git://github.com/technoweenie/rspec_on_rails_on_crack.git vendor/plugins/rspec_on_rails_on_crack"
silent "git submodule init"
gitci "Installed rspec_on_crack plugin"
end
announcing "Installing acts_as_list" do
# silent "script/plugin install git://github.com/veilleperso/acts_as_list.git"
silent "git submodule add git://github.com/veilleperso/acts_as_list.git vendor/plugins/acts_as_list"
silent "git submodule init"
gitci "Installed acts_as_list plugin"
end
announcing "Installing acts_as_state_machine" do
silent "git submodule add git://github.com/omghax/acts_as_state_machine.git vendor/plugins/acts_as_state_machine"
silent "git submodule init"
gitci "Installed acts_as_state_machine plugin"
end
announcing "Installing restful-authentication" do
silent "git submodule add git://github.com/technoweenie/restful-authentication.git vendor/plugins/restful-authentication"
silent "git submodule init"
gitci "Installed restful-authentication plugin"
end
announcing "Installing auto_migrations" do
silent "git submodule add git://github.com/pjhyett/auto_migrations.git vendor/plugins/auto_migrations"
silent "git submodule init"
gitci "Installed auto_migrations plugin"
end
end
end