Class: Rsg::Generators::Misc::MiscGenerator
- Inherits:
-
Base
- Object
- Base
- Rsg::Generators::Misc::MiscGenerator
- Defined in:
- lib/rsg/generators/misc/misc_generator.rb
Instance Method Summary collapse
- #banner ⇒ Object
-
#configure_environments ⇒ Object
TODO: Move to an i18n generator that does this and more.
- #configure_pry ⇒ Object
- #disable_assets_generators ⇒ Object
-
#healthcheck ⇒ Object
TODO: Move to rsg-dox.
- #isolate_rails_gem ⇒ Object
-
#puma_configs ⇒ Object
TODO: Skip puma on app generator, introduce a new Puma::InstallGenerator.
- #remove_assets ⇒ Object
- #remove_gemfile_comments ⇒ Object
- #remove_gemfile_extra_whitespace ⇒ Object
- #remove_tzinfo_gem ⇒ Object
Instance Method Details
#banner ⇒ Object
2 3 4 |
# File 'lib/rsg/generators/misc/misc_generator.rb', line 2 def say "Making some extra tweaks" end |
#configure_environments ⇒ Object
TODO: Move to an i18n generator that does this and more
54 55 56 57 58 59 |
# File 'lib/rsg/generators/misc/misc_generator.rb', line 54 def configure_environments # If by any chance we make use of translations, let them fail and get # caught early on the dev process uncomment_lines "config/environments/development.rb", /raise_on_missing_translations/ uncomment_lines "config/environments/test.rb", /raise_on_missing_translations/ end |
#configure_pry ⇒ Object
44 45 46 |
# File 'lib/rsg/generators/misc/misc_generator.rb', line 44 def configure_pry append_gem "pry-rails", within_group: :development end |
#disable_assets_generators ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/rsg/generators/misc/misc_generator.rb', line 28 def disable_assets_generators return if api_mode? inject_into_file "config/application.rb", <<-CODE, before: /^\s*# Don't generate system test files./ # Don't generate CSS files when using scaffolding commands, since we compile assets through webpacker config.generators.assets = false config.generators.scaffold_stylesheet = false config.generators.stylesheets = false # Most of time we can get away with a handful of methods in the default application_helper. Other ones # can be introduced as needed config.generators.helper = false CODE end |
#healthcheck ⇒ Object
TODO: Move to rsg-dox
62 63 64 65 66 67 68 69 |
# File 'lib/rsg/generators/misc/misc_generator.rb', line 62 def healthcheck inject_into_file "config/routes.rb", <<-CODE, before: "end" # Defines a static healthcheck for probes. Please note that this won't # output any logs in production get :healthcheck, to: proc { [200, {}, ['OK']] } CODE end |
#isolate_rails_gem ⇒ Object
24 25 26 |
# File 'lib/rsg/generators/misc/misc_generator.rb', line 24 def isolate_rails_gem gsub_file "Gemfile", /^( *)(gem ["']rails["'][^\n]+)\n(?: *)(gem ['"]puma['"][^\n]+)\n$/, "\\1\\2\n\n\\3" end |
#puma_configs ⇒ Object
TODO: Skip puma on app generator, introduce a new Puma::InstallGenerator
49 50 51 |
# File 'lib/rsg/generators/misc/misc_generator.rb', line 49 def puma_configs copy_file "puma.rb", "config/puma.rb", force: true end |
#remove_assets ⇒ Object
6 7 8 |
# File 'lib/rsg/generators/misc/misc_generator.rb', line 6 def remove_assets run "rm -rf app/assets" end |
#remove_gemfile_comments ⇒ Object
10 11 12 |
# File 'lib/rsg/generators/misc/misc_generator.rb', line 10 def remove_gemfile_comments gsub_file "Gemfile", /^ *#\s*[^#\n]+\n/, "" end |
#remove_gemfile_extra_whitespace ⇒ Object
20 21 22 |
# File 'lib/rsg/generators/misc/misc_generator.rb', line 20 def remove_gemfile_extra_whitespace gsub_file "Gemfile", /^( *gem[^\n]+)\n\n\n/, "\\1\n\n" end |
#remove_tzinfo_gem ⇒ Object
14 15 16 17 18 |
# File 'lib/rsg/generators/misc/misc_generator.rb', line 14 def remove_tzinfo_gem # Remove tzinfo-data since we don't have a need for it in dev / prod env, if # rsg becomes a thing on the platforms it's needed we can revisit gsub_file "Gemfile", /\ngem 'tzinfo-data'[^\n]+\n/, "" end |