Method: MarketplaceRepository#parse

Defined in:
lib/ovfparse/marketplace_repository.rb

#parse(raw_html) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/ovfparse/marketplace_repository.rb', line 6

def parse (raw_html) 
  file_list = Array.new
  
  xml = Nokogiri::XML(raw_html) do |config|
    config.noblanks.strict.noent
  end

  entries = xml.root.children.select { |element| element.name == 'entry' }

  entries.each { |entry|
     repository = entry.children.detect { |element| element.name == 'repository' }
     basepath = repository.children.detect { |element| element.name == 'basepath' }
     filename = repository.children.detect { |element| element.name == 'filename' }

     file_list.push( {'basepath' => basepath.content, 'filename' => filename.content} )
  }

  return file_list
end