Class: Boring::LetterOpener::InstallGenerator

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

Instance Method Summary collapse

Instance Method Details

#add_letter_opener_gemObject



8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/generators/boring/letter_opener/install/install_generator.rb', line 8

def add_letter_opener_gem
  say "Adding letter_opener gem", :green

  gem_content = <<~RUBY.indent(2)
    \n# Preview email in the default browser instead of sending it to real mailbox
    gem "letter_opener"
  RUBY

  insert_into_file "Gemfile", gem_content, after: /group :development do/

  Bundler.with_unbundled_env do
    run "bundle install"
  end
end

#configure_letter_openerObject



23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/generators/boring/letter_opener/install/install_generator.rb', line 23

def configure_letter_opener
  say "Configuring letter_opener", :green

  configuration_content = <<~RUBY.chomp.indent(2)
    \n# Preview email in the browser instead of sending it
    config.action_mailer.delivery_method = :letter_opener
    config.action_mailer.perform_deliveries = true
  RUBY

  gsub_file "config/environments/development.rb",
            /end\Z/,
            "#{configuration_content}\nend"
end