Class: Henitai::MutationSkipDirectives::IndexBuilder
- Inherits:
-
Object
- Object
- Henitai::MutationSkipDirectives::IndexBuilder
- Defined in:
- lib/henitai/mutation_skip_directives.rb
Overview
Accumulates classified directives for one file, tracking open disable-start regions and raising on malformed directive usage.
Instance Method Summary collapse
- #index ⇒ Object
-
#initialize(path) ⇒ IndexBuilder
constructor
A new instance of IndexBuilder.
- #record(comment, standalone:) ⇒ Object
Constructor Details
#initialize(path) ⇒ IndexBuilder
Returns a new instance of IndexBuilder.
129 130 131 132 133 134 135 136 |
# File 'lib/henitai/mutation_skip_directives.rb', line 129 def initialize(path) @path = path @trailing = {} @standalone = {} @regions = [] @standalone_comment_lines = Set.new @open_region = nil end |
Instance Method Details
#index ⇒ Object
147 148 149 150 151 152 153 154 155 156 |
# File 'lib/henitai/mutation_skip_directives.rb', line 147 def index ensure_all_regions_closed! Index.new( trailing: @trailing.freeze, standalone: @standalone.freeze, regions: @regions.freeze, standalone_comment_lines: @standalone_comment_lines.freeze ) end |
#record(comment, standalone:) ⇒ Object
138 139 140 141 142 143 144 145 |
# File 'lib/henitai/mutation_skip_directives.rb', line 138 def record(comment, standalone:) line = comment.location.start_line @standalone_comment_lines << line if standalone match = DIRECTIVE.match(comment.slice) return unless match dispatch(match, line, standalone) end |