class Rsg::Generators::Misc::MiscGenerator

Public Instance Methods

banner() click to toggle source
configure_environments() click to toggle source

TODO: Move to an i18n generator that does this and more

# 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() click to toggle source
# File lib/rsg/generators/misc/misc_generator.rb, line 44
def configure_pry
  append_gem "pry-rails", within_group: :development
end
disable_assets_generators() click to toggle source
# 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() click to toggle source

TODO: Move to rsg-dox

# 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() click to toggle source
# 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() click to toggle source

TODO: Skip puma on app generator, introduce a new Puma::InstallGenerator

# 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() click to toggle source
# File lib/rsg/generators/misc/misc_generator.rb, line 6
def remove_assets
  run "rm -rf app/assets"
end
remove_gemfile_comments() click to toggle source
# 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() click to toggle source
# 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() click to toggle source
# 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