Class: Zypper::Upgraderepo::View::Report

Inherits:
Object
  • Object
show all
Defined in:
lib/zypper/upgraderepo/view.rb

Overview

Report style output.

Class Method Summary collapse

Class Method Details

.alternative(num, repo, _max_col, alt) ⇒ Object



32
33
34
35
36
37
# File 'lib/zypper/upgraderepo/view.rb', line 32

def self.alternative(num, repo, _max_col, alt)
  puts " #{num.to_s.rjust(2).bold.red} | Status: #{"Not Found".bold.red}"
  puts " #{" " * 2} | Hint: #{alt[:message].bold.yellow}"
  puts " #{" " * 2} | #{"Suggested:".bold.yellow} #{alt[:url]}" unless alt[:url].to_s.empty?
  info(repo)
end

.available(num, repo, _max_col) ⇒ Object



10
11
12
13
14
# File 'lib/zypper/upgraderepo/view.rb', line 10

def self.available(num, repo, _max_col)
  puts " #{num.to_s.rjust(2).bold.green} | Status: #{"Ok".bold.green}"
  puts " #{" " * 2} | Hint: Unversioned repository" if repo.unversioned? && repo.old_url
  info(repo)
end


104
105
106
# File 'lib/zypper/upgraderepo/view.rb', line 104

def self.duplicates_footer(dcount, total)
  puts "Total duplicated repositories: #{dcount.to_s.bold.yellow}/#{total}"
end

.duplicates_header(_max_col) ⇒ Object



95
96
97
# File 'lib/zypper/upgraderepo/view.rb', line 95

def self.duplicates_header(_max_col)
  puts "  # | Duplicated repositories"
end

.duplicates_item(num, dnum, dcount, repo, _max_col) ⇒ Object



99
100
101
102
# File 'lib/zypper/upgraderepo/view.rb', line 99

def self.duplicates_item(num, dnum, dcount, repo, _max_col)
  puts " #{num.to_s.rjust(2).bold.yellow} | Duplicated repository n.#{dnum.to_s.bold}/#{dcount.to_s.bold}"
  info(repo)
end


68
69
70
# File 'lib/zypper/upgraderepo/view.rb', line 68

def self.footer(max_col)
  separator max_col
end

.forbidden(num, repo, _max_col) ⇒ Object



27
28
29
30
# File 'lib/zypper/upgraderepo/view.rb', line 27

def self.forbidden(num, repo, _max_col)
  puts " #{num.to_s.rjust(2).bold.red} | Status: #{"Forbidden Path".bold.red}"
  info(repo)
end

.header(_max_col, _upgrade: false) ⇒ Object



64
65
66
# File 'lib/zypper/upgraderepo/view.rb', line 64

def self.header(_max_col, _upgrade: false)
  puts "  # | Report"
end

.info(repo) ⇒ Object



85
86
87
88
89
90
91
92
93
# File 'lib/zypper/upgraderepo/view.rb', line 85

def self.info(repo)
  puts " #{" " * 2} | Name: #{repo.name} #{repo.upgraded?(:name) ? "(#{repo.old_name.yellow})" : ""}"
  puts " #{" " * 2} | Alias: #{repo.alias} #{repo.upgraded?(:alias) ? "(#{repo.old_alias.yellow})" : ""}"
  puts " #{" " * 2} | Url: #{repo.url}"
  puts " #{" " * 2} |      (#{repo.old_url.yellow})" if repo.upgraded?
  puts " #{" " * 2} | Priority: #{repo.priority}"
  puts " #{" " * 2} | #{repo.enabled? ? "Enabled: Yes" : "Enabled: No".yellow}"
  puts " #{" " * 2} | Filename: #{repo.filename}"
end

.not_found(num, repo, _max_col) ⇒ Object



22
23
24
25
# File 'lib/zypper/upgraderepo/view.rb', line 22

def self.not_found(num, repo, _max_col)
  puts " #{num.to_s.rjust(2).bold.red} | Status: #{"Not Found".bold.red}"
  info(repo)
end

.redirected(num, repo, _max_col, redirected) ⇒ Object



16
17
18
19
20
# File 'lib/zypper/upgraderepo/view.rb', line 16

def self.redirected(num, repo, _max_col, redirected)
  puts " #{num.to_s.rjust(2).bold.yellow} | Status: #{"Redirected".bold.yellow}"
  puts " #{" " * 2} | #{"To:".bold.yellow} #{redirected}"
  info(repo)
end

.separator(max_col, char = "-", color = :none) ⇒ Object



60
61
62
# File 'lib/zypper/upgraderepo/view.rb', line 60

def self.separator(max_col, char = "-", color = :none)
  puts (char * (max_col + 20)).send(color)
end

.server_error(num, repo, _max_col) ⇒ Object



54
55
56
57
58
# File 'lib/zypper/upgraderepo/view.rb', line 54

def self.server_error(num, repo, _max_col)
  puts " #{num.to_s.rjust(2).bold.red} | Status: #{"Server Error".bold.red}"
  puts " #{" " * 2} | Hint: #{repo.status}"
  info(repo)
end

.status(os_release) ⇒ Object



72
73
74
75
76
77
78
79
80
81
82
83
# File 'lib/zypper/upgraderepo/view.rb', line 72

def self.status(os_release)
  color = os_release.seniority.zero? ? :green : :yellow
  puts "----------------------------------------------"
  puts "Full name       | #{os_release.fullname.bold}"
  puts "----------------------------------------------"
  puts "Current release | #{os_release.current.send(color)}"
  puts "Next release    | #{os_release.seniority.positive? ? os_release.next.bold.green : "-"}"
  puts "Last release    | #{os_release.last.send(os_release.unstable ? :red : :clean)} " \
       "(#{os_release.unstable ? "Unstable".bold.red : "Stable".bold.green})"
  puts "Available       | #{os_release.seniority.positive? ? os_release.newer.map(&:bold).join(", ") : "-"}"
  puts "----------------------------------------------"
end

.timeout(num, repo, _max_col) ⇒ Object



39
40
41
42
# File 'lib/zypper/upgraderepo/view.rb', line 39

def self.timeout(num, repo, _max_col)
  puts " #{num.to_s.rjust(2).bold.yellow} | Status: #{"Server Timeout".bold.yellow}"
  info(repo)
end

.untouched(num, repo, _max_col) ⇒ Object



49
50
51
52
# File 'lib/zypper/upgraderepo/view.rb', line 49

def self.untouched(num, repo, _max_col)
  puts " #{num.to_s.rjust(2).bold.yellow} | #{"Untouched".bold.yellow}"
  info(repo)
end


117
118
119
# File 'lib/zypper/upgraderepo/view.rb', line 117

def self.unused_footer(ucount, total)
  puts "Total unused repositories: #{ucount.to_s.bold.yellow}/#{total}"
end

.unused_header(_max_col) ⇒ Object



108
109
110
# File 'lib/zypper/upgraderepo/view.rb', line 108

def self.unused_header(_max_col)
  puts "  # | Unused repositories"
end

.unused_item(num, unum, repo, _max_col) ⇒ Object



112
113
114
115
# File 'lib/zypper/upgraderepo/view.rb', line 112

def self.unused_item(num, unum, repo, _max_col)
  puts " #{num.to_s.rjust(2).bold.yellow} | Unused repository n.#{unum.to_s.bold}"
  info(repo)
end

.upgraded(num, repo, _max_col) ⇒ Object



44
45
46
47
# File 'lib/zypper/upgraderepo/view.rb', line 44

def self.upgraded(num, repo, _max_col)
  puts " #{num.to_s.rjust(2).bold.green} | #{"Upgraded".bold.green}"
  info(repo)
end