Module: LatexCurriculumVitae::CVOutfile

Defined in:
lib/latex_curriculum_vitae/outfile.rb

Overview

Module for creating and appending the outfile

Class Method Summary collapse

Class Method Details

.add_to_outfile(job_title, company, contact, email_address, csv_out, job_url_checked) ⇒ Object

Method to adding the data into the csv file TODO: Try to fix this in future rubocop:disable Metrics/AbcSize This method smells of :reek:LongParameterList


33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/latex_curriculum_vitae/outfile.rb', line 33

def self.add_to_outfile(job_title, company, contact, email_address, csv_out, job_url_checked)
  time = Time.new
  date = time.strftime('%Y-%m-%d')
  contact.gsub!('%20', ' ')
  job_title.gsub!('%20', ' ')
  job_title.gsub!('%26', '&')
  if File.exist?(csv_out)
    puts 'do nothing'
  else
    FileUtils.touch(csv_out)
    # rubocop:disable IndentHeredoc
    File.write csv_out.to_s, <<CSV
date,company,job,contact,email,status, joburl
CSV
  end
  CSV.open(csv_out.to_s, 'a+') do |csv|
    # datum,firma,stelle,kontakt,email,status,joburl
    csv << [date.to_s, company.to_s, job_title.to_s, contact.to_s, email_address.to_s, 'Open', job_url_checked.to_s]
  end
end