prop_up 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +17 -0
- data/Gemfile +4 -0
- data/LICENSE +22 -0
- data/README.md +228 -0
- data/Rakefile +2 -0
- data/bin/prop +14 -0
- data/lib/prop/actions.rb +40 -0
- data/lib/prop/app_builder.rb +334 -0
- data/lib/prop/generators/app_generator.rb +212 -0
- data/lib/prop/version.rb +3 -0
- data/peg-leg-bates.jpg +0 -0
- data/prop.gemspec +31 -0
- data/templates/Gemfile_clean +56 -0
- data/templates/Guardfile +11 -0
- data/templates/Procfile +2 -0
- data/templates/README.md.erb +6 -0
- data/templates/_flashes.html.erb +5 -0
- data/templates/_javascript.html.erb +9 -0
- data/templates/application.css.scss +5 -0
- data/templates/background_jobs_rspec.rb +19 -0
- data/templates/bin_setup +25 -0
- data/templates/config_locales_en.yml +11 -0
- data/templates/database_cleaner_rspec.rb +21 -0
- data/templates/disable_xml_params.rb +3 -0
- data/templates/errors.rb +28 -0
- data/templates/factories_spec.rb +13 -0
- data/templates/factories_spec_rake_task.rb +9 -0
- data/templates/factory_girl_syntax_rspec.rb +3 -0
- data/templates/javascripts/prefilled_input.js +59 -0
- data/templates/postgresql_database.yml.erb +11 -0
- data/templates/prop_gitignore +15 -0
- data/templates/prop_layout.html.erb.erb +15 -0
- data/templates/rack_timeout.rb +1 -0
- data/templates/sample.env +2 -0
- data/templates/smtp.rb +10 -0
- data/templates/spec_helper.rb +31 -0
- data/templates/unicorn.rb +26 -0
- metadata +115 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: fa06a9843fd70391c6eeea5bc6ec6367bc542022
|
4
|
+
data.tar.gz: ff82e6f19d3ac2edd571e890655e30fcb4ca3e62
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 696346f3d82eccefc517e29a0f85ab92ffeb4fa92d94b8432681472b25832d8ad9517f70142134b0a5653eb7f1e8806096cb64da9d361b2dc13646a75b0999f1
|
7
|
+
data.tar.gz: fd292bad7f6f5628ce8d3ff38cc203cde376c95069a0ca81b22e45304caeefb561a42ef1d7cb9a17681b4bf4fce1014b40183ab97033e5c4383db5d4bedca230
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2013 Nathaniel Wroblewski
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,228 @@
|
|
1
|
+
Prop
|
2
|
+
===
|
3
|
+
![Peg Leg Bates Photo](https://raw.github.com/NathanielWroblewski/prop/master/app/assets/images/peg-leg-bates.jpg)
|
4
|
+
|
5
|
+
Description
|
6
|
+
---
|
7
|
+
Prop is a Rails 4 app generator with customized defaults and an opinionated workflow.
|
8
|
+
|
9
|
+
Installation
|
10
|
+
---
|
11
|
+
First, install [hub](https://github.com/github/hub) if you don't have it.
|
12
|
+
```bash
|
13
|
+
brew install hub
|
14
|
+
```
|
15
|
+
Install Prop.
|
16
|
+
```bash
|
17
|
+
gem install prop
|
18
|
+
```
|
19
|
+
Let Prop prop your app up.
|
20
|
+
```bash
|
21
|
+
prop up <my-app-name>
|
22
|
+
```
|
23
|
+
Get all up inside your new app.
|
24
|
+
```bash
|
25
|
+
cd <my-app-name>
|
26
|
+
```
|
27
|
+
Open four tabs in your terminal. In the first, start [zeus](https://github.com/burke/zeus).
|
28
|
+
```bash
|
29
|
+
zeus start
|
30
|
+
```
|
31
|
+
Zeus pre-loads your Rails app making specs, rake tasks, and generators run much faster. Common tasks run through zeus include:
|
32
|
+
```bash
|
33
|
+
zeus g migration <name of migration>
|
34
|
+
zeus d migration <name of migration>
|
35
|
+
zeus rake db:create
|
36
|
+
zeus rake db:migrate
|
37
|
+
zeus rake db:test:prepare
|
38
|
+
zeus c
|
39
|
+
zeus s
|
40
|
+
```
|
41
|
+
In general, anything that would normally be `rails blah` is now `zeus blah`, and anything that would be `rake blah` is now `zeus rake blah`. Ctrl+c will exit.
|
42
|
+
|
43
|
+
In the next tab, start the zeus server.
|
44
|
+
```bash
|
45
|
+
zeus s
|
46
|
+
```
|
47
|
+
Use Ctrl+c to exit.
|
48
|
+
|
49
|
+
In the third tab, run [guard](https://github.com/guard/guard).
|
50
|
+
```bash
|
51
|
+
guard
|
52
|
+
```
|
53
|
+
Guard watches your spec files so that anytime you make a change, your specs will run. You can also hit your enter/return key to run all your specs. `exit` will exit guard.
|
54
|
+
|
55
|
+
I use the final tab as my normal terminal window/git branching/for entering `zeus c` when necessary.
|
56
|
+
|
57
|
+
Finally, create your database.
|
58
|
+
|
59
|
+
```bash
|
60
|
+
zeus rake db:create
|
61
|
+
```
|
62
|
+
|
63
|
+
Workflow
|
64
|
+
---
|
65
|
+
At a high level, have a `production` branch, a `master` branch for staging, and your development branches which are prefixed with your initials. Use continuous integration/continuous deployment so that when you push to master, your tests are run and your app is deployed to staging. When you push to production, your tests are run and the app is deployed to production. Rollbar is used to monitor errors, and Codeship is used for CI. The following git practices were inspired by [Thoughtbot](http://www.thoughtbot.com/)'s [protocol](https://github.com/thoughtbot/guides/tree/master/protocol).
|
66
|
+
|
67
|
+
1. Start a story in Pivotal Tracker (http://www.pivotaltracker.com) by clicking the 'start' button of a story assigned to you.
|
68
|
+
|
69
|
+
2. Create a new branch with
|
70
|
+
```bash
|
71
|
+
$ git checkout -b <your initials>-<name of branch>
|
72
|
+
```
|
73
|
+
For example:
|
74
|
+
```bash
|
75
|
+
$ git checkout -b nw-promo-codes
|
76
|
+
```
|
77
|
+
|
78
|
+
3. After changing files, stage your changes
|
79
|
+
```bash
|
80
|
+
$ git status
|
81
|
+
$ git add <changed file>
|
82
|
+
```
|
83
|
+
|
84
|
+
4. Commit your changes with a commit message that is under 80 characters
|
85
|
+
```bash
|
86
|
+
$ git commit -m '<commit message>'
|
87
|
+
```
|
88
|
+
|
89
|
+
5. If you have multiple, smaller commits that could be grouped into a larger commit, check the log to see how many commits you need to group together and then rebase them.
|
90
|
+
```bash
|
91
|
+
$ git log
|
92
|
+
$ git rebase -i HEAD~<the number of commits to be rebased>
|
93
|
+
```
|
94
|
+
For example:
|
95
|
+
```bash
|
96
|
+
$ git rebase -i HEAD~3
|
97
|
+
```
|
98
|
+
|
99
|
+
Note: The syntax is HEAD followed by a tilde (~) not a dash (-)
|
100
|
+
|
101
|
+
You will receive a message like this:
|
102
|
+
```bash
|
103
|
+
pick 95f08f0 <commit message>
|
104
|
+
pick 09d7d95 <commit message>
|
105
|
+
pick c86dd4e <commit message>
|
106
|
+
# Rebase 665d9f8..c86dd4e onto 665d9f8
|
107
|
+
#
|
108
|
+
# Commands:
|
109
|
+
# p, pick = use commit
|
110
|
+
# r, reword = use commit, but edit the commit message
|
111
|
+
# e, edit = use commit, but stop for amending
|
112
|
+
# s, squash = use commit, but meld into previous commit
|
113
|
+
# f, fixup = like "squash", but discard this commit's log message
|
114
|
+
# x, exec = run command (the rest of the line) using shell
|
115
|
+
```
|
116
|
+
|
117
|
+
Change the 'pick' to the appropriate command. In general, the top commit will receive an 'r' while the following commits will be fixed up with an 'f':
|
118
|
+
```bash
|
119
|
+
r 95f08f0 <commit message>
|
120
|
+
f 09d7d95 <commit message>
|
121
|
+
f c86dd4e <commit message>
|
122
|
+
# Rebase 665d9f8..c86dd4e onto 665d9f8
|
123
|
+
#
|
124
|
+
# Commands:
|
125
|
+
# p, pick = use commit
|
126
|
+
# r, reword = use commit, but edit the commit message
|
127
|
+
# e, edit = use commit, but stop for amending
|
128
|
+
# s, squash = use commit, but meld into previous commit
|
129
|
+
# f, fixup = like "squash", but discard this commit's log message
|
130
|
+
# x, exec = run command (the rest of the line) using shell
|
131
|
+
```
|
132
|
+
|
133
|
+
You will then be prompted to rename the commit message. The commit message should be assigned the Pivotal Tracker story id, followed by an 80 character commit message title, and an optional '*' delimited log of more detailed changes.
|
134
|
+
|
135
|
+
Generally, it should follow the form:
|
136
|
+
|
137
|
+
```
|
138
|
+
[#<Pivotal Tracker Story ID>] <80-character commit message>
|
139
|
+
|
140
|
+
* <detailed commit message>
|
141
|
+
* <detailed commit message>
|
142
|
+
```
|
143
|
+
|
144
|
+
For example:
|
145
|
+
```
|
146
|
+
[#12345678] Added a new kit page
|
147
|
+
|
148
|
+
* Generated a new kit controller
|
149
|
+
* Generated a new kit migration
|
150
|
+
...
|
151
|
+
```
|
152
|
+
|
153
|
+
6. If you have not yet pushed, or you didn't squash any commits or otherwise change history, you can leave off the `-f` flag on the following push. Otherwise, the branch you are working on should then be force pushed to change history. Then, open a pull request.
|
154
|
+
```bash
|
155
|
+
$ git branch
|
156
|
+
$ git push origin <branch name> -f
|
157
|
+
```
|
158
|
+
|
159
|
+
For example:
|
160
|
+
|
161
|
+
```bash
|
162
|
+
$ git push origin nw-promo-codes -f
|
163
|
+
```
|
164
|
+
|
165
|
+
A pull request can be made by visiting your github repo, selecting your branch name from the drop down, selecting the pull request icon, and then selecting the button to make a pull request.
|
166
|
+
|
167
|
+
7. When your pull request has been accepted, you should be sure to fetch the lastest master, and rebase master under your latest commit. Then force push to your branch to change history.
|
168
|
+
```bash
|
169
|
+
$ git fetch
|
170
|
+
$ git rebase origin/master
|
171
|
+
$ git push origin <name of branch> -f
|
172
|
+
```
|
173
|
+
|
174
|
+
If you have conflicts, be sure to continue the rebase after resolving the conflicts. Do not commit.
|
175
|
+
```bash
|
176
|
+
$ git status
|
177
|
+
$ git add <file after resolving conflicts>
|
178
|
+
$ git rebase --continue
|
179
|
+
```
|
180
|
+
|
181
|
+
8. Then, checkout master, pull the latest changes, and merge your branch into master only if there will not be a merge conflict.
|
182
|
+
```bash
|
183
|
+
$ git checkout master
|
184
|
+
$ git pull origin master
|
185
|
+
$ git merge <name of branch> --ff-only
|
186
|
+
```
|
187
|
+
For example:
|
188
|
+
```bash
|
189
|
+
$ git merge nw-promo-codes --ff-only
|
190
|
+
```
|
191
|
+
|
192
|
+
9. Now push your changes and delete your branch locally and remotely.
|
193
|
+
```bash
|
194
|
+
$ git push origin master
|
195
|
+
$ git branch -d <name of branch>
|
196
|
+
$ git push origin :<name of branch>
|
197
|
+
```
|
198
|
+
For example:
|
199
|
+
```bash
|
200
|
+
$ git branch -d nw-promo-codes
|
201
|
+
$ git push origin :nw-promo-codes
|
202
|
+
```
|
203
|
+
|
204
|
+
10. Mark your story in Pivotal Tracker as finished.
|
205
|
+
|
206
|
+
11. Once codeship has verified the tests pass, checkout your changes on staging on Heroku.
|
207
|
+
|
208
|
+
12. If your changes have been tested on staging, mark your story as delivered in Pivotal.
|
209
|
+
|
210
|
+
13. Once your story has been accepted and if it is time to push to production, checkout the production branch, merge master into it, and push your changes.
|
211
|
+
```bash
|
212
|
+
$ git checkout production
|
213
|
+
$ git merge master --ff-only
|
214
|
+
$ git push origin production
|
215
|
+
```
|
216
|
+
|
217
|
+
14. Once codeship has verified the tests pass, checkout your changes at on production. Monitor rollbar for any errors that may be occurring.
|
218
|
+
|
219
|
+
TODO
|
220
|
+
====
|
221
|
+
|
222
|
+
* Automate the opening of the iTerm tabs and run the scripts inside those tabs (starting zeus, guard, server)
|
223
|
+
* Add Devise
|
224
|
+
* Add a Google Maps map and a Leaflet map
|
225
|
+
* Add Figaro
|
226
|
+
* Add Google Places library
|
227
|
+
* Add Backbone
|
228
|
+
* Add spec generation
|
data/Rakefile
ADDED
data/bin/prop
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require File.expand_path(File.join('..', 'lib', 'prop', 'generators', 'app_generator'), File.dirname(__FILE__))
|
4
|
+
require File.expand_path(File.join('..', 'lib', 'prop', 'actions'), File.dirname(__FILE__))
|
5
|
+
require File.expand_path(File.join('..', 'lib', 'prop', 'app_builder'), File.dirname(__FILE__))
|
6
|
+
|
7
|
+
if 'up' == ARGV[0]
|
8
|
+
ARGV.shift
|
9
|
+
templates_root = File.expand_path(File.join("..", "templates"), File.dirname(__FILE__))
|
10
|
+
Prop::AppGenerator.source_root templates_root
|
11
|
+
Prop::AppGenerator.source_paths << Rails::Generators::AppGenerator.source_root << templates_root
|
12
|
+
|
13
|
+
Prop::AppGenerator.start
|
14
|
+
end
|
data/lib/prop/actions.rb
ADDED
@@ -0,0 +1,40 @@
|
|
1
|
+
module Prop
|
2
|
+
module Actions
|
3
|
+
def concat_file(source, destination)
|
4
|
+
contents = IO.read(find_in_source_paths(source))
|
5
|
+
append_file(destination, contents)
|
6
|
+
end
|
7
|
+
|
8
|
+
def replace_in_file(relative_path, find, replace)
|
9
|
+
path = File.join(destination_root, relative_path)
|
10
|
+
contents = IO.read(path)
|
11
|
+
unless contents.gsub!(find, replace)
|
12
|
+
raise "#{find.inspect} not found in #{relative_path}"
|
13
|
+
end
|
14
|
+
File.open(path, 'w') { |file| file.write(contents) }
|
15
|
+
end
|
16
|
+
|
17
|
+
def action_mailer_host(rails_env, host)
|
18
|
+
host_config = "config.action_mailer.default_url_options = { host: '#{host}' }"
|
19
|
+
configure_environment(rails_env, host_config)
|
20
|
+
end
|
21
|
+
|
22
|
+
def configure_environment(rails_env, config)
|
23
|
+
inject_into_file(
|
24
|
+
"config/environments/#{rails_env}.rb",
|
25
|
+
"\n\n #{config}",
|
26
|
+
before: "\nend"
|
27
|
+
)
|
28
|
+
end
|
29
|
+
|
30
|
+
def download_file(uri_string, destination)
|
31
|
+
uri = URI.parse(uri_string)
|
32
|
+
http = Net::HTTP.new(uri.host, uri.port)
|
33
|
+
http.use_ssl = true if uri_string =~ /^https/
|
34
|
+
request = Net::HTTP::Get.new(uri.path)
|
35
|
+
contents = http.request(request).body
|
36
|
+
path = File.join(destination_root, destination)
|
37
|
+
File.open(path, 'w') { |file| file.write(contents) }
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,334 @@
|
|
1
|
+
module Prop
|
2
|
+
class AppBuilder < Rails::AppBuilder
|
3
|
+
include Prop::Actions
|
4
|
+
|
5
|
+
def readme
|
6
|
+
template 'README.md.erb', 'README.md'
|
7
|
+
end
|
8
|
+
|
9
|
+
def remove_public_index
|
10
|
+
remove_file 'public/index.html'
|
11
|
+
end
|
12
|
+
|
13
|
+
def remove_rails_logo_image
|
14
|
+
remove_file 'app/assets/images/rails.png'
|
15
|
+
end
|
16
|
+
|
17
|
+
def raise_on_delivery_errors
|
18
|
+
replace_in_file 'config/environments/development.rb',
|
19
|
+
'raise_delivery_errors = false', 'raise_delivery_errors = true'
|
20
|
+
end
|
21
|
+
|
22
|
+
def raise_on_unpermitted_parameters
|
23
|
+
configure_environment 'development',
|
24
|
+
'config.action_controller.action_on_unpermitted_parameters = :raise'
|
25
|
+
end
|
26
|
+
|
27
|
+
def provide_setup_script
|
28
|
+
copy_file 'bin_setup', 'bin/setup'
|
29
|
+
run 'chmod a+x bin/setup'
|
30
|
+
end
|
31
|
+
|
32
|
+
def configure_generators
|
33
|
+
config = <<-RUBY
|
34
|
+
config.generators do |generate|
|
35
|
+
generate.helper false
|
36
|
+
generate.javascript_engine false
|
37
|
+
generate.request_specs false
|
38
|
+
generate.routing_specs false
|
39
|
+
generate.stylesheets false
|
40
|
+
generate.test_framework :rspec
|
41
|
+
generate.view_specs false
|
42
|
+
end
|
43
|
+
RUBY
|
44
|
+
|
45
|
+
inject_into_class 'config/application.rb', 'Application', config
|
46
|
+
end
|
47
|
+
|
48
|
+
def enable_factory_girl_syntax
|
49
|
+
copy_file 'factory_girl_syntax_rspec.rb', 'spec/support/factory_girl.rb'
|
50
|
+
end
|
51
|
+
|
52
|
+
def test_factories_first
|
53
|
+
copy_file 'factories_spec.rb', 'spec/models/factories_spec.rb'
|
54
|
+
append_file 'Rakefile', factories_spec_rake_task
|
55
|
+
end
|
56
|
+
|
57
|
+
def configure_smtp
|
58
|
+
copy_file 'smtp.rb', 'config/initializers/smtp.rb'
|
59
|
+
|
60
|
+
prepend_file 'config/environments/production.rb',
|
61
|
+
"require Rails.root.join('config/initializers/smtp')\n"
|
62
|
+
|
63
|
+
config = <<-RUBY
|
64
|
+
|
65
|
+
config.action_mailer.delivery_method = :smtp
|
66
|
+
config.action_mailer.smtp_settings = SMTP_SETTINGS
|
67
|
+
RUBY
|
68
|
+
|
69
|
+
inject_into_file 'config/environments/production.rb', config,
|
70
|
+
:after => 'config.action_mailer.raise_delivery_errors = false'
|
71
|
+
end
|
72
|
+
|
73
|
+
def setup_staging_environment
|
74
|
+
run 'cp config/environments/production.rb config/environments/staging.rb'
|
75
|
+
|
76
|
+
prepend_file 'config/environments/staging.rb',
|
77
|
+
"Mail.register_interceptor RecipientInterceptor.new(ENV['EMAIL_RECIPIENTS'])\n"
|
78
|
+
end
|
79
|
+
|
80
|
+
def create_partials_directory
|
81
|
+
empty_directory 'app/views/application'
|
82
|
+
end
|
83
|
+
|
84
|
+
def create_shared_flashes
|
85
|
+
copy_file '_flashes.html.erb', 'app/views/application/_flashes.html.erb'
|
86
|
+
end
|
87
|
+
|
88
|
+
def create_shared_javascripts
|
89
|
+
copy_file '_javascript.html.erb', 'app/views/application/_javascript.html.erb'
|
90
|
+
end
|
91
|
+
|
92
|
+
def create_application_layout
|
93
|
+
template 'prop_layout.html.erb.erb',
|
94
|
+
'app/views/layouts/application.html.erb',
|
95
|
+
:force => true
|
96
|
+
end
|
97
|
+
|
98
|
+
def remove_turbolinks
|
99
|
+
replace_in_file 'app/assets/javascripts/application.js',
|
100
|
+
/\/\/= require turbolinks\n/,
|
101
|
+
''
|
102
|
+
end
|
103
|
+
|
104
|
+
def create_common_javascripts
|
105
|
+
directory 'javascripts', 'app/assets/javascripts'
|
106
|
+
end
|
107
|
+
|
108
|
+
def use_postgres_config_template
|
109
|
+
template 'postgresql_database.yml.erb', 'config/database.yml',
|
110
|
+
:force => true
|
111
|
+
end
|
112
|
+
|
113
|
+
def create_database
|
114
|
+
begin
|
115
|
+
bundle_command 'exec rake db:create'
|
116
|
+
rescue
|
117
|
+
run 'pg_ctl -D /usr/local/var/postgres -l /usr/local/var/postgres/server.log start'
|
118
|
+
bundle_command 'exec rake db:create'
|
119
|
+
end
|
120
|
+
end
|
121
|
+
|
122
|
+
def replace_gemfile
|
123
|
+
remove_file 'Gemfile'
|
124
|
+
copy_file 'Gemfile_clean', 'Gemfile'
|
125
|
+
end
|
126
|
+
|
127
|
+
def set_ruby_to_version_being_used
|
128
|
+
inject_into_file 'Gemfile', "\n\nruby '#{RUBY_VERSION}'",
|
129
|
+
after: /source 'https:\/\/rubygems.org'/
|
130
|
+
end
|
131
|
+
|
132
|
+
def enable_database_cleaner
|
133
|
+
copy_file 'database_cleaner_rspec.rb', 'spec/support/database_cleaner.rb'
|
134
|
+
end
|
135
|
+
|
136
|
+
def configure_rspec
|
137
|
+
remove_file 'spec/spec_helper.rb'
|
138
|
+
copy_file 'spec_helper.rb', 'spec/spec_helper.rb'
|
139
|
+
end
|
140
|
+
|
141
|
+
def use_rspec_binstub
|
142
|
+
run 'bundle binstub rspec-core'
|
143
|
+
run 'rm bin/autospec'
|
144
|
+
end
|
145
|
+
|
146
|
+
def configure_background_jobs_for_rspec
|
147
|
+
copy_file 'background_jobs_rspec.rb', 'spec/support/background_jobs.rb'
|
148
|
+
run 'rails g delayed_job:active_record'
|
149
|
+
end
|
150
|
+
|
151
|
+
def configure_time_zone
|
152
|
+
config = <<-RUBY
|
153
|
+
config.active_record.default_timezone = :utc
|
154
|
+
|
155
|
+
RUBY
|
156
|
+
inject_into_class 'config/application.rb', 'Application', config
|
157
|
+
end
|
158
|
+
|
159
|
+
def configure_time_formats
|
160
|
+
remove_file 'config/locales/en.yml'
|
161
|
+
copy_file 'config_locales_en.yml', 'config/locales/en.yml'
|
162
|
+
end
|
163
|
+
|
164
|
+
def configure_rack_timeout
|
165
|
+
copy_file 'rack_timeout.rb', 'config/initializers/rack_timeout.rb'
|
166
|
+
end
|
167
|
+
|
168
|
+
def configure_action_mailer
|
169
|
+
action_mailer_host 'development', "#{app_name}.local"
|
170
|
+
action_mailer_host 'test', 'www.example.com'
|
171
|
+
action_mailer_host 'staging', "staging.#{app_name}.com"
|
172
|
+
action_mailer_host 'production', "#{app_name}.com"
|
173
|
+
end
|
174
|
+
|
175
|
+
def generate_rspec
|
176
|
+
generate 'rspec:install'
|
177
|
+
end
|
178
|
+
|
179
|
+
def generate_clearance
|
180
|
+
generate 'clearance:install'
|
181
|
+
end
|
182
|
+
|
183
|
+
def configure_unicorn
|
184
|
+
copy_file 'unicorn.rb', 'config/unicorn.rb'
|
185
|
+
end
|
186
|
+
|
187
|
+
def setup_foreman
|
188
|
+
copy_file 'sample.env', '.sample.env'
|
189
|
+
copy_file 'Procfile', 'Procfile'
|
190
|
+
end
|
191
|
+
|
192
|
+
def setup_stylesheets
|
193
|
+
remove_file 'app/assets/stylesheets/application.css'
|
194
|
+
copy_file 'application.css.scss',
|
195
|
+
'app/assets/stylesheets/application.css.scss'
|
196
|
+
end
|
197
|
+
|
198
|
+
def setup_guardfile
|
199
|
+
copy_file 'Guardfile', 'Guardfile'
|
200
|
+
end
|
201
|
+
|
202
|
+
def init_zeus
|
203
|
+
run 'zeus init'
|
204
|
+
end
|
205
|
+
|
206
|
+
def gitignore_files
|
207
|
+
remove_file '.gitignore'
|
208
|
+
copy_file 'prop_gitignore', '.gitignore'
|
209
|
+
[
|
210
|
+
'app/views/pages',
|
211
|
+
'spec/lib',
|
212
|
+
'spec/controllers',
|
213
|
+
'spec/helpers',
|
214
|
+
'spec/support/matchers',
|
215
|
+
'spec/support/mixins',
|
216
|
+
'spec/support/shared_examples'
|
217
|
+
].each do |dir|
|
218
|
+
run "mkdir #{dir}"
|
219
|
+
run "touch #{dir}/.keep"
|
220
|
+
end
|
221
|
+
end
|
222
|
+
|
223
|
+
def init_git
|
224
|
+
run 'git init'
|
225
|
+
end
|
226
|
+
|
227
|
+
def create_heroku_apps
|
228
|
+
path_addition = override_path_for_tests
|
229
|
+
run "#{path_addition} heroku create #{app_name}-production --remote=production"
|
230
|
+
run "#{path_addition} heroku create #{app_name}-staging --remote=staging"
|
231
|
+
run "#{path_addition} heroku config:add RACK_ENV=staging RAILS_ENV=staging --remote=staging"
|
232
|
+
end
|
233
|
+
|
234
|
+
def set_heroku_remotes
|
235
|
+
begin
|
236
|
+
concat_file(
|
237
|
+
'templates/bin_setup',
|
238
|
+
"# Set up staging and production git remotes\r
|
239
|
+
git remote add staging git@heroku.com: #{app_name}-staging.git\r
|
240
|
+
git remote add production git@heroku.com: #{app_name}-production.git"
|
241
|
+
)
|
242
|
+
rescue
|
243
|
+
end
|
244
|
+
end
|
245
|
+
|
246
|
+
def create_github_repo(repo_name)
|
247
|
+
path_addition = override_path_for_tests
|
248
|
+
run "#{path_addition} hub create #{repo_name}"
|
249
|
+
end
|
250
|
+
|
251
|
+
def copy_miscellaneous_files
|
252
|
+
copy_file 'errors.rb', 'config/initializers/errors.rb'
|
253
|
+
end
|
254
|
+
|
255
|
+
def customize_error_pages
|
256
|
+
meta_tags =<<-EOS
|
257
|
+
<meta charset='utf-8' />
|
258
|
+
<meta name='ROBOTS' content='NOODP' />
|
259
|
+
EOS
|
260
|
+
|
261
|
+
%w(500 404 422).each do |page|
|
262
|
+
inject_into_file "public/#{page}.html", meta_tags, :after => "<head>\n"
|
263
|
+
replace_in_file "public/#{page}.html", /<!--.+-->\n/, ''
|
264
|
+
end
|
265
|
+
end
|
266
|
+
|
267
|
+
def remove_routes_comment_lines
|
268
|
+
replace_in_file 'config/routes.rb',
|
269
|
+
/Application\.routes\.draw do.*end/m,
|
270
|
+
"Application.routes.draw do\nend"
|
271
|
+
end
|
272
|
+
|
273
|
+
def disable_xml_params
|
274
|
+
copy_file 'disable_xml_params.rb', 'config/initializers/disable_xml_params.rb'
|
275
|
+
end
|
276
|
+
|
277
|
+
def setup_default_rake_task
|
278
|
+
append_file 'Rakefile' do
|
279
|
+
"task(:default).clear\ntask :default => [:spec]\n"
|
280
|
+
end
|
281
|
+
end
|
282
|
+
|
283
|
+
def open_tab
|
284
|
+
run 'PWD = pwd'
|
285
|
+
run 'launch () {
|
286
|
+
/usr/bin/osascript <<-EOF
|
287
|
+
tell application "iTerm"
|
288
|
+
make new terminal
|
289
|
+
tell the current terminal
|
290
|
+
activate current session
|
291
|
+
launch session "Default Session"
|
292
|
+
tell the last session
|
293
|
+
write text "cd $PWD"
|
294
|
+
end tell
|
295
|
+
end tell
|
296
|
+
end tell
|
297
|
+
EOF
|
298
|
+
}'
|
299
|
+
end
|
300
|
+
|
301
|
+
def start_zeus
|
302
|
+
run 'PWD = pwd'
|
303
|
+
run 'launch () {
|
304
|
+
/usr/bin/osascript <<-EOF
|
305
|
+
tell application "iTerm"
|
306
|
+
make new terminal
|
307
|
+
tell the current terminal
|
308
|
+
activate current session
|
309
|
+
launch session "Default Session"
|
310
|
+
tell the last session
|
311
|
+
write text "cd $PWD"
|
312
|
+
write text "zeus start"
|
313
|
+
end tell
|
314
|
+
end tell
|
315
|
+
end tell
|
316
|
+
EOF
|
317
|
+
}'
|
318
|
+
run 'launch'
|
319
|
+
end
|
320
|
+
|
321
|
+
private
|
322
|
+
|
323
|
+
def override_path_for_tests
|
324
|
+
if ENV['TESTING']
|
325
|
+
support_bin = File.expand_path(File.join('..', '..', '..', 'features', 'support', 'bin'))
|
326
|
+
"PATH=#{support_bin}:$PATH"
|
327
|
+
end
|
328
|
+
end
|
329
|
+
|
330
|
+
def factories_spec_rake_task
|
331
|
+
IO.read find_in_source_paths('factories_spec_rake_task.rb')
|
332
|
+
end
|
333
|
+
end
|
334
|
+
end
|