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 36 37 |
# File 'lib/generators/trek/install/postmark_generator.rb', line 30 def inject_postmark_to_config return if File.read("config/environments/production.rb").include?("delivery_method = :postmark") 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
39 40 41 42 43 44 45 46 47 48 |
# File 'lib/generators/trek/install/postmark_generator.rb', line 39 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 |