Class: CodeownersValidator::Parser
- Inherits:
-
Object
- Object
- CodeownersValidator::Parser
- Defined in:
- lib/codeowners_validator/parser.rb
Instance Method Summary collapse
-
#initialize(lines) ⇒ Parser
constructor
A new instance of Parser.
- #parse ⇒ Object
Constructor Details
#initialize(lines) ⇒ Parser
Returns a new instance of Parser.
7 8 9 |
# File 'lib/codeowners_validator/parser.rb', line 7 def initialize(lines) @lines = lines end |
Instance Method Details
#parse ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/codeowners_validator/parser.rb', line 11 def parse @lines.each.with_index(1).with_object([]) do |(line, line_number), entries| stripped = line.strip next if stripped.empty? || stripped.start_with?("#") pattern, owners, comment = split_line(stripped) entries << CodeownersEntry.new( raw: stripped, pattern:, owners:, comment:, line_number: ) end end |