initiate 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +5 -0
- data/.ruby-version +1 -0
- data/.travis.yml +11 -0
- data/CONTRIBUTING.md +48 -0
- data/Gemfile +3 -0
- data/LICENSE +21 -0
- data/NEWS.md +444 -0
- data/README.md +129 -0
- data/Rakefile +8 -0
- data/bin/initiate +18 -0
- data/bin/rake +16 -0
- data/bin/rspec +16 -0
- data/bin/setup +13 -0
- data/lib/initiate.rb +6 -0
- data/lib/initiate/actions.rb +33 -0
- data/lib/initiate/app_builder.rb +341 -0
- data/lib/initiate/config.rb +9 -0
- data/lib/initiate/generators/app_generator.rb +174 -0
- data/lib/initiate/version.rb +5 -0
- data/spec/features/new_project_spec.rb +131 -0
- data/spec/spec_helper.rb +14 -0
- data/spec/support/initiate.rb +51 -0
- data/suspenders.gemspec +35 -0
- data/templates/Gemfile.erb +53 -0
- data/templates/Procfile +2 -0
- data/templates/README.md.erb +18 -0
- data/templates/_flashes.html.erb +7 -0
- data/templates/_javascript.html.erb +6 -0
- data/templates/action_mailer.rb +5 -0
- data/templates/annotate.rake +4 -0
- data/templates/application.html.slim.erb +10 -0
- data/templates/application.scss +1 -0
- data/templates/bin_setup.erb +32 -0
- data/templates/browserslist +4 -0
- data/templates/bugsnag.rb +5 -0
- data/templates/bundler_audit.rake +12 -0
- data/templates/capybara_webkit.rb +5 -0
- data/templates/config_i18n_tasks.yml +13 -0
- data/templates/config_locales_en.yml.erb +19 -0
- data/templates/database_cleaner_rspec.rb +21 -0
- data/templates/deploy.rb +95 -0
- data/templates/dev.rake +12 -0
- data/templates/disable_xml_params.rb +1 -0
- data/templates/errors.rb +34 -0
- data/templates/factories.rb +2 -0
- data/templates/factory_girl_rspec.rb +3 -0
- data/templates/flashes_helper.rb +5 -0
- data/templates/i18n.rb +3 -0
- data/templates/json_encoding.rb +1 -0
- data/templates/postgresql_database.yml.erb +23 -0
- data/templates/rails_helper.rb +22 -0
- data/templates/sample.env +9 -0
- data/templates/secrets.yml +15 -0
- data/templates/shoulda_matchers_config_rspec.rb +6 -0
- data/templates/smtp.rb +9 -0
- data/templates/spec_helper.rb +23 -0
- data/templates/staging.rb +9 -0
- data/templates/suspenders_gitignore +13 -0
- metadata +167 -0
data/README.md
ADDED
@@ -0,0 +1,129 @@
|
|
1
|
+
# Initiate [](https://travis-ci.org/infinum/initiate)
|
2
|
+
|
3
|
+
Initiate is the base Rails application used at
|
4
|
+
[Infinum](https://infinum.co). It's a fork of [Suspenders](https://github.com/thoughtbot/suspenders) by [Thoughtbot](thoughtbot.com). Thnx Thoughtbot!
|
5
|
+
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
First install the initiate gem:
|
10
|
+
|
11
|
+
gem install initiate
|
12
|
+
|
13
|
+
Then run:
|
14
|
+
|
15
|
+
initiate projectname
|
16
|
+
|
17
|
+
This will create a Rails app in `projectname` using the latest version of Rails.
|
18
|
+
|
19
|
+
## Gemfile
|
20
|
+
|
21
|
+
To see the latest and greatest gems, look at Initiate'
|
22
|
+
[Gemfile](templates/Gemfile.erb), which will be appended to the default
|
23
|
+
generated projectname/Gemfile.
|
24
|
+
|
25
|
+
It includes application gems like:
|
26
|
+
|
27
|
+
* [Bugsnag](https://github.com/bugsnag/bugsnag-ruby) for exception notification
|
28
|
+
* [Delayed Job](https://github.com/collectiveidea/delayed_job) for background
|
29
|
+
processing
|
30
|
+
* [Flutie](https://github.com/thoughtbot/flutie) for `page_title` and `body_class` view
|
31
|
+
helpers
|
32
|
+
* [Postgres](https://github.com/ged/ruby-pg) for access to the Postgres database
|
33
|
+
* [Recipient Interceptor](https://github.com/croaky/recipient_interceptor) to
|
34
|
+
avoid accidentally sending emails to real people from staging
|
35
|
+
* [Simple Form](https://github.com/plataformatec/simple_form) for form markup
|
36
|
+
and style
|
37
|
+
* [Title](https://github.com/calebthompson/title) for storing titles in
|
38
|
+
translations
|
39
|
+
|
40
|
+
And development gems like:
|
41
|
+
|
42
|
+
* [Dotenv](https://github.com/bkeepers/dotenv) for loading environment variables
|
43
|
+
* [Pry Rails](https://github.com/rweng/pry-rails) for interactively exploring
|
44
|
+
objects
|
45
|
+
* [ByeBug](https://github.com/deivid-rodriguez/byebug) for interactively
|
46
|
+
debugging behavior
|
47
|
+
* [Bundler Audit](https://github.com/rubysec/bundler-audit) for scanning the
|
48
|
+
Gemfile for insecure dependencies based on published CVEs
|
49
|
+
* [Spring](https://github.com/rails/spring) for fast Rails actions via
|
50
|
+
pre-loading
|
51
|
+
* [Better errors](https://github.com/charliesome/better_errors) for better debugging via
|
52
|
+
in-browser IRB consoles.
|
53
|
+
* [Quiet Assets](https://github.com/evrone/quiet_assets) for muting assets
|
54
|
+
pipeline log messages
|
55
|
+
|
56
|
+
And testing gems like:
|
57
|
+
|
58
|
+
* [Capybara](https://github.com/jnicklas/capybara) and
|
59
|
+
[Capybara Webkit](https://github.com/thoughtbot/capybara-webkit) for
|
60
|
+
integration testing
|
61
|
+
* [Factory Girl](https://github.com/thoughtbot/factory_girl) for test data
|
62
|
+
* [Formulaic](https://github.com/thoughtbot/formulaic) for integration testing
|
63
|
+
HTML forms
|
64
|
+
* [RSpec](https://github.com/rspec/rspec) for unit testing
|
65
|
+
* [RSpec Mocks](https://github.com/rspec/rspec-mocks) for stubbing and spying
|
66
|
+
* [Shoulda Matchers](https://github.com/thoughtbot/shoulda-matchers) for common
|
67
|
+
RSpec matchers
|
68
|
+
* [Timecop](https://github.com/jtrupiano/timecop-console) for testing time
|
69
|
+
|
70
|
+
## Other goodies
|
71
|
+
|
72
|
+
Initiate also comes with:
|
73
|
+
|
74
|
+
* The [`./bin/setup`][setup] convention for new developer setup
|
75
|
+
* Rails' flashes set up and in application layout
|
76
|
+
* A few nice time formats set up for localization
|
77
|
+
* `Rack::Deflater` to [compress responses with Gzip][compress]
|
78
|
+
* [Safe binstubs][binstub]
|
79
|
+
* [t() and l() in specs without prefixing with I18n][i18n]
|
80
|
+
* An automatically-created `SECRET_KEY_BASE` environment variable in all
|
81
|
+
environments
|
82
|
+
|
83
|
+
## Spring
|
84
|
+
|
85
|
+
Initiate uses [spring](https://github.com/rails/spring) by default.
|
86
|
+
It makes Rails applications load faster, but it might introduce confusing issues
|
87
|
+
around stale code not being refreshed.
|
88
|
+
If you think your application is running old code, run `spring stop`.
|
89
|
+
And if you'd rather not use spring, add `DISABLE_SPRING=1` to your login file.
|
90
|
+
|
91
|
+
## Dependencies
|
92
|
+
|
93
|
+
Initiate requires the latest version of Ruby.
|
94
|
+
|
95
|
+
Some gems included in Initiate have native extensions. You should have GCC
|
96
|
+
installed on your machine before generating an app with Initiate.
|
97
|
+
|
98
|
+
Use [OS X GCC Installer](https://github.com/kennethreitz/osx-gcc-installer/) for
|
99
|
+
Snow Leopard (OS X 10.6).
|
100
|
+
|
101
|
+
Use [Command Line Tools for XCode](https://developer.apple.com/downloads/index.action)
|
102
|
+
for Lion (OS X 10.7) or Mountain Lion (OS X 10.8).
|
103
|
+
|
104
|
+
We use [Capybara Webkit](https://github.com/thoughtbot/capybara-webkit) for
|
105
|
+
full-stack JavaScript integration testing. It requires QT. Instructions for
|
106
|
+
installing QT are
|
107
|
+
[here](https://github.com/thoughtbot/capybara-webkit/wiki/Installing-Qt-and-compiling-capybara-webkit).
|
108
|
+
|
109
|
+
PostgreSQL needs to be installed and running for the `db:create` rake task.
|
110
|
+
|
111
|
+
## Issues
|
112
|
+
|
113
|
+
If you have problems, please create a
|
114
|
+
[GitHub Issue](https://github.com/infinum/initiate/issues).
|
115
|
+
|
116
|
+
## Contributing
|
117
|
+
|
118
|
+
See [CONTRIBUTING.md](CONTRIBUTING.md).
|
119
|
+
|
120
|
+
Thank you, [contributors]!
|
121
|
+
|
122
|
+
[contributors]: https://github.com/infinum/initiate/graphs/contributors
|
123
|
+
|
124
|
+
## License
|
125
|
+
|
126
|
+
Initiate is Copyright © 2015 Infinum.
|
127
|
+
It is free software, and may be redistributed under the terms specified in the [LICENSE] file.
|
128
|
+
|
129
|
+
[LICENSE]: LICENSE
|
data/Rakefile
ADDED
data/bin/initiate
ADDED
@@ -0,0 +1,18 @@
|
|
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 'initiate'
|
8
|
+
|
9
|
+
if ['-v', '--version'].include? ARGV[0]
|
10
|
+
puts Initiate::VERSION
|
11
|
+
exit 0
|
12
|
+
end
|
13
|
+
|
14
|
+
templates_root = File.expand_path(File.join("..", "templates"), File.dirname(__FILE__))
|
15
|
+
Initiate::AppGenerator.source_root templates_root
|
16
|
+
Initiate::AppGenerator.source_paths << Rails::Generators::AppGenerator.source_root << templates_root
|
17
|
+
|
18
|
+
Initiate::AppGenerator.start
|
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/setup
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
#!/usr/bin/env sh
|
2
|
+
|
3
|
+
# Run this script immediately after cloning the codebase.
|
4
|
+
|
5
|
+
# Exit if any subcommand fails
|
6
|
+
set -e
|
7
|
+
|
8
|
+
# Set up Ruby dependencies via Bundler
|
9
|
+
bundle install
|
10
|
+
|
11
|
+
# Add binstubs to PATH in ~/.zshenv like this:
|
12
|
+
# export PATH=".git/safe/../../bin:$PATH"
|
13
|
+
mkdir -p .git/safe
|
data/lib/initiate.rb
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
module Initiate
|
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_application_file(config)
|
18
|
+
inject_into_file(
|
19
|
+
"config/application.rb",
|
20
|
+
"\n\n #{config}",
|
21
|
+
before: "\n end"
|
22
|
+
)
|
23
|
+
end
|
24
|
+
|
25
|
+
def configure_environment(rails_env, config)
|
26
|
+
inject_into_file(
|
27
|
+
"config/environments/#{rails_env}.rb",
|
28
|
+
"\n\n #{config}",
|
29
|
+
before: "\nend"
|
30
|
+
)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,341 @@
|
|
1
|
+
module Initiate
|
2
|
+
class AppBuilder < Rails::AppBuilder
|
3
|
+
include Initiate::Actions
|
4
|
+
|
5
|
+
def readme
|
6
|
+
template 'README.md.erb', 'README.md'
|
7
|
+
end
|
8
|
+
|
9
|
+
def generate_bugsnag
|
10
|
+
copy_file 'bugsnag.rb', 'config/initializers/bugsnag.rb'
|
11
|
+
end
|
12
|
+
|
13
|
+
def setup_development_mailer
|
14
|
+
replace_in_file 'config/environments/development.rb',
|
15
|
+
' config.action_mailer.raise_delivery_errors = false', mailer_configuration
|
16
|
+
end
|
17
|
+
|
18
|
+
def mailer_configuration
|
19
|
+
<<-RUBY
|
20
|
+
config.action_mailer.raise_delivery_errors = true
|
21
|
+
config.action_mailer.default_url_options = { host: 'localhost', port: 3000 }
|
22
|
+
config.action_mailer.delivery_method = :letter_opener
|
23
|
+
config.action_mailer.preview_path = "\#{Rails.root}/lib/mailer_previews"
|
24
|
+
RUBY
|
25
|
+
end
|
26
|
+
|
27
|
+
def raise_on_unpermitted_parameters
|
28
|
+
config = <<-RUBY
|
29
|
+
config.action_controller.action_on_unpermitted_parameters = :raise
|
30
|
+
RUBY
|
31
|
+
|
32
|
+
inject_into_class "config/application.rb", "Application", config
|
33
|
+
end
|
34
|
+
|
35
|
+
def configure_quiet_assets
|
36
|
+
config = <<-RUBY
|
37
|
+
config.quiet_assets = true
|
38
|
+
RUBY
|
39
|
+
|
40
|
+
inject_into_class "config/application.rb", "Application", config
|
41
|
+
end
|
42
|
+
|
43
|
+
def provide_setup_script
|
44
|
+
template "bin_setup.erb", "bin/setup", force: true
|
45
|
+
run "chmod a+x bin/setup"
|
46
|
+
end
|
47
|
+
|
48
|
+
def provide_dev_prime_task
|
49
|
+
copy_file 'dev.rake', 'lib/tasks/dev.rake'
|
50
|
+
end
|
51
|
+
|
52
|
+
def configure_generators
|
53
|
+
config = <<-RUBY
|
54
|
+
|
55
|
+
config.generators do |generate|
|
56
|
+
generate.helper false
|
57
|
+
generate.javascript_engine false
|
58
|
+
generate.request_specs false
|
59
|
+
generate.routing_specs false
|
60
|
+
generate.stylesheets false
|
61
|
+
generate.test_framework :rspec
|
62
|
+
generate.view_specs false
|
63
|
+
end
|
64
|
+
|
65
|
+
RUBY
|
66
|
+
|
67
|
+
inject_into_class 'config/application.rb', 'Application', config
|
68
|
+
end
|
69
|
+
|
70
|
+
def set_up_factory_girl_for_rspec
|
71
|
+
copy_file 'factory_girl_rspec.rb', 'spec/support/factory_girl.rb'
|
72
|
+
end
|
73
|
+
|
74
|
+
def generate_factories_file
|
75
|
+
copy_file "factories.rb", "spec/factories.rb"
|
76
|
+
end
|
77
|
+
|
78
|
+
def configure_smtp
|
79
|
+
copy_file 'smtp.rb', 'config/smtp.rb'
|
80
|
+
|
81
|
+
prepend_file 'config/environments/production.rb',
|
82
|
+
%{require Rails.root.join("config/smtp")\n}
|
83
|
+
|
84
|
+
config = <<-RUBY
|
85
|
+
|
86
|
+
config.action_mailer.delivery_method = :smtp
|
87
|
+
config.action_mailer.smtp_settings = SMTP_SETTINGS
|
88
|
+
RUBY
|
89
|
+
|
90
|
+
inject_into_file 'config/environments/production.rb', config,
|
91
|
+
after: "config.action_mailer.raise_delivery_errors = false"
|
92
|
+
end
|
93
|
+
|
94
|
+
def enable_rack_deflater
|
95
|
+
config = <<-RUBY
|
96
|
+
|
97
|
+
# Enable deflate / gzip compression of controller-generated responses
|
98
|
+
config.middleware.use Rack::Deflater
|
99
|
+
RUBY
|
100
|
+
|
101
|
+
inject_into_file(
|
102
|
+
"config/environments/production.rb",
|
103
|
+
config,
|
104
|
+
after: serve_static_files_line
|
105
|
+
)
|
106
|
+
end
|
107
|
+
|
108
|
+
def setup_asset_host
|
109
|
+
replace_in_file 'config/environments/production.rb',
|
110
|
+
"# config.action_controller.asset_host = 'http://assets.example.com'",
|
111
|
+
'config.action_controller.asset_host = ENV.fetch("ASSET_HOST", ENV.fetch("APPLICATION_HOST"))'
|
112
|
+
|
113
|
+
replace_in_file 'config/initializers/assets.rb',
|
114
|
+
"config.assets.version = '1.0'",
|
115
|
+
'config.assets.version = (ENV["ASSETS_VERSION"] || "1.0")'
|
116
|
+
|
117
|
+
inject_into_file(
|
118
|
+
"config/environments/production.rb",
|
119
|
+
' config.static_cache_control = "public, max-age=#{1.year.to_i}"',
|
120
|
+
after: serve_static_files_line
|
121
|
+
)
|
122
|
+
end
|
123
|
+
|
124
|
+
def setup_staging_environment
|
125
|
+
staging_file = 'config/environments/staging.rb'
|
126
|
+
copy_file 'staging.rb', staging_file
|
127
|
+
end
|
128
|
+
|
129
|
+
def setup_secret_token
|
130
|
+
template 'secrets.yml', 'config/secrets.yml', force: true
|
131
|
+
end
|
132
|
+
|
133
|
+
def disallow_wrapping_parameters
|
134
|
+
remove_file "config/initializers/wrap_parameters.rb"
|
135
|
+
end
|
136
|
+
|
137
|
+
def create_partials_directory
|
138
|
+
empty_directory 'app/views/application'
|
139
|
+
end
|
140
|
+
|
141
|
+
def create_shared_flashes
|
142
|
+
copy_file "_flashes.html.erb", "app/views/application/_flashes.html.erb"
|
143
|
+
copy_file "flashes_helper.rb", "app/helpers/flashes_helper.rb"
|
144
|
+
end
|
145
|
+
|
146
|
+
def create_shared_javascripts
|
147
|
+
copy_file '_javascript.html.erb', 'app/views/application/_javascript.html.erb'
|
148
|
+
end
|
149
|
+
|
150
|
+
def create_application_layout
|
151
|
+
remove_file "app/views/layouts/application.html.erb"
|
152
|
+
template 'application.html.slim.erb',
|
153
|
+
'app/views/layouts/application.html.slim'
|
154
|
+
end
|
155
|
+
|
156
|
+
def use_postgres_config_template
|
157
|
+
template 'postgresql_database.yml.erb', 'config/database.yml',
|
158
|
+
force: true
|
159
|
+
end
|
160
|
+
|
161
|
+
def create_database
|
162
|
+
bundle_command 'exec rake db:create db:migrate'
|
163
|
+
end
|
164
|
+
|
165
|
+
def replace_gemfile
|
166
|
+
remove_file 'Gemfile'
|
167
|
+
template 'Gemfile.erb', 'Gemfile'
|
168
|
+
end
|
169
|
+
|
170
|
+
def set_ruby_to_version_being_used
|
171
|
+
create_file '.ruby-version', "#{Initiate::RUBY_VERSION}\n"
|
172
|
+
end
|
173
|
+
|
174
|
+
def enable_database_cleaner
|
175
|
+
copy_file 'database_cleaner_rspec.rb', 'spec/support/database_cleaner.rb'
|
176
|
+
end
|
177
|
+
|
178
|
+
def provide_shoulda_matchers_config
|
179
|
+
copy_file(
|
180
|
+
"shoulda_matchers_config_rspec.rb",
|
181
|
+
"spec/support/shoulda_matchers.rb"
|
182
|
+
)
|
183
|
+
end
|
184
|
+
|
185
|
+
def configure_spec_support_features
|
186
|
+
empty_directory_with_keep_file 'spec/features'
|
187
|
+
empty_directory_with_keep_file 'spec/support/features'
|
188
|
+
end
|
189
|
+
|
190
|
+
def configure_rspec
|
191
|
+
remove_file "spec/rails_helper.rb"
|
192
|
+
remove_file "spec/spec_helper.rb"
|
193
|
+
copy_file "rails_helper.rb", "spec/rails_helper.rb"
|
194
|
+
copy_file "spec_helper.rb", "spec/spec_helper.rb"
|
195
|
+
end
|
196
|
+
|
197
|
+
def configure_i18n_for_test_environment
|
198
|
+
copy_file "i18n.rb", "spec/support/i18n.rb"
|
199
|
+
end
|
200
|
+
|
201
|
+
def configure_i18n_for_missing_translations
|
202
|
+
raise_on_missing_translations_in("development")
|
203
|
+
raise_on_missing_translations_in("test")
|
204
|
+
end
|
205
|
+
|
206
|
+
def configure_i18n_tasks
|
207
|
+
run "cp $(i18n-tasks gem-path)/templates/rspec/i18n_spec.rb spec/"
|
208
|
+
copy_file "config_i18n_tasks.yml", "config/i18n-tasks.yml"
|
209
|
+
end
|
210
|
+
|
211
|
+
def configure_background_jobs_for_rspec
|
212
|
+
run 'rails g delayed_job:active_record'
|
213
|
+
end
|
214
|
+
|
215
|
+
def configure_action_mailer_in_specs
|
216
|
+
copy_file 'action_mailer.rb', 'spec/support/action_mailer.rb'
|
217
|
+
end
|
218
|
+
|
219
|
+
def configure_capybara_webkit
|
220
|
+
copy_file "capybara_webkit.rb", "spec/support/capybara_webkit.rb"
|
221
|
+
end
|
222
|
+
|
223
|
+
def configure_time_formats
|
224
|
+
remove_file "config/locales/en.yml"
|
225
|
+
template "config_locales_en.yml.erb", "config/locales/en.yml"
|
226
|
+
end
|
227
|
+
|
228
|
+
def configure_simple_form
|
229
|
+
bundle_command "exec rails generate simple_form:install"
|
230
|
+
end
|
231
|
+
|
232
|
+
def configure_action_mailer
|
233
|
+
action_mailer_host "development", %{"localhost:3000"}
|
234
|
+
action_mailer_host "test", %{"www.example.com"}
|
235
|
+
action_mailer_host "production", %{ENV.fetch("APPLICATION_HOST")}
|
236
|
+
end
|
237
|
+
|
238
|
+
def configure_active_job
|
239
|
+
configure_application_file(
|
240
|
+
"config.active_job.queue_adapter = :delayed_job"
|
241
|
+
)
|
242
|
+
configure_environment "test", "config.active_job.queue_adapter = :inline"
|
243
|
+
end
|
244
|
+
|
245
|
+
def fix_i18n_deprecation_warning
|
246
|
+
config = <<-RUBY
|
247
|
+
config.i18n.enforce_available_locales = true
|
248
|
+
RUBY
|
249
|
+
|
250
|
+
inject_into_class 'config/application.rb', 'Application', config
|
251
|
+
end
|
252
|
+
|
253
|
+
def generate_rspec
|
254
|
+
generate 'rspec:install'
|
255
|
+
end
|
256
|
+
|
257
|
+
def setup_stylesheets
|
258
|
+
remove_file "app/assets/stylesheets/application.css"
|
259
|
+
copy_file "application.scss",
|
260
|
+
"app/assets/stylesheets/application.scss"
|
261
|
+
end
|
262
|
+
|
263
|
+
def gitignore_files
|
264
|
+
%w(.sass-cache powder public/system dump.rdb logfile .DS_Store).each do |gitignored|
|
265
|
+
append_file ".gitignore", gitignored
|
266
|
+
end
|
267
|
+
end
|
268
|
+
|
269
|
+
def init_git
|
270
|
+
run 'git init'
|
271
|
+
end
|
272
|
+
|
273
|
+
def provide_deploy_script
|
274
|
+
copy_file "deploy.rb", "config/deploy.rb"
|
275
|
+
end
|
276
|
+
|
277
|
+
def setup_bundler_audit
|
278
|
+
copy_file "bundler_audit.rake", "lib/tasks/bundler_audit.rake"
|
279
|
+
append_file "Rakefile", %{\ntask default: "bundler:audit"\n}
|
280
|
+
end
|
281
|
+
|
282
|
+
def setup_annotate
|
283
|
+
copy_file 'annotate.rake', 'lib/tasks/annotate.rake'
|
284
|
+
end
|
285
|
+
|
286
|
+
def setup_spring
|
287
|
+
bundle_command "exec spring binstub --all"
|
288
|
+
end
|
289
|
+
|
290
|
+
def copy_miscellaneous_files
|
291
|
+
copy_file "browserslist", "browserslist"
|
292
|
+
copy_file "errors.rb", "config/initializers/errors.rb"
|
293
|
+
copy_file "json_encoding.rb", "config/initializers/json_encoding.rb"
|
294
|
+
end
|
295
|
+
|
296
|
+
def remove_routes_comment_lines
|
297
|
+
replace_in_file 'config/routes.rb',
|
298
|
+
/Rails\.application\.routes\.draw do.*end/m,
|
299
|
+
"Rails.application.routes.draw do\nend"
|
300
|
+
end
|
301
|
+
|
302
|
+
def disable_xml_params
|
303
|
+
copy_file 'disable_xml_params.rb', 'config/initializers/disable_xml_params.rb'
|
304
|
+
end
|
305
|
+
|
306
|
+
def setup_default_rake_task
|
307
|
+
append_file 'Rakefile' do
|
308
|
+
<<-EOS
|
309
|
+
task(:default).clear
|
310
|
+
task default: [:spec]
|
311
|
+
|
312
|
+
if defined? RSpec
|
313
|
+
task(:spec).clear
|
314
|
+
RSpec::Core::RakeTask.new(:spec) do |t|
|
315
|
+
t.verbose = false
|
316
|
+
end
|
317
|
+
end
|
318
|
+
EOS
|
319
|
+
end
|
320
|
+
end
|
321
|
+
|
322
|
+
private
|
323
|
+
|
324
|
+
def raise_on_missing_translations_in(environment)
|
325
|
+
config = 'config.action_view.raise_on_missing_translations = true'
|
326
|
+
|
327
|
+
uncomment_lines("config/environments/#{environment}.rb", config)
|
328
|
+
end
|
329
|
+
|
330
|
+
def override_path_for_tests
|
331
|
+
if ENV['TESTING']
|
332
|
+
support_bin = File.expand_path(File.join('..', '..', 'spec', 'fakes', 'bin'))
|
333
|
+
"PATH=#{support_bin}:$PATH"
|
334
|
+
end
|
335
|
+
end
|
336
|
+
|
337
|
+
def serve_static_files_line
|
338
|
+
"config.serve_static_files = ENV['RAILS_SERVE_STATIC_FILES'].present?\n"
|
339
|
+
end
|
340
|
+
end
|
341
|
+
end
|