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_file_failed_to_loadObject



33
34
35
# File 'lib/linter/report.rb', line 33

def has_a_file_failed_to_load
  !@files_failing_load.empty?
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
  failed = false
  @full_report.each do |test, status|
    if status[:status] == 'fail'
      failed = true
    end
  end
  failed
end

#make_fail_tableObject



71
72
73
74
75
76
77
78
79
80
# File 'lib/linter/report.rb', line 71

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



37
38
39
40
41
42
43
44
45
46
47
# File 'lib/linter/report.rb', line 37

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
  puts "*****************"
  puts "Check for property values that start with an interpolated value \nIf the first character of the value is a bracket yaml will fail to load \nPlace the value in quotes"
  puts "*****************"
end

#make_pass_tableObject



49
50
51
52
53
54
55
56
57
58
# File 'lib/linter/report.rb', line 49

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



60
61
62
63
64
65
66
67
68
69
# File 'lib/linter/report.rb', line 60

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