Module: LatexCurriculumVitae::Entityfile

Defined in:
lib/latex_curriculum_vitae/entityfile.rb

Overview

Module for creating the entityfile

Class Method Summary collapse

Class Method Details

.create_file(job_title, company, street, city, contact, entity_tex, contact_sex, proactive, target) ⇒ Object

Method for creating the entity.tex TODO: Try to fix this in future This method smells of :reek:LongParameterList

Parameters:

  • job_title (String)

    Title of the target job

  • company (String)

    Comanys name

  • street (String)

    Companies street

  • city (String)

    City of the company

  • contact (String)

    Name of the contact

  • contact_sex (String)

    Sex of the contact

  • entity_tex (String)

    Path to the entity.tex


80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
# File 'lib/latex_curriculum_vitae/entityfile.rb', line 80

def self.create_file(job_title, company, street, city, contact, entity_tex, contact_sex, proactive, target)
  introduction = LatexCurriculumVitae::Entityfile.get_introduction(contact, contact_sex)
  subject, intro = LatexCurriculumVitae::Entityfile.get_subject_intro(proactive, job_title)
  address_string = LatexCurriculumVitae::Entityfile.get_address_string(company, contact, contact_sex, street, city)
  target_block = LatexCurriculumVitae::Entityfile.get_target_block(target)

  FileUtils.rm(entity_tex) if File.exist?(entity_tex)
  FileUtils.touch(entity_tex)
  # TODO: Try to fix this in future
  # rubocop:disable Layout/IndentHeredoc
  File.write "#{entity_tex}", <<TEXFILE
\\def\\jobtitle{#{job_title}}
\\def\\company{#{company}}
\\def\\contact{#{contact}}
\\def\\street{#{street}}
\\def\\city{#{city}}
\\def\\introduction{#{introduction}}
\\def\\subject{#{subject}}
\\def\\addressstring{#{address_string}}
\\def\\intro{#{intro}}
\\def\\targetblock{#{target_block}}
TEXFILE
end

.get_address_string(company, contact, contact_sex, street, city) ⇒ String

Method for preparing the address_string TODO: Try to fix this in future This method smells of :reek:LongParameterList This method smells of :reek:ControlParameter

Parameters:

  • company (String)

    Comanys name

  • street (String)

    Companies street

  • city (String)

    City of the company

  • contact (String)

    Name of the contact

Returns:

  • (String)

    address_string


150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
# File 'lib/latex_curriculum_vitae/entityfile.rb', line 150

def self.get_address_string(company, contact, contact_sex, street, city)
  address_string = "#{company} \\\\"
  address_string << if contact == ''
                      'z.Hd. Personalabteilung \\\\'
                    else
                      if contact_sex == 'male'
                        "z.Hd. Herrn #{contact} \\\\"
                      else
                        "z.Hd. Frau #{contact} \\\\"
                      end
                    end
  address_string << "#{street} \\\\" if street != ''
  address_string << "#{city}" if city != ''
  return address_string
end

.get_information(entity_tex) ⇒ Array

TODO: Try to fix this in future rubocop:disable Metrics/LineLength Method for getting information

Parameters:

  • entity_tex (String)

    Path to the entity.tex

Returns:

  • (Array)

    contact, email_address, job_title, contact_sex, company, proactive, job_url


30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/latex_curriculum_vitae/entityfile.rb', line 30

def self.get_information(entity_tex)
  resume = `yad --title="Create application" --center --on-top --form --item-separator=, --separator="|" \
--field="What is the jobtitle of your application? Escape amp with backslash:TEXT" \
--field="Is it a proactive application?:CBE" \
--field="Create a motivational letter?:CBE" \
--field="What is the companies name? Escape amp with backslash:TEXT" \
--field="Give me the street of the company:TEXT" \
--field="What is the zip-code (german PLZ) and city from the company:TEXT" \
--field="Is your contact male or female? Leave blank if unknown contact:CBE" \
--field="If you have a contact so give me the name of him/her. Leave blank if unknown contact:TEXT" \
--field="Tell me the email address for sending the application:TEXT" \
--field="What kind of target:CBE" \
--field="Tell me the URL of the job offer:TEXT" \
--button="Go!" "" "no,yes" "yes,no" "" "" "" "male,female,unknown" "" "" "doku,support,kaufm"`
  job_title, proactive, letter, company, street, city, contact_sex, contact, email_address,
      target, job_url = resume.chomp.split('|')

  create_file(job_title, company, street, city, contact, entity_tex, contact_sex, proactive, target)
  [contact, email_address, job_title, contact_sex, company, letter, proactive, job_url, target]
end

.get_introduction(contact, contact_sex) ⇒ String

Method for preparing the introduction variable 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)

    Sex of the contact

Returns:

  • (String)

    introduction


111
112
113
114
115
116
117
118
119
120
121
122
# File 'lib/latex_curriculum_vitae/entityfile.rb', line 111

def self.get_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

.get_subject_intro(proactive, job_title) ⇒ Array

Method for preparing the subject and intro variables 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


130
131
132
133
134
135
136
137
138
139
# File 'lib/latex_curriculum_vitae/entityfile.rb', line 130

def self.get_subject_intro(proactive, job_title)
  if proactive == 'yes'
    subject = "Initiativbewerbung um einen Arbeitsplatz als #{job_title}"
    intro = "gerne möchte ich mich bei Ihnen um die Stelle als #{job_title} oder einer ähnlichen Position bewerben."
  else
    subject = "Bewerbung um einen Arbeitsplatz als #{job_title}"
    intro = "mit großem Interesse bin ich auf die ausgeschriebene Position aufmerksam geworden. Aus diesem Grund bewerbe ich mich bei Ihnen als #{job_title}."
  end
  [subject, 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


171
172
173
174
175
176
177
178
179
180
181
182
183
184
# File 'lib/latex_curriculum_vitae/entityfile.rb', line 171

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 der Programmiersprache 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 \\&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

.shorten_url(job_url, bit_ly_user, bit_ly_apikey) ⇒ String

Method for shorten the URL

Parameters:

  • job_url (String)

    The Url to the job offer

  • bit_ly_user (String)

    The Username in Bit.ly

  • bit_ly_apikey (String)

    The Apikey from your Bit.ly User

Returns:

  • (String)

    job_url_checked Returns the shortened Bit.ly URL


56
57
58
59
60
61
62
63
64
65
66
67
68
# File 'lib/latex_curriculum_vitae/entityfile.rb', line 56

def self.shorten_url(job_url, bit_ly_user, bit_ly_apikey)
  # TODO: Try to fix this in future
  # rubocop:disable Style/UnneededInterpolation
  authorize = UrlShortener::Authorize.new "#{bit_ly_user}", "#{bit_ly_apikey}"
  client = UrlShortener::Client.new authorize

  shorten = client.shorten("#{job_url}") # => UrlShortener::Response::Shorten object
  shorten.result # => returns a hash of all data returned from bitly
  shorten.urls # => Only returns the short urls look for more convenience methods in the UrlShortener::Response::Shorten class
  puts shorten.urls
  job_url_checked = shorten.urls
  return job_url_checked
end