Class: Goodcheck::Reporters::Text
- Inherits:
-
Object
- Object
- Goodcheck::Reporters::Text
- Defined in:
- lib/goodcheck/reporters/text.rb
Instance Attribute Summary collapse
-
#stdout ⇒ Object
readonly
Returns the value of attribute stdout.
Instance Method Summary collapse
- #analysis ⇒ Object
- #file(path) ⇒ Object
-
#initialize(stdout:) ⇒ Text
constructor
A new instance of Text.
- #issue(issue) ⇒ Object
- #rule(rule) ⇒ Object
Constructor Details
#initialize(stdout:) ⇒ Text
Returns a new instance of Text.
6 7 8 |
# File 'lib/goodcheck/reporters/text.rb', line 6 def initialize(stdout:) @stdout = stdout end |
Instance Attribute Details
#stdout ⇒ Object (readonly)
Returns the value of attribute stdout.
4 5 6 |
# File 'lib/goodcheck/reporters/text.rb', line 4 def stdout @stdout end |
Instance Method Details
#analysis ⇒ Object
10 11 12 |
# File 'lib/goodcheck/reporters/text.rb', line 10 def analysis yield end |
#file(path) ⇒ Object
14 15 16 |
# File 'lib/goodcheck/reporters/text.rb', line 14 def file(path) yield end |
#issue(issue) ⇒ Object
22 23 24 25 26 27 28 29 30 31 |
# File 'lib/goodcheck/reporters/text.rb', line 22 def issue(issue) line = issue.buffer.line(issue.location.start_line).chomp end_column = if issue.location.start_line == issue.location.end_line issue.location.end_column else line.bytesize end colored_line = line.byteslice(0, issue.location.start_column) + Rainbow(line.byteslice(issue.location.start_column, end_column - issue.location.start_column)).red + line.byteslice(end_column, line.bytesize - end_column) stdout.puts "#{issue.path}:#{issue.location.start_line}:#{colored_line}:\t#{issue.rule..lines.first.chomp}" end |
#rule(rule) ⇒ Object
18 19 20 |
# File 'lib/goodcheck/reporters/text.rb', line 18 def rule(rule) yield end |