Class: Kanrisuru::Core::Apt::Parser::Base

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

Direct Known Subclasses

List, Search, Show

Class Method Summary collapse

Class Method Details

.extract_single_line(line) ⇒ Object



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

def extract_single_line(line)
  line.split(': ')[1]
end

.parse_apt_line(line) ⇒ Object



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/kanrisuru/core/apt/parsers/base.rb', line 22

def parse_apt_line(line)
  values = line.split('/')
  return if values.length < 2

  package = values[0]

  values = values[1].split
  suites = values[0].split(',')
  version = values[1]
  architecture = values[2]

  installed = false
  upgradeable = false
  automatic = false

  if values.length > 3
    installed = values[3].include?('installed')
    upgradeable = values[3].include?('upgradeable')
    automatic = values[3].include?('automatic')
  end

  Kanrisuru::Core::Apt::PackageOverview.new(package, version, suites, architecture, installed, upgradeable,
                                            automatic)
end

.parse_apt_sources(string) ⇒ Object



17
18
19
20
# File 'lib/kanrisuru/core/apt/parsers/base.rb', line 17

def parse_apt_sources(string)
  url, dist, architecture, = string.split
  Kanrisuru::Core::Apt::Source.new(url, dist, architecture)
end

.parse_comma_values(string) ⇒ Object



13
14
15
# File 'lib/kanrisuru/core/apt/parsers/base.rb', line 13

def parse_comma_values(string)
  string.split(', ')
end