Class: LicenseFinder::ConanInfoParserV2

Inherits:
Object
  • Object
show all
Defined in:
lib/license_finder/package_utils/conan_info_parser_v2.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
28
29
30
31
32
# File 'lib/license_finder/package_utils/conan_info_parser_v2.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

  line = @lines.shift
  line = @lines.shift while line != '======== Basic graph information ========'

  while (line = @lines.shift)
    next if line == ''

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