Class: JungleTest::Runner

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

Overview

Runner Class for the JungleTest gem

Class Method Summary collapse

Class Method Details

.build_content_matrixObject



19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/jungle_test.rb', line 19

def build_content_matrix
  # Initialize datatable for two csv files
  dt_p = JungleTest::DataTable.csv_to_datatable(CSV_PROF)
  dt_j = JungleTest::DataTable.csv_to_datatable(CSV_CAT_JOBS)

  # Create hash that contains profession category by id
  cat = JungleTest::Professions.new(dt_p)
  dt_merged = cat.merge_prof_contract(dt_j)
  line_total = cat.total_by_contract_type(dt_merged)
  mat = JungleTest::MatrixBuilder.new(dt_merged)
  content = mat.content_line_matrix(line_total, dt_merged)
  headers = mat.matrix_headers
  { headers: headers, content: content }
end

.draw_headers(columns) ⇒ Object



34
35
36
37
38
# File 'lib/jungle_test.rb', line 34

def draw_headers(columns)
  JungleTest::DrawMatrix.puts_divider(columns)
  JungleTest::DrawMatrix.puts_header(columns)
  JungleTest::DrawMatrix.puts_divider(columns)
end

.executeObject



40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/jungle_test.rb', line 40

def execute
  headers = build_content_matrix[:headers]
  content = build_content_matrix[:content]
  columns = JungleTest::DrawMatrix.columns_spec(headers, content)
  draw_headers(columns)
  res = {}
  content.each do |ct|
    headers.each_key { |key| res[key] = ct[key].to_s.upcase }
    JungleTest::DrawMatrix.puts_line(res, columns)
  end
  JungleTest::DrawMatrix.puts_divider(columns)
end