Class: RepomdParser::DeltainfoXmlParser

Inherits:
BaseParser
  • Object
show all
Defined in:
lib/repomd_parser/deltainfo_xml_parser.rb

Overview

repomd_parser – Ruby gem to parse RPM repository metadata Copyright © 2018 Ivan Kapelyukhin, SUSE Linux GmbH

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.

Instance Method Summary collapse

Methods inherited from BaseParser

#parse, #parse_file

Instance Method Details

#characters(string) ⇒ Object



34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/repomd_parser/deltainfo_xml_parser.rb', line 34

def characters(string)
  case @current_node
  when :filename
    @delta[:location] ||= ''
    @delta[:location] += string.strip
  when :checksum
    @delta[:checksum] ||= ''
    @delta[:checksum] += string.strip
  when :size
    @delta[:size] ||= ''
    @delta[:size] += string.strip
  end
end

#end_element(name) ⇒ Object



48
49
50
51
52
53
54
55
56
57
58
59
# File 'lib/repomd_parser/deltainfo_xml_parser.rb', line 48

def end_element(name)
  return unless name == 'delta'

  @referenced_files << RepomdParser::Reference.new(
    location: @delta[:location],
    checksum_type: @delta[:checksum_type],
    checksum: @delta[:checksum],
    type: :drpm,
    size: @delta[:size].to_i,
    arch: @package[:arch]
  )
end

#start_element(name, attrs = []) ⇒ Object



19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/repomd_parser/deltainfo_xml_parser.rb', line 19

def start_element(name, attrs = [])
  @current_node = name.to_sym
  case name
  when 'newpackage'
    @package = {}
    @package[:version] = get_attribute(attrs, 'version')
    @package[:name] = get_attribute(attrs, 'name')
    @package[:arch] = get_attribute(attrs, 'arch')
  when 'delta'
    @delta = {}
  when 'checksum'
    @delta[:checksum_type] = get_attribute(attrs, 'type')
  end
end