Class: LicenseFinder::ConanInfoParser

Inherits:
Object
  • Object
show all
Defined in:
lib/license_finder/package_utils/conan_info_parser.rb

Instance Method Summary collapse

Instance Method Details

#parse(info) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/license_finder/package_utils/conan_info_parser.rb', line 5

def parse(info)
  @lines = info.lines.map(&:chomp)
  @state = :project_level # state of the state machine
  @projects = [] # list of projects
  @current_project = nil # current project being populated in the SM
  @current_vals = [] # current val list being populate in the SM
  @current_key = nil # current key to be associated with the current val
  while (line = @lines.shift)
    next if line == ''

    case @state
    when :project_level
      @current_project = {}
      @current_project['name'] = line.strip
      @state = :key_val
    when :key_val
      parse_key_val(line)
    when :val_list
      parse_val_list(line)
    end
  end
  wrap_up
end