Class: Kanrisuru::Core::Yum::Parser::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/kanrisuru/core/yum/parsers/base.rb

Direct Known Subclasses

Info, List, Repolist, Search

Class Method Summary collapse

Class Method Details

.extract_single_yum_line(line) ⇒ Object



9
10
11
12
# File 'lib/kanrisuru/core/yum/parsers/base.rb', line 9

def extract_single_yum_line(line)
  values = line.split(': ', 2)
  values.length == 2 ? values[1] : ''
end

.parse_yum_line(line) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/kanrisuru/core/yum/parsers/base.rb', line 14

def parse_yum_line(line)
  values = line.split
  return if values.length != 3
  return unless /^\w+\.\w+$/i.match(values[0])

  full_name = values[0]
  version = values[1]

  name, architecture = full_name.split('.')

  Kanrisuru::Core::Yum::PackageOverview.new(name, architecture, version)
end