kazan 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 +10 -0
- data/.rspec +2 -0
- data/.ruby-version +1 -0
- data/.travis.yml +8 -0
- data/Gemfile +3 -0
- data/LICENSE +21 -0
- data/README.md +92 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/kazan +30 -0
- data/bin/setup +8 -0
- data/kazan.gemspec +32 -0
- data/lib/kazan/actions.rb +33 -0
- data/lib/kazan/app_builder.rb +308 -0
- data/lib/kazan/generators/app_generator.rb +177 -0
- data/lib/kazan/generators/clockwork_generator.rb +7 -0
- data/lib/kazan/generators/sidekiq_generator.rb +7 -0
- data/lib/kazan/version.rb +5 -0
- data/lib/kazan.rb +5 -0
- data/spec/kazan_spec.rb +21 -0
- data/spec/project_spec.rb +222 -0
- data/spec/spec_helper.rb +7 -0
- data/spec/support/hooks.rb +15 -0
- data/spec/support/kazan_spec_helpers.rb +71 -0
- data/templates/Gemfile.api.erb +53 -0
- data/templates/Gemfile.erb +68 -0
- data/templates/Procfile.erb +1 -0
- data/templates/README.md.erb +16 -0
- data/templates/_flashes.html.erb +7 -0
- data/templates/_javascript.html.erb +12 -0
- data/templates/_styles.html.erb +7 -0
- data/templates/action_mailer.rb +5 -0
- data/templates/application.html.erb +17 -0
- data/templates/application.scss +9 -0
- data/templates/browserslist +3 -0
- data/templates/bullet.rb +6 -0
- data/templates/bundler_audit.rake +12 -0
- data/templates/database.yml.erb +31 -0
- data/templates/database_cleaner.rb +21 -0
- data/templates/envs/.env.development.example +21 -0
- data/templates/envs/.env.production +24 -0
- data/templates/errors.rb +33 -0
- data/templates/factory_girl.rb +3 -0
- data/templates/flashes_helper.rb +5 -0
- data/templates/gitignore +14 -0
- data/templates/i18n.rb +3 -0
- data/templates/json_encoding.rb +2 -0
- data/templates/puma.rb +14 -0
- data/templates/rack_mini_profiler.rb +6 -0
- data/templates/rails_helper.rb +21 -0
- data/templates/rollbar.rb +57 -0
- data/templates/settings.yml.erb +0 -0
- data/templates/shoulda_matchers.rb +6 -0
- data/templates/smtp.rb +14 -0
- data/templates/spec_helper.rb +24 -0
- metadata +164 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 4292499236dbeea2841da32a5083a60cdc3c9a5c
|
4
|
+
data.tar.gz: 52763793ed8cb4b0f325ef07933fb8afbd401a58
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 90081ccd100ca63ec181edcb0f18404f4e0e5835ae3df1d659efdcf936af71056607aa3fcf23604c6391334eff56af7dd68d6b85c2e6c68988a712c889b2dc4f
|
7
|
+
data.tar.gz: e714c8f2473e5324851ce7ad4cb3547b899a0744170a0f2c2ec9e9e8f98cf8fe3e2d80ec04e8e135883f563d304e13cf80614989988feb1d48dcf8a09b2b8adb
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
2.3.1
|
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2016 Marat Khusnetdinov
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,92 @@
|
|
1
|
+
# Kazan [](https://travis-ci.org/khusnetdinov/kazan) [](https://gemnasium.com/github.com/khusnetdinov/kazan) [](https://codeclimate.com/github/khusnetdinov/kazan)
|
2
|
+
|
3
|
+
Kazan creates rails project and setups predefined gems and tools.
|
4
|
+
|
5
|
+

|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Install gem:
|
10
|
+
|
11
|
+
$ gem install kazan
|
12
|
+
|
13
|
+
## Usage
|
14
|
+
|
15
|
+
By default this rails application generator uses PostgreSQL as db and RSpec as test framework. Also it installs and setups a lot usefull gems, and you don't need waste time then you stat new project.
|
16
|
+
|
17
|
+
Just run:
|
18
|
+
|
19
|
+
$ kazan projectname
|
20
|
+
|
21
|
+
This generator maps all flags to rails native generator, for example you can create api application:
|
22
|
+
|
23
|
+
$ kazan projectname --api
|
24
|
+
|
25
|
+
See all gems that will be installed to project in [Gemfile](https://github.com/khusnetdinov/kazan/blob/master/templates/Gemfile.erb) for web application or for api [Gemfile.api](https://github.com/khusnetdinov/kazan/blob/master/templates/Gemfile.api.erb).
|
26
|
+
|
27
|
+
## Options
|
28
|
+
|
29
|
+
- `--static` to use [Bitters](https://github.com/thoughtbot/bitters), [Bourbon](https://github.com/thoughtbot/bourbon), [Neat](https://github.com/thoughtbot/neat), [Refills](https://github.com/thoughtbot/refills).
|
30
|
+
|
31
|
+
## Gems
|
32
|
+
|
33
|
+
It includes applications gems:
|
34
|
+
|
35
|
+
- [Dotenv](https://github.com/bkeepers/dotenv) Shim to load environment variables from .env into ENV in development.
|
36
|
+
- [I18n](https://github.com/svenfuchs/rails-i18n) is central point to collect locale data for use in Ruby on Rails.
|
37
|
+
- [PostgreSQL](https://www.postgresql.org/) database with [PG](https://rubygems.org/gems/pg/versions/0.18.4) adapter is used by defaul.
|
38
|
+
- [Puma](http://puma.io/) is a simple, fast, threaded, and highly concurrent HTTP 1.1 server for Ruby/Rack applications.
|
39
|
+
- [Rack Canonical Host](https://github.com/tylerhunt/rack-canonical-host) is middleware that lets you define a single host name as the canonical host for your application. Requests for other host names will then be redirected to the canonical host.
|
40
|
+
- [Rack Timeout](https://github.com/heroku/rack-timeout) aborts requests that are taking too long; an exception is raised.
|
41
|
+
- [Recepient Interceptor](https://github.com/croaky/recipient_interceptor) never accidentally send emails to real people from your staging environment.
|
42
|
+
- [Rails 5.0.0](http://rubyonrails.org/)
|
43
|
+
- [Rails Config](https://github.com/railsconfig/config) helps you easily manage environment specific settings in an easy and usable manner.
|
44
|
+
- [Rollbar](https://rollbar.com/) error monitoring fits right into your continuous delivery and deployment workflows to provide confidence in every code release.
|
45
|
+
- [Simple From](https://github.com/plataformatec/simple_form) [API EXCLUDED] aims to be as flexible as possible while helping you with powerful components to create your forms.
|
46
|
+
|
47
|
+
It includes assets gems [API EXCLUDED]:
|
48
|
+
|
49
|
+
- [Autoprefixer Rails](https://github.com/ai/autoprefixer-rails) is a tool to parse CSS and add vendor prefixes to CSS rules using values from the [Can I Use](http://caniuse.com/).
|
50
|
+
- [Normalize Css](https://necolas.github.io/normalize.css/) makes browsers render all elements more consistently and in line with modern standards. It precisely targets only the styles that need normalizing.
|
51
|
+
- [Sass](http://sass-lang.com/) is the most mature, stable, and powerful professional grade CSS extension language in the world.
|
52
|
+
|
53
|
+
It includes development gems:
|
54
|
+
|
55
|
+
- [Annotate](https://github.com/ctran/annotate_models) adds a comment summarizing the current schema.
|
56
|
+
- [Awesome Print](https://github.com/awesome-print/awesome_print) prints pretty Ruby objects in full color exposing their internal structure with proper indentation.
|
57
|
+
- [Better Errors](https://github.com/charliesome/better_errors) [API EXCLUDED] replaces the standard Rails error page with a much better and more useful error page.
|
58
|
+
- [ByeBug](https://github.com/deivid-rodriguez/byebug) is a simple to use, feature rich debugger for Ruby 2.
|
59
|
+
- [Bundler Audit](https://github.com/rubysec/bundler-audit) is patch-level verification for bundler.
|
60
|
+
- [Bullet](https://github.com/flyerhzm/bullet) is designed to help you increase your application's performance by reducing the number of queries it makes.
|
61
|
+
- [Foreman](https://github.com/ddollar/foreman) procfile-based applications.
|
62
|
+
- [Letter Opener](https://github.com/ryanb/letter_opener) previews email in the default browser instead of sending it.
|
63
|
+
- [Listen](https://github.com/guard/listen) listens to file modifications and notifies you about the changes.
|
64
|
+
- [Pry](https://github.com/rweng/pry-rails) for interactively exploring objects.
|
65
|
+
- [Rack Mini Profiler](https://github.com/MiniProfiler/rack-mini-profiler) [API EXCLUDED] displays speed badge for every html page.
|
66
|
+
- [Spring](https://github.com/rails/spring) speeds up development by keeping your application running in the background.
|
67
|
+
- [Web Console](https://github.com/rails/web-console) [API EXCLUDED] is a debugging tool for your Ruby on Rails applications.
|
68
|
+
|
69
|
+
It includes tests gems:
|
70
|
+
- [Capybara](https://github.com/jnicklas/capybara) [API EXCLUDED] helps you test web applications by simulating how a real user would interact with your app.
|
71
|
+
- [Database Cleaner](https://github.com/DatabaseCleaner/database_cleaner) is a set of strategies for cleaning your database in Ruby.
|
72
|
+
- [Factory Girl](https://github.com/thoughtbot/factory_girl) is a fixtures replacement with a straightforward definition syntax.
|
73
|
+
- [Faker](https://github.com/stympy/faker) a port of Perl's Data::Faker library that generates fake data.
|
74
|
+
- [Formulaic](https://github.com/thoughtbot/formulaic) [API EXCLUDED] the tedium of formulaic form filling with Capybara.
|
75
|
+
- [Launchy](https://github.com/copiousfreetime/launchy) [API EXCLUDED] helper class for launching cross-platform applications in a fire and forget manner.
|
76
|
+
- [Rspec](https://github.com/rspec/rspec-rails) is a testing framework for Rails.
|
77
|
+
- [Simplecov](https://github.com/colszowka/simplecov) is a code coverage analysis tool for Ruby.
|
78
|
+
- [Shoulda Matchers](https://github.com/thoughtbot/shoulda-matchers) provides RSpec- and Minitest-compatible one-liners that test common Rails functionality.
|
79
|
+
- [Timecop](https://github.com/travisjeffery/timecop) providing "time travel" and "time freezing" capabilities, making it dead simple to test time-dependent code.
|
80
|
+
- [Web Mock](https://github.com/bblimke/webmock) for stubbing and setting expectations on HTTP requests in Ruby.
|
81
|
+
|
82
|
+
## Bonuses
|
83
|
+
|
84
|
+
- t() and l() in specs without prefixing with I18n.
|
85
|
+
- Low database connection pool limit.
|
86
|
+
- Rails' flashes set up and in application layout.
|
87
|
+
- [Rack::Deflater](https://robots.thoughtbot.com/content-compression-with-rack-deflater) to compress responses with Gzip.
|
88
|
+
- [Safe binstubs](https://github.com/thoughtbot/suspenders/pull/282)
|
89
|
+
|
90
|
+
## License
|
91
|
+
|
92
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "kazan"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start
|
data/bin/kazan
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'pathname'
|
4
|
+
|
5
|
+
source_path = (Pathname.new(__FILE__).dirname + '../lib').expand_path
|
6
|
+
$LOAD_PATH << source_path
|
7
|
+
|
8
|
+
require 'kazan'
|
9
|
+
|
10
|
+
if ARGV.empty?
|
11
|
+
puts "Please provide an arguments"
|
12
|
+
puts
|
13
|
+
exit 0
|
14
|
+
elsif ['-v', '--version'].include? ARGV[0]
|
15
|
+
puts Kazan::VERSION
|
16
|
+
exit 0
|
17
|
+
elsif ['ruby'].include?(ARGV[0]) && ['-v', '--version'].include?(ARGV[1])
|
18
|
+
puts Kazan::RUBY_PROJECT_VERSION
|
19
|
+
exit 0
|
20
|
+
elsif ['rails'].include?(ARGV[0]) && ['-v', '--version'].include?(ARGV[1])
|
21
|
+
puts Kazan::RAILS_VERSION
|
22
|
+
exit 0
|
23
|
+
end
|
24
|
+
|
25
|
+
templates_root = File.expand_path(File.join("..", "templates"), File.dirname(__FILE__))
|
26
|
+
Kazan::AppGenerator.source_root templates_root
|
27
|
+
Kazan::AppGenerator.source_paths << Rails::Generators::AppGenerator.source_root << templates_root
|
28
|
+
|
29
|
+
Kazan::AppGenerator.start
|
30
|
+
|
data/bin/setup
ADDED
data/kazan.gemspec
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'kazan/version'
|
5
|
+
require 'date'
|
6
|
+
|
7
|
+
Gem::Specification.new do |spec|
|
8
|
+
spec.version = Kazan::VERSION
|
9
|
+
spec.required_ruby_version = Kazan::RUBY_PROJECT_VERSION
|
10
|
+
|
11
|
+
spec.name = 'kazan'
|
12
|
+
|
13
|
+
spec.authors = ['Marat Khusnetdinov']
|
14
|
+
spec.email = ['marat@khusnetdinov.ru']
|
15
|
+
spec.homepage = 'https://github.com/khusnetdinov/kazan'
|
16
|
+
spec.license = 'MIT'
|
17
|
+
|
18
|
+
spec.summary = %q{Kazan creates rails project and setups predefined gems and tools.}
|
19
|
+
spec.description = %q{Kazan creates rails project and setups predefined gems and tools.}
|
20
|
+
spec.rdoc_options = ['--charset=UTF-8']
|
21
|
+
spec.extra_rdoc_files = %w[README.md LICENSE]
|
22
|
+
|
23
|
+
spec.files = `git ls-files`.split("\n")
|
24
|
+
spec.executables = ['kazan']
|
25
|
+
spec.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
26
|
+
|
27
|
+
spec.add_dependency 'rails', Kazan::RAILS_VERSION
|
28
|
+
spec.add_dependency 'bundler', '~> 1.3'
|
29
|
+
|
30
|
+
spec.add_development_dependency 'rake', '~> 10.0'
|
31
|
+
spec.add_development_dependency 'rspec', '~> 3.5'
|
32
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
module Kazan
|
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 configure_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,308 @@
|
|
1
|
+
module Kazan
|
2
|
+
class AppBuilder < Rails::AppBuilder
|
3
|
+
include Kazan::Actions
|
4
|
+
|
5
|
+
def readme
|
6
|
+
template 'README.md.erb', 'README.md'
|
7
|
+
end
|
8
|
+
|
9
|
+
def gitignore
|
10
|
+
copy_file 'gitignore', '.gitignore'
|
11
|
+
end
|
12
|
+
|
13
|
+
def gemfile
|
14
|
+
template 'Gemfile.erb', 'Gemfile'
|
15
|
+
end
|
16
|
+
|
17
|
+
def gemfile_api
|
18
|
+
template 'Gemfile.api.erb', 'Gemfile', force: true
|
19
|
+
end
|
20
|
+
|
21
|
+
def ruby_version
|
22
|
+
create_file '.ruby-version', "#{Kazan::RUBY_PROJECT_VERSION}\n"
|
23
|
+
end
|
24
|
+
|
25
|
+
def simple_form_config
|
26
|
+
bundle_command 'exec rails generate simple_form:install'
|
27
|
+
end
|
28
|
+
|
29
|
+
def rack_mini_profiler_config
|
30
|
+
copy_file 'rack_mini_profiler.rb', 'config/initializers/rack_mini_profiler.rb'
|
31
|
+
end
|
32
|
+
|
33
|
+
def puma_config
|
34
|
+
copy_file 'puma.rb', 'config/puma.rb', force: true
|
35
|
+
end
|
36
|
+
|
37
|
+
def postgres_config
|
38
|
+
template 'database.yml.erb', 'config/database.yml', force: true
|
39
|
+
template 'database.yml.erb', 'config/database.yml.example'
|
40
|
+
end
|
41
|
+
|
42
|
+
def database_tables
|
43
|
+
bundle_command 'exec rake db:create db:migrate'
|
44
|
+
end
|
45
|
+
|
46
|
+
def shared_views_directory
|
47
|
+
empty_directory 'app/views/layouts/shared'
|
48
|
+
end
|
49
|
+
|
50
|
+
def shared_flash
|
51
|
+
copy_file '_flashes.html.erb', 'app/views/layouts/shared/_flashes.html.erb'
|
52
|
+
copy_file 'flashes_helper.rb', 'app/helpers/flashes_helper.rb'
|
53
|
+
end
|
54
|
+
|
55
|
+
def shared_javascript
|
56
|
+
copy_file '_javascript.html.erb', 'app/views/layouts/shared/_javascript.html.erb'
|
57
|
+
end
|
58
|
+
|
59
|
+
def shared_styles
|
60
|
+
copy_file '_styles.html.erb', 'app/views/layouts/shared/_styles.html.erb'
|
61
|
+
end
|
62
|
+
|
63
|
+
def shared_layout
|
64
|
+
copy_file 'application.html.erb', 'app/views/layouts/application.html.erb', force: true
|
65
|
+
end
|
66
|
+
|
67
|
+
def assets_config
|
68
|
+
copy_file 'browserslist', 'app/assets/stylesheets/browserslist'
|
69
|
+
copy_file 'errors.rb', 'config/initializers/errors.rb'
|
70
|
+
copy_file 'json_encoding.rb', 'config/initializers/json_encoding.rb'
|
71
|
+
end
|
72
|
+
|
73
|
+
def dotenvs
|
74
|
+
directory 'envs', '.'
|
75
|
+
end
|
76
|
+
|
77
|
+
def settings
|
78
|
+
template 'settings.yml.erb', 'config/settings.yml'
|
79
|
+
end
|
80
|
+
|
81
|
+
def exception_on_delivery_errors
|
82
|
+
replace_in_file 'config/environments/development.rb',
|
83
|
+
'raise_delivery_errors = false', 'raise_delivery_errors = true'
|
84
|
+
end
|
85
|
+
|
86
|
+
def exception_on_unpermitted_parameters
|
87
|
+
config = <<-RUBY
|
88
|
+
config.action_controller.action_on_unpermitted_parameters = :raise
|
89
|
+
|
90
|
+
RUBY
|
91
|
+
|
92
|
+
inject_into_class 'config/application.rb', 'Application', config
|
93
|
+
end
|
94
|
+
|
95
|
+
def exception_on_missing_translations
|
96
|
+
exception_on_missing_translations_in 'development'
|
97
|
+
exception_on_missing_translations_in 'test'
|
98
|
+
end
|
99
|
+
|
100
|
+
def letter_opener_config
|
101
|
+
letter_opener_settings = <<-RUBY
|
102
|
+
# Letter opener settings
|
103
|
+
config.action_mailer.default_url_options = { host: 'localhost', port: 3000 }
|
104
|
+
config.action_mailer.delivery_method = :letter_opener
|
105
|
+
RUBY
|
106
|
+
|
107
|
+
configure_environment 'development', letter_opener_settings
|
108
|
+
end
|
109
|
+
|
110
|
+
def bullet_config
|
111
|
+
template 'bullet.rb', 'config/initializers/bullet.rb'
|
112
|
+
end
|
113
|
+
|
114
|
+
def quiet_assets_config
|
115
|
+
config = <<-RUBY
|
116
|
+
config.assets.quiet = true
|
117
|
+
|
118
|
+
RUBY
|
119
|
+
|
120
|
+
inject_into_class 'config/application.rb', 'Application', config
|
121
|
+
end
|
122
|
+
|
123
|
+
def foreman_config
|
124
|
+
template 'Procfile.erb', 'Procfile'
|
125
|
+
end
|
126
|
+
|
127
|
+
def rails_generators_config
|
128
|
+
config = <<-RUBY
|
129
|
+
config.generators do |generate|
|
130
|
+
generate.helper false
|
131
|
+
generate.javascript_engine false
|
132
|
+
generate.request_specs false
|
133
|
+
generate.routing_specs false
|
134
|
+
generate.stylesheets false
|
135
|
+
generate.test_framework :rspec
|
136
|
+
generate.view_specs false
|
137
|
+
end
|
138
|
+
|
139
|
+
RUBY
|
140
|
+
|
141
|
+
inject_into_class 'config/application.rb', 'Application', config
|
142
|
+
end
|
143
|
+
|
144
|
+
def stylesheets_gems
|
145
|
+
gems = <<-RUBY
|
146
|
+
|
147
|
+
gem 'bourbon', '5.0.0.beta.6'
|
148
|
+
gem 'neat', '~> 1.8.0'
|
149
|
+
gem 'refills', group: [:development, :test]
|
150
|
+
RUBY
|
151
|
+
|
152
|
+
inject_into_file 'Gemfile', gems,
|
153
|
+
after: "gem 'sass-rails', '~> 5.0'\n"
|
154
|
+
|
155
|
+
Bundler.with_clean_env { run 'bundle install' }
|
156
|
+
end
|
157
|
+
|
158
|
+
def stylesheets_manifest
|
159
|
+
remove_file 'app/assets/stylesheets/application.css'
|
160
|
+
copy_file(
|
161
|
+
'application.scss',
|
162
|
+
'app/assets/stylesheets/application.scss',
|
163
|
+
force: true,
|
164
|
+
)
|
165
|
+
end
|
166
|
+
|
167
|
+
def refills
|
168
|
+
generate 'refills:import', 'flashes'
|
169
|
+
remove_dir 'app/views/refills'
|
170
|
+
end
|
171
|
+
|
172
|
+
def bitters
|
173
|
+
run 'bitters install --path app/assets/stylesheets'
|
174
|
+
end
|
175
|
+
|
176
|
+
def static_pages
|
177
|
+
meta_tags = <<-EOS
|
178
|
+
<meta charset="utf-8" />
|
179
|
+
<meta name="ROBOTS" content="NOODP" />
|
180
|
+
<meta name="viewport" content="initial-scale=1" />
|
181
|
+
EOS
|
182
|
+
|
183
|
+
%w(500 404 422).each do |page|
|
184
|
+
inject_into_file "public/#{page}.html", meta_tags, after: "<head>\n"
|
185
|
+
replace_in_file "public/#{page}.html", /<!--.+-->\n/, ''
|
186
|
+
end
|
187
|
+
end
|
188
|
+
|
189
|
+
def bundler_audit_config
|
190
|
+
copy_file 'bundler_audit.rake', 'lib/tasks/bundler_audit.rake'
|
191
|
+
append_file 'Rakefile', %{\ntask default: 'bundler:audit'\n}
|
192
|
+
end
|
193
|
+
|
194
|
+
def exception_on_missing_assets_in_test
|
195
|
+
configure_environment 'test', 'config.assets.raise_runtime_errors = true'
|
196
|
+
end
|
197
|
+
|
198
|
+
def spec_translations_config
|
199
|
+
copy_file 'i18n.rb', 'spec/support/i18n.rb'
|
200
|
+
end
|
201
|
+
|
202
|
+
def spec_action_mailer_config
|
203
|
+
copy_file 'action_mailer.rb', 'spec/support/action_mailer.rb'
|
204
|
+
end
|
205
|
+
|
206
|
+
def spec_database_cleaner_config
|
207
|
+
copy_file 'database_cleaner.rb', 'spec/support/database_cleaner.rb'
|
208
|
+
end
|
209
|
+
|
210
|
+
def spec_shoulda_matchers_config
|
211
|
+
copy_file 'shoulda_matchers.rb', 'spec/support/shoulda_matchers.rb'
|
212
|
+
end
|
213
|
+
|
214
|
+
def spec_factory_girl_config
|
215
|
+
copy_file 'factory_girl.rb', 'spec/support/factory_girl.rb'
|
216
|
+
end
|
217
|
+
|
218
|
+
def rspec_config
|
219
|
+
generate 'rspec:install'
|
220
|
+
end
|
221
|
+
|
222
|
+
def rspec_replace_config
|
223
|
+
copy_file 'rails_helper.rb', 'spec/rails_helper.rb', force: true
|
224
|
+
copy_file 'spec_helper.rb', 'spec/spec_helper.rb', force: true
|
225
|
+
end
|
226
|
+
|
227
|
+
def smtp_config
|
228
|
+
copy_file 'smtp.rb', 'config/smtp.rb'
|
229
|
+
|
230
|
+
prepend_file 'config/environments/production.rb',
|
231
|
+
%{require Rails.root.join("config/smtp")\n}
|
232
|
+
|
233
|
+
config = <<-RUBY
|
234
|
+
config.action_mailer.delivery_method = :smtp
|
235
|
+
config.action_mailer.smtp_settings = SMTP_SETTINGS
|
236
|
+
|
237
|
+
RUBY
|
238
|
+
|
239
|
+
inject_into_file 'config/environments/production.rb', config,
|
240
|
+
after: "config.action_mailer.raise_delivery_errors = false"
|
241
|
+
end
|
242
|
+
|
243
|
+
def rack_timeout_config
|
244
|
+
rack_timeout_config = <<-RUBY
|
245
|
+
Rack::Timeout.timeout = (ENV["RACK_TIMEOUT"] || 10).to_i
|
246
|
+
|
247
|
+
RUBY
|
248
|
+
|
249
|
+
append_file 'config/environments/production.rb', rack_timeout_config
|
250
|
+
end
|
251
|
+
|
252
|
+
def rack_canonical_host_config
|
253
|
+
config = <<-RUBY
|
254
|
+
config.middleware.use Rack::CanonicalHost, ENV.fetch("APPLICATION_HOST")
|
255
|
+
RUBY
|
256
|
+
|
257
|
+
inject_into_file "config/environments/production.rb", config,
|
258
|
+
after: "Rails.application.configure do"
|
259
|
+
end
|
260
|
+
|
261
|
+
def rack_deflater_config
|
262
|
+
configure_environment "production", "config.middleware.use Rack::Deflater"
|
263
|
+
end
|
264
|
+
|
265
|
+
def rollbar_config
|
266
|
+
copy_file 'rollbar.rb', 'config/initializers/rollbar.rb'
|
267
|
+
end
|
268
|
+
|
269
|
+
def spring
|
270
|
+
bundle_command 'exec spring binstub --all'
|
271
|
+
end
|
272
|
+
|
273
|
+
def empty_directories
|
274
|
+
[
|
275
|
+
'app/assets/fonts',
|
276
|
+
'app/controllers/api',
|
277
|
+
'app/controllers/web',
|
278
|
+
'app/services',
|
279
|
+
'app/policies',
|
280
|
+
'app/validations',
|
281
|
+
'app/views/shared',
|
282
|
+
'spec/controllers',
|
283
|
+
'spec/factories',
|
284
|
+
'spec/helpers',
|
285
|
+
'spec/models',
|
286
|
+
'spec/mailers',
|
287
|
+
'spec/requests',
|
288
|
+
'spec/routing',
|
289
|
+
].each do |dir|
|
290
|
+
empty_directory_with_keep_file dir
|
291
|
+
end
|
292
|
+
end
|
293
|
+
|
294
|
+
def init_commit
|
295
|
+
run 'git init'
|
296
|
+
run 'git add .'
|
297
|
+
run 'git commit -m "Init commit"'
|
298
|
+
end
|
299
|
+
|
300
|
+
private
|
301
|
+
|
302
|
+
def exception_on_missing_translations_in(environment)
|
303
|
+
config = 'config.action_view.raise_on_missing_translations = true'
|
304
|
+
|
305
|
+
uncomment_lines("config/environments/#{environment}.rb", config)
|
306
|
+
end
|
307
|
+
end
|
308
|
+
end
|