Class: PropertyGenerator::Report

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

Instance Method Summary collapse

Constructor Details

#initialize(files_failing_load) ⇒ Report

Returns a new instance of Report.



5
6
7
8
# File 'lib/linter/report.rb', line 5

def initialize(files_failing_load)
  @files_failing_load = files_failing_load
  @full_report = {}
end

Instance Method Details

#add_report(report) ⇒ Object



10
11
12
# File 'lib/linter/report.rb', line 10

def add_report(report)
  @full_report = @full_report.merge(report)
end

#display_reportObject



14
15
16
17
18
19
20
21
# File 'lib/linter/report.rb', line 14

def display_report
  if @files_failing_load != []
    make_failing_to_load_table
  end
  make_pass_table
  make_warn_table
  make_fail_table
end

#has_a_test_failedObject



23
24
25
26
27
28
29
30
31
# File 'lib/linter/report.rb', line 23

def has_a_test_failed
  @full_report.each do |test, status|
    if status[:status] == 'fail' || @files_failing_load != []
      return true
    else
      return false
    end
  end
end

#make_fail_tableObject



64
65
66
67
68
69
70
71
72
73
# File 'lib/linter/report.rb', line 64

def make_fail_table
  rows = []
  @full_report.each do |test,status|
    if status[:status] == 'fail'
      rows << [test.gsub('_', ' '), status[:error].scan(/.{1,90}/).join("\n")]
    end
  end
  table = Terminal::Table.new :headings => ['Test', 'Error'], :title => 'Failing Tests', :rows => rows, :style => {:width => 200}
  puts table
end

#make_failing_to_load_tableObject



33
34
35
36
37
38
39
40
# File 'lib/linter/report.rb', line 33

def make_failing_to_load_table
  rows = []
  @files_failing_load.each do |failed|
    rows << [failed]
  end
  table = Terminal::Table.new :headings => ['Files'], :title => 'Files Failing to Load', :rows => rows, :style => {:width => 200}
  puts table
end

#make_pass_tableObject



42
43
44
45
46
47
48
49
50
51
# File 'lib/linter/report.rb', line 42

def make_pass_table
  rows = []
  @full_report.each do |test,status|
    if status[:status] == 'pass'
      rows << [test.gsub('_', ' ')]
    end
  end
  table = Terminal::Table.new :headings => ['Test'], :title => 'Passing Tests', :rows => rows, :style => {:width => 200}
  puts table
end

#make_warn_tableObject



53
54
55
56
57
58
59
60
61
62
# File 'lib/linter/report.rb', line 53

def make_warn_table
  rows = []
  @full_report.each do |test,status|
    if status[:status] == 'warn'
      rows << [test.gsub('_', ' '), status[:error].scan(/.{1,90}/).join("\n")]
    end
  end
  table = Terminal::Table.new :headings => ['Test', 'Error'], :title => 'Warning Tests', :rows => rows, :style => {:width => 200}
  puts table
end