Class: Exercism::Analyzers::Tab
- Inherits:
-
Analyzer
- Object
- Analyzer
- Exercism::Analyzers::Tab
show all
- Defined in:
- lib/exercism-analysis/analyzers/ruby/tab.rb
Constant Summary
collapse
- TAB_REGEX =
/\A\s*\t+\s*\b/
- SPACE_REGEX =
/\A\t* \t*\b/
Instance Attribute Summary
Attributes inherited from Analyzer
#adapter, #processor
Instance Method Summary
collapse
Methods inherited from Analyzer
#initialize, #lines, #padding, processor, #with_tempfile
Instance Method Details
#call ⇒ Object
9
10
11
|
# File 'lib/exercism-analysis/analyzers/ruby/tab.rb', line 9
def call
Result.new(:indentation, feedback)
end
|
#feedback ⇒ Object
13
14
15
16
17
|
# File 'lib/exercism-analysis/analyzers/ruby/tab.rb', line 13
def feedback
feedback_lines_with_type.take(1).map do |(line, line_no), type|
Feedback.from_line(type, line.chomp, line_no)
end
end
|
#feedback_lines_with_type ⇒ Object
19
20
21
|
# File 'lib/exercism-analysis/analyzers/ruby/tab.rb', line 19
def feedback_lines_with_type
lines_with_tabs_and_spaces.zip([:tab_and_space]) + lines_with_tabs.zip([:tab])
end
|
#lines_with_tabs ⇒ Object
23
24
25
26
27
|
# File 'lib/exercism-analysis/analyzers/ruby/tab.rb', line 23
def lines_with_tabs
lines.select do |line, _|
line =~ TAB_REGEX
end
end
|
#lines_with_tabs_and_spaces ⇒ Object
29
30
31
32
33
|
# File 'lib/exercism-analysis/analyzers/ruby/tab.rb', line 29
def lines_with_tabs_and_spaces
lines_with_tabs.select do |line, _|
line =~ SPACE_REGEX
end
end
|