Class: Zypper::Upgraderepo::View::Table

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

Overview

Table style output.

Class Method Summary collapse

Class Method Details

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



155
156
157
158
159
# File 'lib/zypper/upgraderepo/view.rb', line 155

def self.alternative(num, repo, max_col, alt)
  Messages.error("| #{num.to_s.rjust(2)} | #{repo.name.ljust(max_col, " ")} " \
                 "| #{repo.enabled? ? " Y " : " N ".yellow} | #{alt[:message].bold.yellow}")
  puts " #{" " * 3} | #{" " * 2} | #{" " * max_col} | #{" " * 3} | #{alt[:url]}" unless alt[:url].to_s.empty?
end

.available(num, repo, max_col) ⇒ Object



129
130
131
132
133
134
135
136
137
# File 'lib/zypper/upgraderepo/view.rb', line 129

def self.available(num, repo, max_col)
  if repo.unversioned? && repo.old_url
    Messages.ok("| #{num.to_s.rjust(2)} | #{repo.name.ljust(max_col, " ")} " \
                "| #{repo.enabled? ? " Y " : " N ".yellow} | Unversioned repository")
  else
    Messages.ok("| #{num.to_s.rjust(2)} | #{repo.name.ljust(max_col, " ")} " \
                "| #{repo.enabled? ? " Y " : " N ".yellow} |")
  end
end


220
221
222
# File 'lib/zypper/upgraderepo/view.rb', line 220

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

.duplicates_header(max_col) ⇒ Object



210
211
212
# File 'lib/zypper/upgraderepo/view.rb', line 210

def self.duplicates_header(max_col)
  puts " St. |  # | #{"Name".ljust(max_col, " ")} | En. | Details"
end

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



214
215
216
217
218
# File 'lib/zypper/upgraderepo/view.rb', line 214

def self.duplicates_item(num, dnum, dcount, repo, max_col)
  Messages.warning("| #{num.to_s.rjust(2)} | #{repo.name.ljust(max_col, " ")} " \
                   "| #{repo.enabled? ? " Y " : " N ".yellow} " \
                   "| Duplicate n.#{dnum.to_s.bold}/#{dcount.to_s.bold} ")
end


190
191
192
# File 'lib/zypper/upgraderepo/view.rb', line 190

def self.footer(max_col)
  separator max_col
end

.forbidden(num, repo, max_col) ⇒ Object



150
151
152
153
# File 'lib/zypper/upgraderepo/view.rb', line 150

def self.forbidden(num, repo, max_col)
  Messages.error("| #{num.to_s.rjust(2)} | #{repo.name.ljust(max_col, " ")} " \
                 "| #{repo.enabled? ? " Y " : " N ".yellow} | #{"Forbidden path".bold.red}")
end

.header(max_col, upgrade: false) ⇒ Object



186
187
188
# File 'lib/zypper/upgraderepo/view.rb', line 186

def self.header(max_col, upgrade: false)
  puts " St. |  # | #{"Name".ljust(max_col, " ")} | En. | #{upgrade ? "Details" : "Hint"}"
end

.not_found(num, repo, max_col) ⇒ Object



145
146
147
148
# File 'lib/zypper/upgraderepo/view.rb', line 145

def self.not_found(num, repo, max_col)
  Messages.error("| #{num.to_s.rjust(2)} | #{repo.name.ljust(max_col, " ")} " \
                 "| #{repo.enabled? ? " Y " : " N ".yellow} | #{"Not Found".bold.red}")
end

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



139
140
141
142
143
# File 'lib/zypper/upgraderepo/view.rb', line 139

def self.redirected(num, repo, max_col, redirected)
  Messages.warning("| #{num.to_s.rjust(2)} | #{repo.name.ljust(max_col, " ")} " \
                   "| #{repo.enabled? ? " Y " : " N ".yellow} | #{"Redirection".bold.yellow} of #{repo.url} ")
  puts " #{" " * 3} | #{" " * 2} | #{" " * max_col} | #{" " * 3} | #{"To:".bold.yellow} #{redirected}"
end

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



182
183
184
# File 'lib/zypper/upgraderepo/view.rb', line 182

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

.server_error(num, repo, max_col) ⇒ Object



177
178
179
180
# File 'lib/zypper/upgraderepo/view.rb', line 177

def self.server_error(num, repo, max_col)
  Messages.error("| #{num.to_s.rjust(2)} | #{repo.name.ljust(max_col, " ")} " \
                 "| #{repo.enabled? ? " Y " : " N ".yellow} | #{"Error:".bold.red} #{repo.status}")
end

.status(os_release) ⇒ Object



194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
# File 'lib/zypper/upgraderepo/view.rb', line 194

def self.status(os_release)
  puts "---------------------------------------------------"
  puts " System releases based on #{os_release.fullname.bold}"
  puts "---------------------------------------------------"
  puts " Current |  Next  |  Last  | Available"
  puts "--------------------------------------------------"
  puts "   #{os_release.current}  " \
       "|  #{os_release.seniority.positive? ? os_release.next.bold.green : " -  "}  " \
       "|  #{os_release.last.send(os_release.unstable ? :red : :clean)}  " \
       "| #{os_release.seniority.positive? ? os_release.newer.join(", ") : "-"}"
  puts "--------------------------------------------------"
  return unless os_release.unstable

  Messages.warning "The #{"last".bold.red} version should be considered #{"Unstable".bold.red}"
end

.timeout(num, repo, max_col) ⇒ Object



161
162
163
164
# File 'lib/zypper/upgraderepo/view.rb', line 161

def self.timeout(num, repo, max_col)
  Messages.error("| #{num.to_s.rjust(2)} | #{repo.name.ljust(max_col, " ")} " \
                 "| #{repo.enabled? ? " Y " : " N ".yellow} | #{"Server Timeout".bold.yellow}")
end

.untouched(num, repo, max_col) ⇒ Object



172
173
174
175
# File 'lib/zypper/upgraderepo/view.rb', line 172

def self.untouched(num, repo, max_col)
  Messages.warning("| #{num.to_s.rjust(2)} | #{repo.name.ljust(max_col, " ")} " \
                   "| #{repo.enabled? ? " Y " : " N ".yellow} | #{"Untouched:".bold.yellow} #{repo.old_url}")
end


234
235
236
# File 'lib/zypper/upgraderepo/view.rb', line 234

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

.unused_header(max_col) ⇒ Object



224
225
226
# File 'lib/zypper/upgraderepo/view.rb', line 224

def self.unused_header(max_col)
  puts " St. |  # | #{"Name".ljust(max_col, " ")} | En. | Details"
end

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



228
229
230
231
232
# File 'lib/zypper/upgraderepo/view.rb', line 228

def self.unused_item(num, unum, repo, max_col)
  Messages.warning("| #{num.to_s.rjust(2)} | #{repo.name.ljust(max_col, " ")} " \
                   "| #{repo.enabled? ? " Y " : " N ".yellow} " \
                   "| Unused n.#{unum.to_s.bold}")
end

.upgraded(num, repo, max_col) ⇒ Object



166
167
168
169
170
# File 'lib/zypper/upgraderepo/view.rb', line 166

def self.upgraded(num, repo, max_col)
  Messages.ok("| #{num.to_s.rjust(2)} | #{repo.name.ljust(max_col, " ")} " \
              "| #{repo.enabled? ? " Y " : " N ".yellow} | #{"From:".bold.green} #{repo.old_url}")
  puts " #{" " * 3} | #{" " * 2} | #{" " * max_col} | #{" " * 3} | #{"To:".bold.green} #{repo.url}"
end