/
rails3.rb
260 lines (205 loc) · 6.35 KB
/
rails3.rb
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
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
# To use
# rails new appname --skip-gemfile -JTm tiny.cc/rails3
### File templates first, commands after
# Install and configure standard gems
file "Gemfile",<<-END
# Edit this Gemfile to bundle your application's dependencies.
source 'http://rubygems.org'
gem 'rails'
gem "haml-rails"
gem "jquery-rails"
# gem 'aws-s3', :require => 'aws/s3'
# gem 'bcrypt-ruby', :require => 'bcrypt'
# gem 'formtastic'
# gem 'devise'
group :development, :test do
gem "sqlite3-ruby", :require => 'sqlite3'
gem "ruby-debug19", :require => 'ruby-debug'
# nice table displays in Rails console
gem "hirb"
# Data export
gem "yaml_db"
# css framework for dev machine
gem "compass"
# model layer, test data generation
gem "factory_girl_rails"
# Useful for fake data generation
gem "faker"
gem "randexp"
gem "random_data"
gem 'forgery'
# testing
# gem 'database_cleaner', :git => 'https://github.com/bmabey/database_cleaner.git'
gem "rspec-rails"
gem 'shoulda-matchers'
# controller helper not available for integration tests, so use webrat for now
gem "capybara", :git => 'git://github.com/jnicklas/capybara.git', :require => 'capybara/rspec'
gem "launchy"
gem "ZenTest"
gem "autotest-rails"
end
END
# Default application layout
file "app/views/layouts/application.html.haml",<<-END
!!!
%html(lang='en')
%head
%meta(charset='utf-8')
%title
= render 'layouts/head'
= yield :stylesheets
= yield :javascripts
%body
#container
%header
= render 'layouts/flashes'
#main
= yield
%footer
= debug(params)
= debug(cookies)
END
file "app/views/layouts/_flashes.html.haml", <<-END
- flash.each do |type, value|
.flash{ :class => type.to_s }
= value
END
file "app/views/layouts/_head.html.haml", <<-END
= javascript_include_tag "http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"
= javascript_include_tag 'http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.9/jquery-ui.min.js'
= javascript_include_tag :all
= stylesheet_link_tag "main", :media => "screen, projection"
= stylesheet_link_tag "print", :media => "print"
<!--[if IE]><link href="stylesheets/ie.css" rel="stylesheet" /><![endif]-->
<!-- HTML5 Shiv http://code.google.com/p/html5shiv/ -->
<!--[if lt IE 9]>
<script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<script src="http://ie7-js.googlecode.com/svn/version/2.1(beta4)/IE9.js">IE7_PNG_SUFFIX=".png";</script>
<![endif]-->
= favicon_link_tag
/= render 'layouts/google_analytics'
END
# Default sass template
file "app/stylesheets/main.sass", <<-END
// API located at: http://compass-style.org/docs/reference/compass/
@import blueprint/reset
$blueprint-grid-columns : 24
$blueprint-grid-width : 30px
$blueprint-grid-margin : 10px
$blueprint-grid-outer-width = $blueprint_grid_width + $blueprint_grid_margin
$blueprint-container-size = $blueprint_grid_outer_width * $blueprint_grid_columns - $blueprint_grid_margin
@import blueprint
@import blueprint/scaffolding
@import "compass/support"
@import "compass/css3/text-shadow"
@import "compass/utilities/lists/horizontal-list"
@import "compass/utilities/links"
@import "compass/utilities/general/min"
@import "compass/utilities/text/replacement"
@import "compass/utilities/lists/inline-block-list"
+blueprint
+blueprint-scaffolding
@mixin horizontal-center($width: 500px)
display: block
width: $width
margin: 0 auto
header, nav, footer
+column($blueprint_grid_columns, true)
#container
+container
END
# Google analytics partial
file "app/views/layouts/_google_analytics.html.erb", <<-END
<script>
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-XXXXXXX-1']);
_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
</script>
END
run "rm .gitignore"
file ".gitignore", <<-END
tags
log/*.log
*.swp
*.swo
.sass-cache
*~
*.cache
*.log
*.pid
tmp/**/*
db/*.sqlite3
db/data.yml
vendor/bundle
END
file "spec/changes", <<-END
##previously needed, but not needed with Jose Valim hack
# config.use_transactional_fixtures = false
include Capybara::DSL
# config.before(:suite) do
# DatabaseCleaner.strategy = :transaction
# DatabaseCleaner.clean_with :truncation
# end
#
# config.before(:each) do
# DatabaseCleaner.start
# end
#
# config.after(:each) do
# DatabaseCleaner.clean
# end
END
file "spec/support/shared_connection.rb", <<-END
# see following URL thread for more info
# http://groups.google.com/group/ruby-capybara/browse_thread/thread/248e89ae2acbf603/122ed17a45f3b397?lnk=raot#122ed17a45f3b397
class ActiveRecord::Base
mattr_accessor :shared_connection
@@shared_connection = nil
def self.connection
@@shared_connection || retrieve_connection
end
end
# Forces all threads to share the same connection. This works on
# Capybara because it starts the web server in a thread.
ActiveRecord::Base.shared_connection = ActiveRecord::Base.connection
END
file "README.md", <<-END
Compile css with:
compass watch
Create Pivotal Tracker project
Create stories, specs and tests
Create heroku and github repos and remotes
Ensure that files listed in SECRETS are never shared publicly
END
file "SECRETS", <<-END
config/initializers/secret_token.rb
config/database.yml
END
# Create git repository
git :init
run "rm README"
run "rm public/index.html"
run "rm app/views/layouts/application.html.erb"
run 'bundle install --path vendor/bundle'
# Install haml/sass/compass
run "compass init rails --css-dir=public/stylesheets --sass-dir=app/stylesheets --images-dir=public/images -x sass --using blueprint/basic"
# no initializer.. causes probs with heroku
run "rm config/initializers/compass.rb"
# Install rspec
generate "rspec:install"
run "echo '--format documentation' >> .rspec"
# run 'mkdir spec/{routing,models,controllers,views,helpers,mailers,requests}'
run "touch spec/factories.rb"
# Install jquery - remove after rails 3.1
run "rails generate jquery:install"
# git:hold_empty_dirs
run("find . \\( -type d -empty \\) -and \\( -not -regex ./\\.git.* \\) -exec touch {}/.gitignore \\;")
run "ctags -R"
git :add => "."
git :commit => "-a -m 'Finishing application setup'"
git :branch => "dev"