Class: Browsable::Generators::InstallGenerator

Inherits:
Rails::Generators::Base
  • Object
show all
Defined in:
lib/generators/browsable/install/install_generator.rb

Overview

‘rails g browsable:install` — writes a fully-commented config/browsable.yml.

The generated file is a self-documenting reference: every option is present, commented out, and set to its default. browsable needs no config to run; this file exists only so overriding a default is one uncomment away.

Instance Method Summary collapse

Instance Method Details

#create_config_fileObject



24
25
26
27
28
29
30
31
32
# File 'lib/generators/browsable/install/install_generator.rb', line 24

def create_config_file
  if File.exist?(config_destination) && !options[:force]
    say_status :skip, "config/browsable.yml already exists (pass --force to overwrite)", :yellow
    @skipped = true
    return
  end

  template "browsable.yml.tt", "config/browsable.yml", force: options[:force]
end


34
35
36
37
38
39
40
41
42
# File 'lib/generators/browsable/install/install_generator.rb', line 34

def print_summary
  return if @skipped

  say ""
  say "browsable: created config/browsable.yml", :green
  say "  Every option is commented out and set to its default — the file is", :white
  say "  optional and exists only for overrides. Uncomment a line to change it.", :white
  say "  Run `bundle exec browsable audit` for your first audit.", :white
end