Class: Rupert::Parser

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

Instance Method Summary collapse

Constructor Details

#initialize(raw_io) ⇒ Parser

Returns a new instance of Parser.



7
8
9
# File 'lib/rupert/parser.rb', line 7

def initialize(raw_io)
  @raw_io = raw_io
end

Instance Method Details

#parseObject



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/rupert/parser.rb', line 11

def parse
  # TODO Fit to current design (i.e. no parsing in Lead c'tor?)
  lead = RPM::Lead.new(@raw_io)

  signature = signature_from(parse_index(@raw_io))

  # TODO I'd like to get rid of this duplication, but still don't know how.
  # Ideally, raw signed content should be available from both archive and
  # header, and concatenated to calculate checksum.
  content = parse_content @raw_io
  @raw_io.seek(-content.length, IO::SEEK_CUR)

  header = header_from(parse_index(@raw_io))

  RPM.new(lead, signature, content, header)
end