Class: CucumberLint::LintedFile
- Inherits:
-
Object
- Object
- CucumberLint::LintedFile
- Defined in:
- lib/cucumber_lint/linted_file.rb
Overview
A class that represents a file being linted
Instance Attribute Summary collapse
-
#content ⇒ Object
readonly
Returns the value of attribute content.
-
#errors ⇒ Object
readonly
Returns the value of attribute errors.
-
#lines ⇒ Object
readonly
Returns the value of attribute lines.
Instance Method Summary collapse
- #add_error(error) ⇒ Object
- #add_fix(line_number, fix) ⇒ Object
-
#initialize(path) ⇒ LintedFile
constructor
A new instance of LintedFile.
- #mark_for_deletion ⇒ Object
- #resolve ⇒ Object
Constructor Details
#initialize(path) ⇒ LintedFile
Returns a new instance of LintedFile.
9 10 11 12 13 14 15 16 17 |
# File 'lib/cucumber_lint/linted_file.rb', line 9 def initialize path @path = Pathname.new path @content = IO.read path @lines = @content.lines @errors = [] @fixes = {} @marked_for_deletion = false end |
Instance Attribute Details
#content ⇒ Object (readonly)
Returns the value of attribute content.
7 8 9 |
# File 'lib/cucumber_lint/linted_file.rb', line 7 def content @content end |
#errors ⇒ Object (readonly)
Returns the value of attribute errors.
7 8 9 |
# File 'lib/cucumber_lint/linted_file.rb', line 7 def errors @errors end |
#lines ⇒ Object (readonly)
Returns the value of attribute lines.
7 8 9 |
# File 'lib/cucumber_lint/linted_file.rb', line 7 def lines @lines end |
Instance Method Details
#add_error(error) ⇒ Object
20 21 22 |
# File 'lib/cucumber_lint/linted_file.rb', line 20 def add_error error @errors << "#{@path}:#{error}" end |
#add_fix(line_number, fix) ⇒ Object
25 26 27 28 |
# File 'lib/cucumber_lint/linted_file.rb', line 25 def add_fix line_number, fix @fixes[line_number] ||= [] @fixes[line_number] += Array(fix) end |
#mark_for_deletion ⇒ Object
31 32 33 |
# File 'lib/cucumber_lint/linted_file.rb', line 31 def mark_for_deletion @marked_for_deletion = true end |
#resolve ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/cucumber_lint/linted_file.rb', line 36 def resolve if @marked_for_deletion delete :deleted elsif !errors.empty? || fixable? fix errors.empty? ? :written : :failed else :passed end end |