Class: Trek::Generators::Install::PostmarkGenerator
- Inherits:
-
Rails::Generators::Base
- Object
- Rails::Generators::Base
- Trek::Generators::Install::PostmarkGenerator
- Includes:
- Helpers
- Defined in:
- lib/generators/trek/install/postmark_generator.rb
Instance Method Summary collapse
- #add_gem ⇒ Object
- #inject_postmark_to_application_mailer ⇒ Object
- #inject_postmark_to_config ⇒ Object
- #inject_postmark_to_credentials ⇒ Object
Instance Method Details
#add_gem ⇒ Object
15 16 17 18 19 20 |
# File 'lib/generators/trek/install/postmark_generator.rb', line 15 def add_gem return if in_gemfile?("postmark-rails") gem "postmark-rails" bundle_install end |
#inject_postmark_to_application_mailer ⇒ Object
22 23 24 25 26 27 28 |
# File 'lib/generators/trek/install/postmark_generator.rb', line 22 def inject_postmark_to_application_mailer inject_into_class "app/mailers/application_mailer.rb", "ApplicationMailer", application_mailer_injection, after: ' layout "mailer"\n' run "rubocop --autocorrect app/mailers/application_mailer.rb", abort_on_failure: true end |
#inject_postmark_to_config ⇒ Object
30 31 32 33 34 35 |
# File 'lib/generators/trek/install/postmark_generator.rb', line 30 def inject_postmark_to_config inject_into_file "config/environments/production.rb", config_injection, after: %r{# Specify outgoing SMTP server\. Remember to add smtp/\* credentials via (?:bin/)?rails credentials:edit\.\n} run "rubocop --autocorrect config/environments/production.rb", abort_on_failure: true end |
#inject_postmark_to_credentials ⇒ Object
37 38 39 40 41 42 43 44 45 46 |
# File 'lib/generators/trek/install/postmark_generator.rb', line 37 def inject_postmark_to_credentials return if credentials_encrypted_file.read&.include?("postmark:") inject_into_credentials( <<~YAML postmark: api_token: #{ENV.fetch("POSTMARK_API_TOKEN", "")} YAML ) end |