Module: LatexCurriculumVitae::Email

Defined in:
lib/latex_curriculum_vitae/email.rb

Overview

Module for creating the Email

Class Method Summary collapse

Class Method Details

.create_email(contact, email_address, job_title, contact_sex, proactive, letter, name_of_pdf, sysconf_dir, data_dir, mail_backend, target) ⇒ Object

Method for creating the email TODO: Try to fix this in future rubocop:disable Metrics/MethodLength rubocop:disable Metrics/ParameterLists This method smells of :reek:LongParameterList This method smells of :reek:ControlParameter

Parameters:

  • contact (String)

    Name of the contact

  • email_address (String)

    Email address of the contact

  • job_title (String)

    Title of the target job

  • contact_sex (String)

    Can be male, female or unknown

  • proactive (String)

    Can be yes or no

  • letter (String)

    For preparing the letter

  • name_of_pdf (String)

    Name of the output pdf



39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# File 'lib/latex_curriculum_vitae/email.rb', line 39

def self.create_email(contact, email_address, job_title, contact_sex, proactive, letter, name_of_pdf, sysconf_dir,
                      data_dir, mail_backend, target)
  own_email_address, own_smtp, own_username, own_password,
      own_port = LatexCurriculumVitae::GetConfig.get_smtp(sysconf_dir)
  introduction = introduction(contact, contact_sex)
  subject = subject(proactive, job_title)
  body = get_body(introduction, letter, proactive, job_title, target)
  filename = "#{data_dir}/#{name_of_pdf}.pdf"

  if mail_backend == 'Pony'
    # More information about Pony Mailer: https://github.com/benprew/pony
    Pony.mail(to: email_address,
              bcc: own_email_address,
              from: own_email_address,
              subject: subject,
              body: body,
              attachments: { 'Bewerbungsunterlagen_Manns.pdf' => File.read(filename) },
              via: :smtp,
              via_options: {
                address: own_smtp,
                port: own_port,
                enable_starttls_auto: true,
                user_name: own_username,
                password: own_password,
                authentication: :plain, # :plain, :login, :cram_md5, no auth by default
                domain: 'localhost.localdomain', # the HELO domain provided by the client to the server
              })
  else
    `evolution mailto:"#{email_address}?subject=#{subject}\&body=#{body}\&attach=#{filename}"`
  end
end

.get_body(introduction, letter, proactive, job_title, target) ⇒ String

Method for building the email body TODO: Try to fix this in future rubocop:disable Layout/IndentHeredoc This method smells of :reek:ControlParameter

Parameters:

  • introduction (String)

    EMail introduction

  • letter (String)

    With motivational letter? Can be yes or no

  • proactive (String)

    Is this a proactive application yes/no

  • job_title (String)

    The job title

Returns:

  • (String)

    body Returns the messagebody for the email



152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
# File 'lib/latex_curriculum_vitae/email.rb', line 152

def self.get_body(introduction, letter, proactive, job_title, target)
  intro = get_intro(proactive, job_title)
  target_block = get_target_block(target)
  body = if letter == 'no'
           <<BODY
#{introduction}

#{intro}

Mit meinen vielfältigen Erfahrungen als Kaufmann, Community-
Manager, Buchautor und Customer Supporter (Level 1 und 2),
sowie Autor Geschäftsprozess- und Anwendungsdokumentation
könnte ich Ihr neuer Mitarbeiter sein.

Zuletzt war ich für die XCOM AG im Bereich der Dokumentation
tätig.

Seit dieser Zeit habe ich an teamgesteuerten Projekten für Kunden
mitgearbeitet, wobei mein Schwerpunkt im Bereich Kundenpflege via
Telefon und Email, Dispatching und Teamcontrolling lag.

#{target_block}

In für mich fremde Arbeitsgebiete werde ich mich rasch einarbeiten.
Meine Kenntnisse in IT und Organisationsfähigkeiten kann ich für Ihr
Unternehmen im Bereich des Managements gewinnbringend umsetzen.
Persönlich runde ich das Profil mit den Eigenschaften: Teamfähigkeit,
Kommunikationsstärke und Leistungsbereitschaft ab.

Ich bin mir sicher, die von Ihnen gewünschten Kenntnisse und
Fähigkeiten mitzubringen, und würde mich sehr über ein
Vorstellungsgespräch freuen.

--


Sincerly yours

Sascha Manns
Maifeldstraße 10
56727 Mayen
Phone: +49-172-3142738 (mobile)
Phone: +49-2651-4014045 (home)
Email: [email protected]
Web: https://saschamanns.de
BODY
         else
           <<BODY
#{introduction}

gerne möchte ich mich bei Ihnen für die obige Stelle bewerben.
Meine digitale Bewerbungsmappe, samt des offiziellen Anschreibens,
sind der Mail als Anhang beigefügt.
--
Sincerly yours

Sascha Manns
Maifeldstraße 10
56727 Mayen
Phone: +49-172-3142738 (mobile)
Phone: +49-2651-4014045 (home)
Email: [email protected]
Web: https://saschamanns.de
BODY
         end
  return body
end

.get_intro(proactive, job_title) ⇒ Object

Method for getting the email intro TODO: Try to fix this in future rubocop:disable Metrics/LineLength This method smells of :reek:ControlParameter

Parameters:

  • proactive (String)

    Is this a proactive application yes/no

  • job_title (String)

    The job title

Returns:

  • intro



113
114
115
116
117
118
119
120
# File 'lib/latex_curriculum_vitae/email.rb', line 113

def self.get_intro(proactive, job_title)
  intro = if proactive == 'yes'
            "gerne möchte ich mich bei Ihnen um die Stelle als #{job_title} oder einer ähnlichen Position bewerben."
          else
            "mit großem Interesse bin ich auf die ausgeschriebene Position aufmerksam geworden. Aus diesem Grund bewerbe ich mich bei Ihnen als #{job_title}."
          end
  return intro
end

.get_target_block(target) ⇒ Object

Method for getting the target code block TODO: Try to fix this in future This method smells of :reek:ControlParameter

Parameters:

  • target (String)

    The chosen target



127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
# File 'lib/latex_curriculum_vitae/email.rb', line 127

def self.get_target_block(target)
  if target == 'doku'
    target_block = 'Neben der Beschreibungssprache DocBook samt XSL-FO lernte ich die Satzsprache LaTeX.
Selbstständig erarbeitete ich mir Kenntnisse in den Programmiersprachen Ruby, Python, sowie der Web-App-Entwicklung
(TH Mittelrhein).'
  elsif target == 'support'
    target_block = 'Im IT-Support hatte ich bereits erste Führungserfahrung als Dispatcher und Controller.
Selbstständig erarbeitete ich mir Kenntnisse in den Programmiersprachen Bash, Ruby und Python, sowie der
Web-App-Entwicklung (TH Mittelrhein).'
  else
    target_block = 'Im kaufmännischen Bereich habe ich bereits vielfältige Erfahrungen im Einkauf, Verkauf,
Öffentlichkeitsarbeit und Vertrieb gemacht und bin stets bereit neues zu lernen.'
  end
  return target_block
end

.introduction(contact, contact_sex) ⇒ String

Method for building the introduction TODO: Try to fix this in future rubocop:disable Style/IfInsideElse This method smells of :reek:ControlParameter

Parameters:

  • contact (String)

    Name of the contact

  • contact_sex (String)

    Can be male, female or unknown

Returns:

  • (String)

    Returns introduction



78
79
80
81
82
83
84
85
86
87
88
89
# File 'lib/latex_curriculum_vitae/email.rb', line 78

def self.introduction(contact, contact_sex)
  introduction = if contact == ''
                   'Sehr geehrte Damen und Herren,'
                 else
                   if contact_sex == 'male'
                     "Sehr geehrter Herr #{contact},"
                   else
                     "Sehr geehrte Frau #{contact},"
                   end
                 end
  return introduction
end

.result_ok(contact, email_address, job_title, contact_sex, proactive, letter, name_of_pdf, sysconf_dir, data_dir, mail_backend, target) ⇒ Object

Method for checking the result TODO: Try to fix this in future This method smells of :reek:LongParameterList

Parameters:

  • contact (String)

    Name of the contact

  • email_address (String)

    Email address from the contact

  • job_title (String)

    The given jobtitle

  • contact_sex (String)

    Can be male, female or unknown

  • proactive (String)

    Can be yes or no

  • letter (String)

    With motivational letter? Can be yes or no

  • name_of_pdf (String)

    Name of the resulting PDF file



230
231
232
233
234
235
236
237
238
239
240
241
242
243
# File 'lib/latex_curriculum_vitae/email.rb', line 230

def self.result_ok(contact, email_address, job_title, contact_sex, proactive, letter, name_of_pdf, sysconf_dir,
                   data_dir, mail_backend, target)
  resultfile_ok = `yad --title="Resulting file" --center --on-top --form \
--item-separator=, --separator="|" \
--field="Resulting file ok?:CBE" \
"yes,no"`
  ok = resultfile_ok.chomp.split('|')
  if ok.include? 'yes'
    LatexCurriculumVitae::Email.create_email(contact, email_address, job_title, contact_sex, proactive, letter,
                                             name_of_pdf, sysconf_dir, data_dir, mail_backend, target)
  else
    abort('Aborted')
  end
end

.subject(proactive, job_title) ⇒ Array

Method for building the subject TODO: Try to fix this in future This method smells of :reek:ControlParameter

Parameters:

  • proactive (String)

    Can be yes or no

  • job_title (String)

    Title of the target job

Returns:

  • (Array)

    subject, intro



97
98
99
100
101
102
103
104
# File 'lib/latex_curriculum_vitae/email.rb', line 97

def self.subject(proactive, job_title)
  subject = if proactive == 'yes'
              "Initiativbewerbung um einen Arbeitsplatz als #{job_title}"
            else
              "Bewerbung um einen Arbeitsplatz als #{job_title}"
            end
  return subject
end