wagon_rails 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +4 -0
- data/.ruby-version +1 -0
- data/Gemfile +3 -0
- data/Gemfile.lock +130 -0
- data/LICENSE +22 -0
- data/README.md +92 -0
- data/Rakefile +2 -0
- data/bin/rake +16 -0
- data/bin/rspec +16 -0
- data/bin/wagon_rails +17 -0
- data/lib/wagon_rails/actions.rb +25 -0
- data/lib/wagon_rails/app_builder.rb +342 -0
- data/lib/wagon_rails/generators/app_generator.rb +198 -0
- data/lib/wagon_rails/version.rb +5 -0
- data/lib/wagon_rails.rb +4 -0
- data/templates/Gemfile.erb +42 -0
- data/templates/Procfile +1 -0
- data/templates/README.md.erb +32 -0
- data/templates/_flashes.html.erb +18 -0
- data/templates/action_mailer.rb +5 -0
- data/templates/application.js +9 -0
- data/templates/application.yml +6 -0
- data/templates/application_controller.rb +26 -0
- data/templates/bin_deploy +9 -0
- data/templates/config_i18n_tasks.yml +13 -0
- data/templates/devise_registrations_new.html.erb +16 -0
- data/templates/devise_sessions_new.html.erb +16 -0
- data/templates/disable_xml_params.rb +3 -0
- data/templates/errors.rb +34 -0
- data/templates/high_voltage.rb +4 -0
- data/templates/json_encoding.rb +1 -0
- data/templates/paperclip.rb +8 -0
- data/templates/postgresql_database.yml.erb +12 -0
- data/templates/puma.rb +15 -0
- data/templates/rack_timeout.rb +3 -0
- data/templates/smtp.rb +8 -0
- data/templates/wagon_rails_gitignore +12 -0
- data/templates/wagon_rails_home.html.erb +28 -0
- data/templates/wagon_rails_layout.html.erb.erb +23 -0
- data/wagon_rails.gemspec +35 -0
- metadata +118 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 8cbc07ceb1ef3a44f6acb334d1deca48a3d2e1d6
|
4
|
+
data.tar.gz: 2d8f107514a82894445b7ac4e9d9bfb36067efed
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 0c3abb7f9793294a43ec0a377ee503509c96b3a2d006ca392275225ace291245749837fca9449619b4f44847b4220e57ae77f68122db05f36ffa566e155fd9cf
|
7
|
+
data.tar.gz: 6532be001e3fd90a057768602961f1da9952331ac77b8c270e7cc40b2d7bf2661544095c81dcb984eebdd7a23d42a50aeaed81c10be5337095bd914fa8d316cc
|
data/.gitignore
ADDED
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
2.2.0
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,130 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
wagon_rails (0.1.0)
|
5
|
+
bundler (~> 1.3)
|
6
|
+
rails (= 4.2.0)
|
7
|
+
|
8
|
+
GEM
|
9
|
+
remote: https://rubygems.org/
|
10
|
+
specs:
|
11
|
+
actionmailer (4.2.0)
|
12
|
+
actionpack (= 4.2.0)
|
13
|
+
actionview (= 4.2.0)
|
14
|
+
activejob (= 4.2.0)
|
15
|
+
mail (~> 2.5, >= 2.5.4)
|
16
|
+
rails-dom-testing (~> 1.0, >= 1.0.5)
|
17
|
+
actionpack (4.2.0)
|
18
|
+
actionview (= 4.2.0)
|
19
|
+
activesupport (= 4.2.0)
|
20
|
+
rack (~> 1.6.0)
|
21
|
+
rack-test (~> 0.6.2)
|
22
|
+
rails-dom-testing (~> 1.0, >= 1.0.5)
|
23
|
+
rails-html-sanitizer (~> 1.0, >= 1.0.1)
|
24
|
+
actionview (4.2.0)
|
25
|
+
activesupport (= 4.2.0)
|
26
|
+
builder (~> 3.1)
|
27
|
+
erubis (~> 2.7.0)
|
28
|
+
rails-dom-testing (~> 1.0, >= 1.0.5)
|
29
|
+
rails-html-sanitizer (~> 1.0, >= 1.0.1)
|
30
|
+
activejob (4.2.0)
|
31
|
+
activesupport (= 4.2.0)
|
32
|
+
globalid (>= 0.3.0)
|
33
|
+
activemodel (4.2.0)
|
34
|
+
activesupport (= 4.2.0)
|
35
|
+
builder (~> 3.1)
|
36
|
+
activerecord (4.2.0)
|
37
|
+
activemodel (= 4.2.0)
|
38
|
+
activesupport (= 4.2.0)
|
39
|
+
arel (~> 6.0)
|
40
|
+
activesupport (4.2.0)
|
41
|
+
i18n (~> 0.7)
|
42
|
+
json (~> 1.7, >= 1.7.7)
|
43
|
+
minitest (~> 5.1)
|
44
|
+
thread_safe (~> 0.3, >= 0.3.4)
|
45
|
+
tzinfo (~> 1.1)
|
46
|
+
arel (6.0.0)
|
47
|
+
builder (3.2.2)
|
48
|
+
capybara (2.3.0)
|
49
|
+
mime-types (>= 1.16)
|
50
|
+
nokogiri (>= 1.3.3)
|
51
|
+
rack (>= 1.0.0)
|
52
|
+
rack-test (>= 0.5.4)
|
53
|
+
xpath (~> 2.0)
|
54
|
+
diff-lcs (1.2.5)
|
55
|
+
erubis (2.7.0)
|
56
|
+
globalid (0.3.3)
|
57
|
+
activesupport (>= 4.1.0)
|
58
|
+
hike (1.2.3)
|
59
|
+
i18n (0.7.0)
|
60
|
+
json (1.8.2)
|
61
|
+
loofah (2.0.1)
|
62
|
+
nokogiri (>= 1.5.9)
|
63
|
+
mail (2.6.3)
|
64
|
+
mime-types (>= 1.16, < 3)
|
65
|
+
mime-types (2.4.3)
|
66
|
+
mini_portile (0.6.0)
|
67
|
+
minitest (5.5.1)
|
68
|
+
multi_json (1.10.1)
|
69
|
+
nokogiri (1.6.2.1)
|
70
|
+
mini_portile (= 0.6.0)
|
71
|
+
rack (1.6.0)
|
72
|
+
rack-test (0.6.2)
|
73
|
+
rack (>= 1.0)
|
74
|
+
rails (4.2.0)
|
75
|
+
actionmailer (= 4.2.0)
|
76
|
+
actionpack (= 4.2.0)
|
77
|
+
actionview (= 4.2.0)
|
78
|
+
activejob (= 4.2.0)
|
79
|
+
activemodel (= 4.2.0)
|
80
|
+
activerecord (= 4.2.0)
|
81
|
+
activesupport (= 4.2.0)
|
82
|
+
bundler (>= 1.3.0, < 2.0)
|
83
|
+
railties (= 4.2.0)
|
84
|
+
sprockets-rails
|
85
|
+
rails-deprecated_sanitizer (1.0.3)
|
86
|
+
activesupport (>= 4.2.0.alpha)
|
87
|
+
rails-dom-testing (1.0.5)
|
88
|
+
activesupport (>= 4.2.0.beta, < 5.0)
|
89
|
+
nokogiri (~> 1.6.0)
|
90
|
+
rails-deprecated_sanitizer (>= 1.0.1)
|
91
|
+
rails-html-sanitizer (1.0.1)
|
92
|
+
loofah (~> 2.0)
|
93
|
+
railties (4.2.0)
|
94
|
+
actionpack (= 4.2.0)
|
95
|
+
activesupport (= 4.2.0)
|
96
|
+
rake (>= 0.8.7)
|
97
|
+
thor (>= 0.18.1, < 2.0)
|
98
|
+
rake (10.4.2)
|
99
|
+
rspec (2.99.0)
|
100
|
+
rspec-core (~> 2.99.0)
|
101
|
+
rspec-expectations (~> 2.99.0)
|
102
|
+
rspec-mocks (~> 2.99.0)
|
103
|
+
rspec-core (2.99.0)
|
104
|
+
rspec-expectations (2.99.0)
|
105
|
+
diff-lcs (>= 1.1.3, < 2.0)
|
106
|
+
rspec-mocks (2.99.0)
|
107
|
+
sprockets (2.12.3)
|
108
|
+
hike (~> 1.2)
|
109
|
+
multi_json (~> 1.0)
|
110
|
+
rack (~> 1.0)
|
111
|
+
tilt (~> 1.1, != 1.3.0)
|
112
|
+
sprockets-rails (2.2.4)
|
113
|
+
actionpack (>= 3.0)
|
114
|
+
activesupport (>= 3.0)
|
115
|
+
sprockets (>= 2.8, < 4.0)
|
116
|
+
thor (0.19.1)
|
117
|
+
thread_safe (0.3.4)
|
118
|
+
tilt (1.4.1)
|
119
|
+
tzinfo (1.2.2)
|
120
|
+
thread_safe (~> 0.1)
|
121
|
+
xpath (2.0.0)
|
122
|
+
nokogiri (~> 1.3)
|
123
|
+
|
124
|
+
PLATFORMS
|
125
|
+
ruby
|
126
|
+
|
127
|
+
DEPENDENCIES
|
128
|
+
capybara (~> 2.2, >= 2.2.0)
|
129
|
+
rspec (~> 2.0)
|
130
|
+
wagon_rails!
|
data/LICENSE
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
The MIT License
|
2
|
+
|
3
|
+
Copyright (c) 2010-2012 Mike Burns and thoughtbot, inc.
|
4
|
+
Copyright (c) 2015 Sebastien Saunier and Le Wagon, SAS.
|
5
|
+
|
6
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
7
|
+
of this software and associated documentation files (the "Software"), to deal
|
8
|
+
in the Software without restriction, including without limitation the rights
|
9
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
10
|
+
copies of the Software, and to permit persons to whom the Software is
|
11
|
+
furnished to do so, subject to the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be included in
|
14
|
+
all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
17
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
18
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
19
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
20
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
21
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
22
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,92 @@
|
|
1
|
+
# Wagon Rails
|
2
|
+
|
3
|
+
Wagon Rails is the base Rails application used by [Le Wagon](http://www.lewagon.org/en)'s students during the 9-week FullStack bootcamp. It's the scripted version of [lewagon/rails-kickoff](http://github.com/lewagon/rails-kickoff) where you would manually copy/paste commands to achieve the same result as justone.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
First install the wagon_rails gem:
|
8
|
+
|
9
|
+
```bash
|
10
|
+
$ gem install wagon_rails
|
11
|
+
```
|
12
|
+
|
13
|
+
Then run:
|
14
|
+
|
15
|
+
```bash
|
16
|
+
$ wagon_rails new YOUR_PROJECT_NAME
|
17
|
+
```
|
18
|
+
|
19
|
+
This will create a Rails app in `YOUR_PROJECT_NAME` using the latest version of Rails,
|
20
|
+
create a GitHub repository and an application on Heroku.
|
21
|
+
|
22
|
+
### Advanced usages
|
23
|
+
|
24
|
+
If you don't want to create a GitHub repo, use the `--skip-github` flag, and
|
25
|
+
if you don't want to create an Heroku app, use the `--skip-heroku` flag.
|
26
|
+
|
27
|
+
```bash
|
28
|
+
$ wagon_rails bew YOUR_PROJECT_NAME --skip-github --skip-heroku
|
29
|
+
```
|
30
|
+
|
31
|
+
## Dependencies
|
32
|
+
|
33
|
+
This gem suppose that you have **Postgresql** on your computer. Check out
|
34
|
+
[lewagon/setup](https://github.com/lewagon/setup)
|
35
|
+
|
36
|
+
For the GitHub repo creation, it assumes you have the [hub](https://github.com/github/hub) gem installed.
|
37
|
+
|
38
|
+
|
39
|
+
```bash
|
40
|
+
$ gem install hub
|
41
|
+
```
|
42
|
+
|
43
|
+
And for the Heroku app creation, it assumes that you have the `heroku binary` and are logged in (`heroku login`).
|
44
|
+
|
45
|
+
```bash
|
46
|
+
$ brew install heroku
|
47
|
+
$ heroku login
|
48
|
+
```
|
49
|
+
|
50
|
+
## Gemfile
|
51
|
+
|
52
|
+
To see the latest and greatest gems, look at WagonRails'
|
53
|
+
[Gemfile](templates/Gemfile.erb), which will be appended to the default
|
54
|
+
generated projectname/Gemfile.
|
55
|
+
|
56
|
+
It includes application gems like:
|
57
|
+
|
58
|
+
- [Postgres](https://github.com/ged/ruby-pg) for access to the Postgres database
|
59
|
+
- [Figaro](https://github.com/laserlemon/figaro) for environment variables and configuration management.
|
60
|
+
- [Simple Form](https://github.com/plataformatec/simple_form) for form markup and style
|
61
|
+
- [High Voltage](https://github.com/thoughtbot/high_voltage) for static pages
|
62
|
+
- [Devise](https://github.com/plataformatec/devise) for user authentication
|
63
|
+
- [Pundit](https://github.com/elabs/pundit) for user authorization
|
64
|
+
- [Paperclip](https://github.com/thoughtbot/paperclip) for file attachment and S3 upload.
|
65
|
+
- [Bootstrap](https://github.com/twbs/bootstrap-sass) to jump start the design with a solid responsive grid and basic UI components.
|
66
|
+
- [Font Awesome](https://github.com/FortAwesome/font-awesome-sass) to get a nice iconography
|
67
|
+
|
68
|
+
And development gems like:
|
69
|
+
|
70
|
+
- [Pry Rails](https://github.com/rweng/pry-rails) for interactively exploring objects
|
71
|
+
- [Pry ByeBug](https://github.com/deivid-rodriguez/pry-byebug) for interactively debugging behavior
|
72
|
+
- [Better Errors](https://github.com/charliesome/better_errors) for a great error page with remote debugging
|
73
|
+
- [Letter Opener](https://github.com/ryanb/letter_opener) for testing emails in `development`.
|
74
|
+
|
75
|
+
And production gems for a ready-to-deploy app on Heroku.
|
76
|
+
|
77
|
+
- [Rails 12factor](https://github.com/heroku/rails_12factor/) for injecting the required Rails configuration
|
78
|
+
- [Puma](https://github.com/puma/puma) for a blazing fast HTTP server in production ([recommended by Heroku](https://devcenter.heroku.com/articles/deploying-rails-applications-with-the-puma-web-server))
|
79
|
+
|
80
|
+
WagonRails, when the `--skip-heroku` flag is **not** used, will
|
81
|
+
add a `deploy` script to the `bin` repository. Simply deploy with:
|
82
|
+
|
83
|
+
```
|
84
|
+
$ deploy # git push heroku + rake db:migrate + restart
|
85
|
+
```
|
86
|
+
|
87
|
+
## Credits
|
88
|
+
|
89
|
+
WagonRails is a fork of [thoughtbot/suspenders](https://github.com/thoughtbot/suspenders),
|
90
|
+
which is maintained and funded by [thoughtbot, inc](http://thoughtbot.com/community).
|
91
|
+
|
92
|
+
Thank you guys for creating this gem in the first place!
|
data/Rakefile
ADDED
data/bin/rake
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
#
|
3
|
+
# This file was generated by Bundler.
|
4
|
+
#
|
5
|
+
# The application 'rake' is installed as part of a gem, and
|
6
|
+
# this file is here to facilitate running it.
|
7
|
+
#
|
8
|
+
|
9
|
+
require 'pathname'
|
10
|
+
ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile",
|
11
|
+
Pathname.new(__FILE__).realpath)
|
12
|
+
|
13
|
+
require 'rubygems'
|
14
|
+
require 'bundler/setup'
|
15
|
+
|
16
|
+
load Gem.bin_path('rake', 'rake')
|
data/bin/rspec
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
#
|
3
|
+
# This file was generated by Bundler.
|
4
|
+
#
|
5
|
+
# The application 'rspec' is installed as part of a gem, and
|
6
|
+
# this file is here to facilitate running it.
|
7
|
+
#
|
8
|
+
|
9
|
+
require 'pathname'
|
10
|
+
ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile",
|
11
|
+
Pathname.new(__FILE__).realpath)
|
12
|
+
|
13
|
+
require 'rubygems'
|
14
|
+
require 'bundler/setup'
|
15
|
+
|
16
|
+
load Gem.bin_path('rspec-core', 'rspec')
|
data/bin/wagon_rails
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require 'pathname'
|
3
|
+
|
4
|
+
source_path = (Pathname.new(__FILE__).dirname + '../lib').expand_path
|
5
|
+
$LOAD_PATH << source_path
|
6
|
+
|
7
|
+
require 'wagon_rails'
|
8
|
+
|
9
|
+
if ARGV.first == 'new'
|
10
|
+
ARGV.shift
|
11
|
+
end
|
12
|
+
|
13
|
+
templates_root = File.expand_path(File.join("..", "templates"), File.dirname(__FILE__))
|
14
|
+
WagonRails::AppGenerator.source_root templates_root
|
15
|
+
WagonRails::AppGenerator.source_paths << Rails::Generators::AppGenerator.source_root << templates_root
|
16
|
+
|
17
|
+
WagonRails::AppGenerator.start
|
@@ -0,0 +1,25 @@
|
|
1
|
+
module WagonRails
|
2
|
+
module Actions
|
3
|
+
def replace_in_file(relative_path, find, replace)
|
4
|
+
path = File.join(destination_root, relative_path)
|
5
|
+
contents = IO.read(path)
|
6
|
+
unless contents.gsub!(find, replace)
|
7
|
+
raise "#{find.inspect} not found in #{relative_path}"
|
8
|
+
end
|
9
|
+
File.open(path, "w") { |file| file.write(contents) }
|
10
|
+
end
|
11
|
+
|
12
|
+
def action_mailer_host(rails_env, host)
|
13
|
+
config = "config.action_mailer.default_url_options = { host: #{host} }"
|
14
|
+
configure_environment(rails_env, config)
|
15
|
+
end
|
16
|
+
|
17
|
+
def configure_environment(rails_env, config)
|
18
|
+
inject_into_file(
|
19
|
+
"config/environments/#{rails_env}.rb",
|
20
|
+
"\n\n #{config}",
|
21
|
+
before: "\nend"
|
22
|
+
)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,342 @@
|
|
1
|
+
module WagonRails
|
2
|
+
class AppBuilder < Rails::AppBuilder
|
3
|
+
include WagonRails::Actions
|
4
|
+
|
5
|
+
def readme
|
6
|
+
template 'README.md.erb', 'README.md'
|
7
|
+
end
|
8
|
+
|
9
|
+
def raise_on_delivery_errors
|
10
|
+
%w(development production).each do |environment|
|
11
|
+
replace_in_file "config/environments/#{environment}.rb",
|
12
|
+
'raise_delivery_errors = false', 'raise_delivery_errors = true'
|
13
|
+
config = "config.action_mailer.raise_delivery_errors = true"
|
14
|
+
uncomment_lines("config/environments/#{environment}.rb", config)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
def set_development_delivery_method
|
19
|
+
inject_into_file(
|
20
|
+
"config/environments/development.rb",
|
21
|
+
"\n config.action_mailer.delivery_method = :letter_opener",
|
22
|
+
after: "config.action_mailer.raise_delivery_errors = true",
|
23
|
+
)
|
24
|
+
end
|
25
|
+
|
26
|
+
def raise_on_unpermitted_parameters
|
27
|
+
config = <<-RUBY
|
28
|
+
config.action_controller.action_on_unpermitted_parameters = :raise
|
29
|
+
RUBY
|
30
|
+
|
31
|
+
inject_into_class "config/application.rb", "Application", config
|
32
|
+
end
|
33
|
+
|
34
|
+
def configure_generators
|
35
|
+
config = <<-RUBY
|
36
|
+
|
37
|
+
config.generators do |generate|
|
38
|
+
generate.helper true
|
39
|
+
generate.javascript_engine false
|
40
|
+
generate.request_specs false
|
41
|
+
generate.routing_specs false
|
42
|
+
generate.stylesheets false
|
43
|
+
# generate.test_framework :rspec
|
44
|
+
generate.view_specs false
|
45
|
+
end
|
46
|
+
|
47
|
+
RUBY
|
48
|
+
|
49
|
+
inject_into_class 'config/application.rb', 'Application', config
|
50
|
+
end
|
51
|
+
|
52
|
+
def configure_smtp
|
53
|
+
copy_file 'smtp.rb', 'config/smtp.rb'
|
54
|
+
|
55
|
+
prepend_file 'config/environments/production.rb',
|
56
|
+
%{require Rails.root.join("config/smtp")\n}
|
57
|
+
|
58
|
+
config = <<-RUBY
|
59
|
+
|
60
|
+
config.action_mailer.delivery_method = :smtp
|
61
|
+
RUBY
|
62
|
+
|
63
|
+
inject_into_file 'config/environments/production.rb', config,
|
64
|
+
:after => 'config.action_mailer.raise_delivery_errors = true'
|
65
|
+
end
|
66
|
+
|
67
|
+
def enable_rack_deflater
|
68
|
+
config = <<-RUBY
|
69
|
+
|
70
|
+
# Enable deflate / gzip compression of controller-generated responses
|
71
|
+
config.middleware.use Rack::Deflater
|
72
|
+
RUBY
|
73
|
+
|
74
|
+
inject_into_file(
|
75
|
+
"config/environments/production.rb",
|
76
|
+
config,
|
77
|
+
after: serve_static_files_line
|
78
|
+
)
|
79
|
+
end
|
80
|
+
|
81
|
+
def disallow_wrapping_parameters
|
82
|
+
remove_file "config/initializers/wrap_parameters.rb"
|
83
|
+
end
|
84
|
+
|
85
|
+
def create_partials_directory
|
86
|
+
empty_directory 'app/views/shared'
|
87
|
+
end
|
88
|
+
|
89
|
+
def create_shared_flashes
|
90
|
+
copy_file '_flashes.html.erb', 'app/views/shared/_flashes.html.erb'
|
91
|
+
end
|
92
|
+
|
93
|
+
def create_application_layout
|
94
|
+
template 'wagon_rails_layout.html.erb.erb',
|
95
|
+
'app/views/layouts/application.html.erb',
|
96
|
+
force: true
|
97
|
+
end
|
98
|
+
|
99
|
+
def use_postgres_config_template
|
100
|
+
template 'postgresql_database.yml.erb', 'config/database.yml',
|
101
|
+
force: true
|
102
|
+
end
|
103
|
+
|
104
|
+
def create_database
|
105
|
+
bundle_command 'exec rake db:create db:migrate'
|
106
|
+
end
|
107
|
+
|
108
|
+
def replace_gemfile
|
109
|
+
remove_file 'Gemfile'
|
110
|
+
template 'Gemfile.erb', 'Gemfile'
|
111
|
+
end
|
112
|
+
|
113
|
+
def set_ruby_to_version_being_used
|
114
|
+
create_file '.ruby-version', "#{WagonRails::RUBY_VERSION}\n"
|
115
|
+
end
|
116
|
+
|
117
|
+
def enable_database_cleaner
|
118
|
+
copy_file 'database_cleaner_rspec.rb', 'spec/support/database_cleaner.rb'
|
119
|
+
end
|
120
|
+
|
121
|
+
def configure_i18n_for_missing_translations
|
122
|
+
raise_on_missing_translations_in("development")
|
123
|
+
raise_on_missing_translations_in("test")
|
124
|
+
end
|
125
|
+
|
126
|
+
def configure_rack_timeout
|
127
|
+
copy_file 'rack_timeout.rb', 'config/initializers/rack_timeout.rb'
|
128
|
+
end
|
129
|
+
|
130
|
+
def configure_simple_form
|
131
|
+
bundle_command "exec rails generate simple_form:install --bootstrap"
|
132
|
+
end
|
133
|
+
|
134
|
+
def configure_action_mailer
|
135
|
+
action_mailer_host "development", %{"localhost:#{port}"}
|
136
|
+
action_mailer_host "production", %{ENV.fetch("HOST")}
|
137
|
+
end
|
138
|
+
|
139
|
+
def fix_i18n_deprecation_warning
|
140
|
+
config = <<-RUBY
|
141
|
+
config.i18n.enforce_available_locales = true
|
142
|
+
RUBY
|
143
|
+
|
144
|
+
inject_into_class 'config/application.rb', 'Application', config
|
145
|
+
end
|
146
|
+
|
147
|
+
def configure_puma
|
148
|
+
copy_file 'puma.rb', 'config/puma.rb'
|
149
|
+
end
|
150
|
+
|
151
|
+
def setup_foreman
|
152
|
+
copy_file 'Procfile', 'Procfile'
|
153
|
+
end
|
154
|
+
|
155
|
+
def setup_figaro
|
156
|
+
run 'touch config/application.yml'
|
157
|
+
end
|
158
|
+
|
159
|
+
def copy_application_yml
|
160
|
+
copy_file 'application.yml', 'config/application.yml'
|
161
|
+
end
|
162
|
+
|
163
|
+
def setup_paperclip
|
164
|
+
copy_file 'paperclip.rb', 'config/initializers/paperclip.rb'
|
165
|
+
end
|
166
|
+
|
167
|
+
def setup_stylesheets
|
168
|
+
remove_file 'app/assets/stylesheets/application.css'
|
169
|
+
run 'rm -r app/assets/stylesheets'
|
170
|
+
run 'curl -L https://github.com/lewagon/rails-stylesheets/archive/master.zip > stylesheets.zip'
|
171
|
+
run 'unzip stylesheets.zip -d app/assets && rm stylesheets.zip && mv app/assets/rails-stylesheets-master app/assets/stylesheets'
|
172
|
+
end
|
173
|
+
|
174
|
+
def setup_javascripts
|
175
|
+
remove_file 'app/assets/javascripts/application.js'
|
176
|
+
copy_file 'application.js', 'app/assets/javascripts/application.js'
|
177
|
+
run 'mkdir app/assets/javascripts/app'
|
178
|
+
run 'touch app/assets/javascripts/app/.keep'
|
179
|
+
end
|
180
|
+
|
181
|
+
def gitignore_files
|
182
|
+
remove_file '.gitignore'
|
183
|
+
copy_file 'wagon_rails_gitignore', '.gitignore'
|
184
|
+
# [
|
185
|
+
# 'app/views/shared'
|
186
|
+
# ].each do |dir|
|
187
|
+
# run "mkdir #{dir}"
|
188
|
+
# run "touch #{dir}/.keep"
|
189
|
+
# end
|
190
|
+
end
|
191
|
+
|
192
|
+
def init_git
|
193
|
+
run 'git init'
|
194
|
+
end
|
195
|
+
|
196
|
+
def commit(message)
|
197
|
+
run "git add ."
|
198
|
+
run "git commit -m '#{message}'"
|
199
|
+
end
|
200
|
+
|
201
|
+
def create_heroku_app
|
202
|
+
region = "eu" # or 'us'
|
203
|
+
run_heroku "create #{heroku_app_name} --region #{region}"
|
204
|
+
end
|
205
|
+
|
206
|
+
def set_heroku_remote
|
207
|
+
run "git remote add heroku git@heroku.com:#{heroku_app_name}.git"
|
208
|
+
end
|
209
|
+
|
210
|
+
def add_host_to_application_yml
|
211
|
+
host = <<-EOF
|
212
|
+
production:
|
213
|
+
HOST: https://<%= #{heroku_app_name} %>.herokuapp.com
|
214
|
+
EOF
|
215
|
+
end
|
216
|
+
|
217
|
+
def push_env_to_heroku
|
218
|
+
run "figaro heroku:set -e production"
|
219
|
+
end
|
220
|
+
|
221
|
+
def provide_deploy_script
|
222
|
+
copy_file "bin_deploy", "bin/deploy"
|
223
|
+
|
224
|
+
instructions = <<-MARKDOWN
|
225
|
+
|
226
|
+
## Deploying
|
227
|
+
|
228
|
+
$ bin/deploy
|
229
|
+
MARKDOWN
|
230
|
+
|
231
|
+
append_file "README.md", instructions
|
232
|
+
run "chmod u+x bin/deploy"
|
233
|
+
end
|
234
|
+
|
235
|
+
def create_github_repo
|
236
|
+
path_addition = override_path_for_tests
|
237
|
+
run "#{path_addition} hub create"
|
238
|
+
end
|
239
|
+
|
240
|
+
def copy_miscellaneous_files
|
241
|
+
copy_file "errors.rb", "config/initializers/errors.rb"
|
242
|
+
copy_file "json_encoding.rb", "config/initializers/json_encoding.rb"
|
243
|
+
end
|
244
|
+
|
245
|
+
def customize_error_pages
|
246
|
+
meta_tags =<<-EOS
|
247
|
+
<meta charset="utf-8" />
|
248
|
+
<meta name="ROBOTS" content="NOODP" />
|
249
|
+
<meta name="viewport" content="initial-scale=1" />
|
250
|
+
EOS
|
251
|
+
|
252
|
+
%w(500 404 422).each do |page|
|
253
|
+
inject_into_file "public/#{page}.html", meta_tags, :after => "<head>\n"
|
254
|
+
replace_in_file "public/#{page}.html", /<!--.+-->\n/, ''
|
255
|
+
end
|
256
|
+
end
|
257
|
+
|
258
|
+
def remove_routes_comment_lines
|
259
|
+
replace_in_file 'config/routes.rb',
|
260
|
+
/Rails\.application\.routes\.draw do.*end/m,
|
261
|
+
"Rails.application.routes.draw do\nend"
|
262
|
+
end
|
263
|
+
|
264
|
+
def copy_home
|
265
|
+
copy_file 'wagon_rails_home.html.erb', 'app/views/pages/home.html.erb'
|
266
|
+
end
|
267
|
+
|
268
|
+
def configure_high_voltage
|
269
|
+
copy_file 'high_voltage.rb', 'config/initializers/high_voltage.rb'
|
270
|
+
end
|
271
|
+
|
272
|
+
def disable_xml_params
|
273
|
+
copy_file 'disable_xml_params.rb', 'config/initializers/disable_xml_params.rb'
|
274
|
+
end
|
275
|
+
|
276
|
+
def generate_devise
|
277
|
+
generate 'devise:install'
|
278
|
+
end
|
279
|
+
|
280
|
+
def generate_user
|
281
|
+
generate 'devise User'
|
282
|
+
end
|
283
|
+
|
284
|
+
def generate_pundit
|
285
|
+
generate 'pundit:install'
|
286
|
+
end
|
287
|
+
|
288
|
+
def install_navbar
|
289
|
+
run 'curl https://raw.githubusercontent.com/lewagon/awesome-navbars/master/templates/_navbar_with_login.html.erb > app/views/shared/_navbar.html.erb'
|
290
|
+
run 'curl http://lorempixel.com/200/50/abstract/ > app/assets/images/logo.jpg'
|
291
|
+
end
|
292
|
+
|
293
|
+
def generate_devise_views
|
294
|
+
generate 'devise:views:i18n_templates'
|
295
|
+
remove_file 'app/views/devise/registrations/new.html.erb'
|
296
|
+
copy_file 'devise_registrations_new.html.erb', 'app/views/devise/registrations/new.html.erb'
|
297
|
+
remove_file 'app/views/devise/sessions/new.html.erb'
|
298
|
+
copy_file 'devise_sessions_new.html.erb', 'app/views/devise/sessions/new.html.erb'
|
299
|
+
end
|
300
|
+
|
301
|
+
def setup_application_controller
|
302
|
+
remove_file 'app/controllers/application_controller.rb'
|
303
|
+
copy_file 'application_controller.rb', 'app/controllers/application_controller.rb'
|
304
|
+
end
|
305
|
+
|
306
|
+
private
|
307
|
+
|
308
|
+
def raise_on_missing_translations_in(environment)
|
309
|
+
config = 'config.action_view.raise_on_missing_translations = true'
|
310
|
+
|
311
|
+
uncomment_lines("config/environments/#{environment}.rb", config)
|
312
|
+
end
|
313
|
+
|
314
|
+
def override_path_for_tests
|
315
|
+
if ENV['TESTING']
|
316
|
+
support_bin = File.expand_path(File.join('..', '..', 'spec', 'fakes', 'bin'))
|
317
|
+
"PATH=#{support_bin}:$PATH"
|
318
|
+
end
|
319
|
+
end
|
320
|
+
|
321
|
+
def run_heroku(command)
|
322
|
+
path_addition = override_path_for_tests
|
323
|
+
run "#{path_addition} heroku #{command}"
|
324
|
+
end
|
325
|
+
|
326
|
+
def heroku_app_name
|
327
|
+
"#{app_name}-production"
|
328
|
+
end
|
329
|
+
|
330
|
+
def generate_secret
|
331
|
+
SecureRandom.hex(64)
|
332
|
+
end
|
333
|
+
|
334
|
+
def port
|
335
|
+
@port ||= 3000
|
336
|
+
end
|
337
|
+
|
338
|
+
def serve_static_files_line
|
339
|
+
"config.serve_static_files = ENV['RAILS_SERVE_STATIC_FILES'].present?\n"
|
340
|
+
end
|
341
|
+
end
|
342
|
+
end
|