Class: Slither::Parser

Inherits:
Object
  • Object
show all
Defined in:
lib/slither/parser.rb

Instance Method Summary collapse

Constructor Details

#initialize(definition, file) ⇒ Parser

Returns a new instance of Parser.



4
5
6
7
8
9
# File 'lib/slither/parser.rb', line 4

def initialize(definition, file)
  @definition = definition
  @file = file
  # This may be used in the future for non-linear or repeating sections
  @mode = :linear
end

Instance Method Details

#parseObject



11
12
13
14
15
16
17
18
19
20
21
# File 'lib/slither/parser.rb', line 11

def parse()
  @parsed = {}
  @content = read_file      
  unless @content.empty?
    @definition.sections.each do |section|
      rows = fill_content(section)
      raise(Slither::RequiredSectionNotFoundError, "Required section '#{section.name}' was not found.") unless rows > 0 || section.optional
    end
  end
  @parsed
end