Class: Fukuzatsu::Formatters::Text
- Inherits:
-
Object
- Object
- Fukuzatsu::Formatters::Text
show all
- Includes:
- Base
- Defined in:
- lib/fukuzatsu/formatters/text.rb
Class Method Summary
collapse
Instance Method Summary
collapse
Methods included from Base
#filename, included, #initialize, #output_directory, #output_path, #path_to_results
Class Method Details
.reset_output_directory(args) ⇒ Object
12
13
|
# File 'lib/fukuzatsu/formatters/text.rb', line 12
def self.reset_output_directory(args)
end
|
.writes_to_file_system? ⇒ Boolean
15
16
17
|
# File 'lib/fukuzatsu/formatters/text.rb', line 15
def self.writes_to_file_system?
false
end
|
Instance Method Details
#color_for(entity, average_complexity) ⇒ Object
19
20
21
22
23
24
|
# File 'lib/fukuzatsu/formatters/text.rb', line 19
def color_for(entity, average_complexity)
return :green if entity.complexity == 0
return :yellow if entity.complexity <= average_complexity
return :red if entity.complexity > average_complexity
return :white
end
|
#export ⇒ Object
30
31
32
33
34
35
36
37
38
|
# File 'lib/fukuzatsu/formatters/text.rb', line 30
def export
table = Terminal::Table.new(
title: "#{summary.source_file}".color(:white),
headings: ,
rows: rows,
)
table.align_column(3, :right)
puts table
end
|
26
27
28
|
# File 'lib/fukuzatsu/formatters/text.rb', line 26
def
["Class/Module", "Method", "Complexity"]
end
|
#rows ⇒ Object
40
41
42
43
44
45
|
# File 'lib/fukuzatsu/formatters/text.rb', line 40
def rows
rows_for(
[self.summary, self.summary.summaries].flatten,
self.summary.average_complexity
)
end
|
#rows_for(summaries, average_complexity) ⇒ Object
47
48
49
50
51
52
53
54
55
56
|
# File 'lib/fukuzatsu/formatters/text.rb', line 47
def rows_for(summaries, average_complexity)
summaries.map do |summary|
color = color_for(summary, average_complexity)
[
wrap("#{summary.container_name}").color(color),
wrap("#{summary.entity_name}".color(color)),
"#{summary.complexity}".color(color)
]
end.compact
end
|
#wrap(string) ⇒ Object
58
59
60
61
|
# File 'lib/fukuzatsu/formatters/text.rb', line 58
def wrap(string)
return string if string.length < 50
string[0..49] << "..."
end
|