Class: Ievkit::Job

Inherits:
Object
  • Object
show all
Defined in:
lib/ievkit/job.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(referential_id) ⇒ Job

Returns a new instance of Job.



6
7
8
# File 'lib/ievkit/job.rb', line 6

def initialize(referential_id)
  @client = Ievkit::Client.new(referential_id)
end

Instance Attribute Details

#clientObject (readonly)

Returns the value of attribute client.



3
4
5
# File 'lib/ievkit/job.rb', line 3

def client
  @client
end

#disable_cacheObject

Returns the value of attribute disable_cache.



4
5
6
# File 'lib/ievkit/job.rb', line 4

def disable_cache
  @disable_cache
end

#responseObject (readonly)

Returns the value of attribute response.



3
4
5
# File 'lib/ievkit/job.rb', line 3

def response
  @response
end

Instance Method Details

#delete_job(url) ⇒ Object



18
19
20
# File 'lib/ievkit/job.rb', line 18

def delete_job(url)
  do_job(url, :delete)
end

#delete_jobsObject



22
23
24
# File 'lib/ievkit/job.rb', line 22

def delete_jobs
  do_job(@client.iev_url_jobs, :delete)
end

#download_validation_report(data, errors) ⇒ Object



38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# File 'lib/ievkit/job.rb', line 38

def download_validation_report(data, errors)
  csv = []
  csv << "\uFEFF;Statut/Information;Nombre d'erreurs;Nombre d'avertissements"
  data.each do |el|
    t = [el[:name], I18n.t("compliance_check_results.severities.#{el[:status]}"), el[:count_error], el[:count_warning]]
    csv << t.join(';')
    next unless el[:check_point_errors]
    el[:check_point_errors].each do |index|
      error = errors[index]
      next unless error
      t = []
      esf = error[:source][:file]
      if esf && esf[:filename]
        filename = []
        filename << "#{I18n.t('report.file.line')} #{esf[:line_number]}" if esf[:line_number].to_i > 0
        filename << "#{I18n.t('report.file.column')} #{esf[:column_number]}" if esf[:column_number].to_i > 0
        t << filename.join(' ') if filename.present?
      end
      t << error[:error_name]
      csv << ';'+t.join(' ')
    end
  end
  csv.join("\n")
end

#get_job(url) ⇒ Object



14
15
16
# File 'lib/ievkit/job.rb', line 14

def get_job(url)
  do_job(url, :get)
end

#get_statsObject



30
31
32
# File 'lib/ievkit/job.rb', line 30

def get_stats
  @client.get_stats
end

#list_tests(action, format) ⇒ Object



34
35
36
# File 'lib/ievkit/job.rb', line 34

def list_tests(action, format)
  @client.list_tests(action, format)
end

#post_job(action, type = nil, options = {}) ⇒ Object



10
11
12
# File 'lib/ievkit/job.rb', line 10

def post_job(action, type = nil, options = {})
  send(action, type, options)
end

#terminated_job?(url) ⇒ Boolean

Returns:

  • (Boolean)


26
27
28
# File 'lib/ievkit/job.rb', line 26

def terminated_job?(url)
  get_job(url).to_s.include?('terminated_jobs')
end