Class: Kazan::AppBuilder
- Inherits:
-
Rails::AppBuilder
- Object
- Rails::AppBuilder
- Kazan::AppBuilder
- Includes:
- Actions
- Defined in:
- lib/kazan/app_builder.rb
Instance Method Summary collapse
- #assets_config ⇒ Object
- #bitters ⇒ Object
- #bullet_config ⇒ Object
- #bundler_audit_config ⇒ Object
- #database_tables ⇒ Object
- #dotenvs ⇒ Object
- #empty_directories ⇒ Object
- #exception_on_delivery_errors ⇒ Object
- #exception_on_missing_assets_in_test ⇒ Object
- #exception_on_missing_translations ⇒ Object
- #exception_on_unpermitted_parameters ⇒ Object
- #foreman_config ⇒ Object
- #gemfile ⇒ Object
- #gemfile_api ⇒ Object
- #gitignore ⇒ Object
- #init_commit ⇒ Object
- #letter_opener_config ⇒ Object
- #postgres_config ⇒ Object
- #puma_config ⇒ Object
- #quiet_assets_config ⇒ Object
- #rack_canonical_host_config ⇒ Object
- #rack_deflater_config ⇒ Object
- #rack_mini_profiler_config ⇒ Object
- #rack_timeout_config ⇒ Object
- #rails_generators_config ⇒ Object
- #readme ⇒ Object
- #refills ⇒ Object
- #remove_turbolinks ⇒ Object
- #rollbar_config ⇒ Object
- #rspec_config ⇒ Object
- #rspec_replace_config ⇒ Object
- #ruby_version ⇒ Object
- #settings ⇒ Object
- #shared_flash ⇒ Object
- #shared_javascript ⇒ Object
- #shared_layout ⇒ Object
- #shared_styles ⇒ Object
- #shared_views_directory ⇒ Object
- #simple_form_config ⇒ Object
- #smtp_config ⇒ Object
- #spec_action_mailer_config ⇒ Object
- #spec_database_cleaner_config ⇒ Object
- #spec_factory_girl_config ⇒ Object
- #spec_shoulda_matchers_config ⇒ Object
- #spec_translations_config ⇒ Object
- #spring ⇒ Object
- #static_pages ⇒ Object
- #stylesheets_gems ⇒ Object
- #stylesheets_manifest ⇒ Object
Methods included from Actions
#configure_action_mailer_host, #configure_application_file, #configure_environment, #replace_in_file
Instance Method Details
#assets_config ⇒ Object
67 68 69 70 71 |
# File 'lib/kazan/app_builder.rb', line 67 def assets_config copy_file 'browserslist', 'app/assets/stylesheets/browserslist' copy_file 'errors.rb', 'config/initializers/errors.rb' copy_file 'json_encoding.rb', 'config/initializers/json_encoding.rb' end |
#bitters ⇒ Object
178 179 180 |
# File 'lib/kazan/app_builder.rb', line 178 def bitters run 'bitters install --path app/assets/stylesheets' end |
#bullet_config ⇒ Object
110 111 112 |
# File 'lib/kazan/app_builder.rb', line 110 def bullet_config template 'bullet.rb', 'config/initializers/bullet.rb' end |
#bundler_audit_config ⇒ Object
195 196 197 198 |
# File 'lib/kazan/app_builder.rb', line 195 def bundler_audit_config copy_file 'bundler_audit.rake', 'lib/tasks/bundler_audit.rake' append_file 'Rakefile', %{\ntask default: 'bundler:audit'\n} end |
#database_tables ⇒ Object
42 43 44 |
# File 'lib/kazan/app_builder.rb', line 42 def database_tables bundle_command 'exec rake db:create db:migrate' end |
#dotenvs ⇒ Object
73 74 75 |
# File 'lib/kazan/app_builder.rb', line 73 def dotenvs directory 'envs', '.' end |
#empty_directories ⇒ Object
279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 |
# File 'lib/kazan/app_builder.rb', line 279 def empty_directories [ 'app/assets/fonts', 'app/controllers/api', 'app/controllers/web', 'app/services', 'app/policies', 'app/validations', 'app/views/shared', 'spec/controllers', 'spec/factories', 'spec/helpers', 'spec/models', 'spec/mailers', 'spec/requests', 'spec/routing', ].each do |dir| empty_directory_with_keep_file dir end end |
#exception_on_delivery_errors ⇒ Object
81 82 83 84 |
# File 'lib/kazan/app_builder.rb', line 81 def exception_on_delivery_errors replace_in_file 'config/environments/development.rb', 'raise_delivery_errors = false', 'raise_delivery_errors = true' end |
#exception_on_missing_assets_in_test ⇒ Object
200 201 202 |
# File 'lib/kazan/app_builder.rb', line 200 def exception_on_missing_assets_in_test configure_environment 'test', 'config.assets.raise_runtime_errors = true' end |
#exception_on_missing_translations ⇒ Object
95 96 97 98 |
# File 'lib/kazan/app_builder.rb', line 95 def exception_on_missing_translations exception_on_missing_translations_in 'development' exception_on_missing_translations_in 'test' end |
#exception_on_unpermitted_parameters ⇒ Object
86 87 88 89 90 91 92 93 |
# File 'lib/kazan/app_builder.rb', line 86 def exception_on_unpermitted_parameters config = "config.action_controller.action_on_unpermitted_parameters = :raise\n\n RUBY\n\n inject_into_class 'config/application.rb', 'Application', config\nend\n" |
#foreman_config ⇒ Object
123 124 125 |
# File 'lib/kazan/app_builder.rb', line 123 def foreman_config template 'Procfile.erb', 'Procfile' end |
#gemfile ⇒ Object
13 14 15 |
# File 'lib/kazan/app_builder.rb', line 13 def gemfile template 'Gemfile.erb', 'Gemfile' end |
#gemfile_api ⇒ Object
17 18 19 |
# File 'lib/kazan/app_builder.rb', line 17 def gemfile_api template 'Gemfile.api.erb', 'Gemfile', force: true end |
#gitignore ⇒ Object
9 10 11 |
# File 'lib/kazan/app_builder.rb', line 9 def gitignore copy_file 'project_gitignore', '.gitignore', force: true end |
#init_commit ⇒ Object
300 301 302 303 304 |
# File 'lib/kazan/app_builder.rb', line 300 def init_commit run 'git init' run 'git add .' run 'git commit -m "Init commit"' end |
#letter_opener_config ⇒ Object
100 101 102 103 104 105 106 107 108 |
# File 'lib/kazan/app_builder.rb', line 100 def letter_opener_config letter_opener_settings = " # Letter opener settings\n config.action_mailer.default_url_options = { host: 'localhost', port: 3000 }\n config.action_mailer.delivery_method = :letter_opener\n RUBY\n\n configure_environment 'development', letter_opener_settings\nend\n" |
#postgres_config ⇒ Object
37 38 39 40 |
# File 'lib/kazan/app_builder.rb', line 37 def postgres_config template 'database.yml.erb', 'config/database.yml', force: true template 'database.yml.erb', 'config/database.yml.example' end |
#puma_config ⇒ Object
33 34 35 |
# File 'lib/kazan/app_builder.rb', line 33 def puma_config copy_file 'puma.rb', 'config/puma.rb', force: true end |
#quiet_assets_config ⇒ Object
114 115 116 117 118 119 120 121 |
# File 'lib/kazan/app_builder.rb', line 114 def quiet_assets_config config = "config.assets.quiet = true\n\n RUBY\n\n inject_into_class 'config/application.rb', 'Application', config\nend\n" |
#rack_canonical_host_config ⇒ Object
258 259 260 261 262 263 264 265 |
# File 'lib/kazan/app_builder.rb', line 258 def rack_canonical_host_config config = " config.middleware.use Rack::CanonicalHost, ENV.fetch(\"APPLICATION_HOST\")\n RUBY\n\n inject_into_file \"config/environments/production.rb\", config,\n after: \"Rails.application.configure do\"\nend\n" |
#rack_deflater_config ⇒ Object
267 268 269 |
# File 'lib/kazan/app_builder.rb', line 267 def rack_deflater_config configure_environment "production", "config.middleware.use Rack::Deflater" end |
#rack_mini_profiler_config ⇒ Object
29 30 31 |
# File 'lib/kazan/app_builder.rb', line 29 def rack_mini_profiler_config copy_file 'rack_mini_profiler.rb', 'config/initializers/rack_mini_profiler.rb' end |
#rack_timeout_config ⇒ Object
249 250 251 252 253 254 255 256 |
# File 'lib/kazan/app_builder.rb', line 249 def rack_timeout_config rack_timeout_config = " Rack::Timeout.timeout = (ENV[\"RACK_TIMEOUT\"] || 10).to_i\n\n RUBY\n\n append_file 'config/environments/production.rb', rack_timeout_config\nend\n" |
#rails_generators_config ⇒ Object
127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 |
# File 'lib/kazan/app_builder.rb', line 127 def rails_generators_config config = "config.generators do |generate|\n generate.helper false\n generate.javascript_engine false\n generate.request_specs false\n generate.routing_specs false\n generate.stylesheets false\n generate.test_framework :rspec\n generate.view_specs false\nend\n\n RUBY\n\n inject_into_class 'config/application.rb', 'Application', config\nend\n" |
#readme ⇒ Object
5 6 7 |
# File 'lib/kazan/app_builder.rb', line 5 def readme template 'README.md.erb', 'README.md' end |
#refills ⇒ Object
173 174 175 176 |
# File 'lib/kazan/app_builder.rb', line 173 def refills generate 'refills:import', 'flashes' remove_dir 'app/views/refills' end |
#remove_turbolinks ⇒ Object
144 145 146 147 148 149 |
# File 'lib/kazan/app_builder.rb', line 144 def remove_turbolinks replace_in_file( "app/assets/javascripts/application.js", "//= require turbolinks", "") end |
#rollbar_config ⇒ Object
271 272 273 |
# File 'lib/kazan/app_builder.rb', line 271 def copy_file 'rollbar.rb', 'config/initializers/rollbar.rb' end |
#rspec_config ⇒ Object
224 225 226 |
# File 'lib/kazan/app_builder.rb', line 224 def rspec_config generate 'rspec:install' end |
#rspec_replace_config ⇒ Object
228 229 230 231 |
# File 'lib/kazan/app_builder.rb', line 228 def rspec_replace_config copy_file 'rails_helper.rb', 'spec/rails_helper.rb', force: true copy_file 'spec_helper.rb', 'spec/spec_helper.rb', force: true end |
#ruby_version ⇒ Object
21 22 23 |
# File 'lib/kazan/app_builder.rb', line 21 def ruby_version create_file '.ruby-version', "#{Kazan::RUBY_PROJECT_VERSION}\n" end |
#settings ⇒ Object
77 78 79 |
# File 'lib/kazan/app_builder.rb', line 77 def settings template 'settings.yml.erb', 'config/settings.yml' end |
#shared_flash ⇒ Object
50 51 52 53 |
# File 'lib/kazan/app_builder.rb', line 50 def shared_flash copy_file '_flashes.html.erb', 'app/views/layouts/shared/_flashes.html.erb' copy_file 'flashes_helper.rb', 'app/helpers/flashes_helper.rb' end |
#shared_javascript ⇒ Object
55 56 57 |
# File 'lib/kazan/app_builder.rb', line 55 def shared_javascript copy_file '_javascript.html.erb', 'app/views/layouts/shared/_javascript.html.erb' end |
#shared_layout ⇒ Object
63 64 65 |
# File 'lib/kazan/app_builder.rb', line 63 def shared_layout copy_file 'application.html.erb', 'app/views/layouts/application.html.erb', force: true end |
#shared_styles ⇒ Object
59 60 61 |
# File 'lib/kazan/app_builder.rb', line 59 def shared_styles copy_file '_styles.html.erb', 'app/views/layouts/shared/_styles.html.erb' end |
#shared_views_directory ⇒ Object
46 47 48 |
# File 'lib/kazan/app_builder.rb', line 46 def shared_views_directory empty_directory 'app/views/layouts/shared' end |
#simple_form_config ⇒ Object
25 26 27 |
# File 'lib/kazan/app_builder.rb', line 25 def simple_form_config bundle_command 'exec rails generate simple_form:install' end |
#smtp_config ⇒ Object
233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 |
# File 'lib/kazan/app_builder.rb', line 233 def smtp_config copy_file 'smtp.rb', 'config/smtp.rb' prepend_file 'config/environments/production.rb', %{require Rails.root.join("config/smtp")\n} config = " config.action_mailer.delivery_method = :smtp\n config.action_mailer.smtp_settings = SMTP_SETTINGS\n\n RUBY\n\n inject_into_file 'config/environments/production.rb', config,\n after: \"config.action_mailer.raise_delivery_errors = false\"\nend\n" |
#spec_action_mailer_config ⇒ Object
208 209 210 |
# File 'lib/kazan/app_builder.rb', line 208 def spec_action_mailer_config copy_file 'action_mailer.rb', 'spec/support/action_mailer.rb' end |
#spec_database_cleaner_config ⇒ Object
212 213 214 |
# File 'lib/kazan/app_builder.rb', line 212 def spec_database_cleaner_config copy_file 'database_cleaner.rb', 'spec/support/database_cleaner.rb' end |
#spec_factory_girl_config ⇒ Object
220 221 222 |
# File 'lib/kazan/app_builder.rb', line 220 def spec_factory_girl_config copy_file 'factory_girl.rb', 'spec/support/factory_girl.rb' end |
#spec_shoulda_matchers_config ⇒ Object
216 217 218 |
# File 'lib/kazan/app_builder.rb', line 216 def spec_shoulda_matchers_config copy_file 'shoulda_matchers.rb', 'spec/support/shoulda_matchers.rb' end |
#spec_translations_config ⇒ Object
204 205 206 |
# File 'lib/kazan/app_builder.rb', line 204 def spec_translations_config copy_file 'i18n.rb', 'spec/support/i18n.rb' end |
#spring ⇒ Object
275 276 277 |
# File 'lib/kazan/app_builder.rb', line 275 def spring bundle_command 'exec spring binstub --all' end |
#static_pages ⇒ Object
182 183 184 185 186 187 188 189 190 191 192 193 |
# File 'lib/kazan/app_builder.rb', line 182 def static_pages = "<meta charset=\"utf-8\" />\n<meta name=\"ROBOTS\" content=\"NOODP\" />\n<meta name=\"viewport\" content=\"initial-scale=1\" />\n EOS\n\n %w(500 404 422).each do |page|\n inject_into_file \"public/\#{page}.html\", meta_tags, after: \"<head>\\n\"\n replace_in_file \"public/\#{page}.html\", /<!--.+-->\\n/, ''\n end\nend\n" |
#stylesheets_gems ⇒ Object
151 152 153 154 155 156 157 158 159 160 161 162 163 |
# File 'lib/kazan/app_builder.rb', line 151 def stylesheets_gems gems = "\ngem 'bourbon', '5.0.0.beta.6'\ngem 'neat', '~> 1.8.0'\ngem 'refills', group: [:development, :test]\n RUBY\n\n inject_into_file 'Gemfile', gems,\n after: \"gem 'sass-rails', '~> 5.0'\\n\"\n\n Bundler.with_clean_env { run 'bundle install' }\nend\n" |
#stylesheets_manifest ⇒ Object
165 166 167 168 169 170 171 |
# File 'lib/kazan/app_builder.rb', line 165 def stylesheets_manifest remove_file 'app/assets/stylesheets/application.css' copy_file( 'application.scss', 'app/assets/stylesheets/application.scss', force: true) end |