Module: EcoRake::Utils::Mailing

Defined in:
lib/eco-rake/utils/mailing.rb

Instance Method Summary collapse

Instance Method Details

#email(subject:, body:, to:, enviro: nil, space: nil) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/eco-rake/utils/mailing.rb', line 9

def email(subject:, body:, to:, enviro: nil, space: nil)
  has_enviro = enviro && subject&.downcase&.include?(enviro.downcase)

  if enviro && !has_enviro
    env_str  = enviro.upcase
    env_str << " (space: #{space})" if space
    subject  = "#{env_str} - #{subject}"
  end

  mailer.mail(
    to:      to,
    subject: subject,
    body:    body
  )
end

#email_missing_files(enviro:, to:, space: nil) ⇒ Object

Helper to notify that there are no files to be processed



26
27
28
29
30
31
32
33
34
# File 'lib/eco-rake/utils/mailing.rb', line 26

def email_missing_files(enviro:, to:, space: nil)
  email(
    to:      to,
    subject: "No files to be processed",
    body:    'No files found to be processed. Aborting...',
    enviro:  enviro,
    space:   space
  )
end

#mailerEcoRake::Mailer

Returns:

  • (EcoRake::Mailer)


5
6
7
# File 'lib/eco-rake/utils/mailing.rb', line 5

def mailer
  @mailer ||= EcoRake::Utils::Mailer.new
end