Class: Yard::Lint::Validators::Documentation::DuplicateNamespaceComment::Parser
- Inherits:
-
Parsers::Base
- Object
- Parsers::Base
- Yard::Lint::Validators::Documentation::DuplicateNamespaceComment::Parser
- Defined in:
- lib/yard/lint/validators/documentation/duplicate_namespace_comment/parser.rb
Overview
Extracts duplicate namespace documentation offenses from raw collector output. Each line has the form "file:line: Namespace\tsite|site|...\tconflict" where conflict is either 'same' or 'differ'.
Constant Summary collapse
- LINE_REGEX =
Parses the "file:line: Namespace" head of an offense line. The namespace path uses '::' and never ': ', so the final ": " is an unambiguous separator.
/\A(.+):(\d+): (.+)\z/
Instance Method Summary collapse
-
#call(output) ⇒ Array<Hash>
Offense hashes with location/line/namespace/sites/conflict.
Methods inherited from Parsers::Base
Instance Method Details
#call(output) ⇒ Array<Hash>
Returns offense hashes with location/line/namespace/sites/conflict.
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/yard/lint/validators/documentation/duplicate_namespace_comment/parser.rb', line 20 def call(output) return [] if output.nil? || output.empty? output.split("\n").filter_map do |line| head, sites, conflict = line.split("\t") next unless head match = head.match(LINE_REGEX) next unless match { location: match[1], line: match[2].to_i, namespace: match[3], sites: (sites || '').split('|'), conflict: conflict } end end |