zypper-upgraderepo 1.8.1 → 1.10.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,143 +1,191 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Zypper
2
4
  module Upgraderepo
3
-
4
5
  module View
5
-
6
+ #
7
+ # Report style output.
8
+ #
6
9
  class Report
10
+ def self.available(num, repo, _max_col)
11
+ puts " #{num.to_s.rjust(2).bold.green} | Status: #{"Ok".bold.green}"
12
+ puts " #{" " * 2} | Hint: Unversioned repository" if repo.unversioned? && repo.old_url
13
+ info(repo)
14
+ end
7
15
 
8
- def self.available(num, repo, max_col)
9
- puts " #{num.to_s.rjust(2).bold.green} | Status: #{'Ok'.bold.green}"
10
- puts " #{' ' * 2} | Hint: Unversioned repository" if repo.unversioned? && repo.old_url
11
- self.info(repo)
16
+ def self.redirected(num, repo, _max_col, redirected)
17
+ puts " #{num.to_s.rjust(2).bold.yellow} | Status: #{"Redirected".bold.yellow}"
18
+ puts " #{" " * 2} | #{"To:".bold.yellow} #{redirected}"
19
+ info(repo)
12
20
  end
13
21
 
14
- def self.redirected(num, repo, max_col, redirected)
15
- puts " #{num.to_s.rjust(2).bold.yellow} | Status: #{'Redirected'.bold.yellow}"
16
- puts " #{' ' * 2} | #{'To:'.bold.yellow} #{redirected}"
17
- self.info(repo)
22
+ def self.not_found(num, repo, _max_col)
23
+ puts " #{num.to_s.rjust(2).bold.red} | Status: #{"Not Found".bold.red}"
24
+ info(repo)
18
25
  end
19
26
 
20
- def self.not_found(num, repo, max_col)
21
- puts " #{num.to_s.rjust(2).bold.red} | Status: #{'Not Found'.bold.red}"
22
- self.info(repo)
27
+ def self.forbidden(num, repo, _max_col)
28
+ puts " #{num.to_s.rjust(2).bold.red} | Status: #{"Forbidden Path".bold.red}"
29
+ info(repo)
23
30
  end
24
31
 
25
- def self.forbidden(num, repo, max_col)
26
- puts " #{num.to_s.rjust(2).bold.red} | Status: #{'Forbidden Path'.bold.red}"
27
- self.info(repo)
32
+ def self.alternative(num, repo, _max_col, alt)
33
+ puts " #{num.to_s.rjust(2).bold.red} | Status: #{"Not Found".bold.red}"
34
+ puts " #{" " * 2} | Hint: #{alt[:message].bold.yellow}"
35
+ puts " #{" " * 2} | #{"Suggested:".bold.yellow} #{alt[:url]}" unless alt[:url].to_s.empty?
36
+ info(repo)
28
37
  end
29
38
 
30
- def self.alternative(num, repo, max_col, alt)
31
- puts " #{num.to_s.rjust(2).bold.red} | Status: #{'Not Found'.bold.red}"
32
- puts " #{' ' * 2} | Hint: #{alt[:message].bold.yellow}"
33
- puts " #{' ' * 2} | #{'Suggested:'.bold.yellow} #{alt[:url]}" unless alt[:url].to_s.empty?
34
- self.info(repo)
39
+ def self.timeout(num, repo, _max_col)
40
+ puts " #{num.to_s.rjust(2).bold.yellow} | Status: #{"Server Timeout".bold.yellow}"
41
+ info(repo)
35
42
  end
36
43
 
37
- def self.timeout(num, repo, max_col)
38
- puts " #{num.to_s.rjust(2).bold.yellow} | Status: #{'Server Timeout'.bold.yellow}"
39
- self.info(repo)
44
+ def self.upgraded(num, repo, _max_col)
45
+ puts " #{num.to_s.rjust(2).bold.green} | #{"Upgraded".bold.green}"
46
+ info(repo)
40
47
  end
41
48
 
42
- def self.upgraded(num, repo, max_col)
43
- puts " #{num.to_s.rjust(2).bold.green} | #{'Upgraded'.bold.green}"
44
- self.info(repo)
49
+ def self.untouched(num, repo, _max_col)
50
+ puts " #{num.to_s.rjust(2).bold.yellow} | #{"Untouched".bold.yellow}"
51
+ info(repo)
45
52
  end
46
53
 
47
- def self.untouched(num, repo, max_col)
48
- puts " #{num.to_s.rjust(2).bold.yellow} | #{'Untouched'.bold.yellow}"
49
- self.info(repo)
54
+ def self.server_error(num, repo, _max_col)
55
+ puts " #{num.to_s.rjust(2).bold.red} | Status: #{"Server Error".bold.red}"
56
+ puts " #{" " * 2} | Hint: #{repo.status}"
57
+ info(repo)
50
58
  end
51
59
 
52
- def self.separator
53
- puts '-' * 90
60
+ def self.separator(max_col, char = "-", color = :none)
61
+ puts (char * (max_col + 20)).send(color)
54
62
  end
55
63
 
56
- def self.header(max_col, upgrade = false)
64
+ def self.header(_max_col, _upgrade: false)
57
65
  puts " # | Report"
58
66
  end
59
67
 
60
- def self.footer
61
- self.separator
68
+ def self.footer(max_col)
69
+ separator max_col
62
70
  end
63
71
 
64
72
  def self.status(os_release)
65
- color = os_release.seniority == 0 ? :green : :yellow
66
- puts '----------------------------------------------'
73
+ color = os_release.seniority.zero? ? :green : :yellow
74
+ puts "----------------------------------------------"
67
75
  puts "Full name | #{os_release.fullname.bold}"
68
- puts '----------------------------------------------'
76
+ puts "----------------------------------------------"
69
77
  puts "Current release | #{os_release.current.send(color)}"
70
- puts "Next release | #{os_release.seniority > 0 ? os_release.next.bold.green : '-'}"
71
- puts "Last release | #{os_release.last.send(os_release.unstable ? :red : :clean)} (#{os_release.unstable ? 'Unstable'.bold.red : 'Stable'.bold.green})"
72
- puts "Available | #{os_release.seniority > 0 ? os_release.newer.map{ |i| i.bold }.join(', ') : '-' }"
73
- puts '----------------------------------------------'
78
+ puts "Next release | #{os_release.seniority.positive? ? os_release.next.bold.green : "-"}"
79
+ puts "Last release | #{os_release.last.send(os_release.unstable ? :red : :clean)} " \
80
+ "(#{os_release.unstable ? "Unstable".bold.red : "Stable".bold.green})"
81
+ puts "Available | #{os_release.seniority.positive? ? os_release.newer.map(&:bold).join(", ") : "-"}"
82
+ puts "----------------------------------------------"
74
83
  end
75
84
 
76
- private
77
-
78
85
  def self.info(repo)
79
- puts " #{ ' ' * 2 } | Name: #{repo.name} #{repo.upgraded?(:name) ? '(' + repo.old_name.yellow + ')' : '' }"
80
- puts " #{ ' ' * 2 } | Alias: #{repo.alias} #{repo.upgraded?(:alias) ? '(' + repo.old_alias.yellow + ')' : ''}"
81
- puts " #{ ' ' * 2 } | Url: #{repo.url}"
82
- puts " #{ ' ' * 2 } | (#{repo.old_url.yellow})" if repo.upgraded?
83
- puts " #{ ' ' * 2 } | Priority: #{repo.priority}"
84
- puts " #{ ' ' * 2 } | #{repo.enabled? ? 'Enabled: Yes' : 'Enabled: No'.yellow}"
85
- puts " #{ ' ' * 2 } | Filename: #{repo.filename}"
86
+ puts " #{" " * 2} | Name: #{repo.name} #{repo.upgraded?(:name) ? "(#{repo.old_name.yellow})" : ""}"
87
+ puts " #{" " * 2} | Alias: #{repo.alias} #{repo.upgraded?(:alias) ? "(#{repo.old_alias.yellow})" : ""}"
88
+ puts " #{" " * 2} | Url: #{repo.url}"
89
+ puts " #{" " * 2} | (#{repo.old_url.yellow})" if repo.upgraded?
90
+ puts " #{" " * 2} | Priority: #{repo.priority}"
91
+ puts " #{" " * 2} | #{repo.enabled? ? "Enabled: Yes" : "Enabled: No".yellow}"
92
+ puts " #{" " * 2} | Filename: #{repo.filename}"
86
93
  end
87
- end
88
94
 
95
+ def self.duplicates_header(_max_col)
96
+ puts " # | Duplicated repositories"
97
+ end
89
98
 
90
- class Table
99
+ def self.duplicates_item(num, dnum, dcount, repo, _max_col)
100
+ puts " #{num.to_s.rjust(2).bold.yellow} | Duplicated repository n.#{dnum.to_s.bold}/#{dcount.to_s.bold}"
101
+ info(repo)
102
+ end
103
+
104
+ def self.duplicates_footer(dcount, total)
105
+ puts "Total duplicated repositories: #{dcount.to_s.bold.yellow}/#{total}"
106
+ end
107
+
108
+ def self.unused_header(_max_col)
109
+ puts " # | Unused repositories"
110
+ end
91
111
 
112
+ def self.unused_item(num, unum, repo, _max_col)
113
+ puts " #{num.to_s.rjust(2).bold.yellow} | Unused repository n.#{unum.to_s.bold}"
114
+ info(repo)
115
+ end
116
+
117
+ def self.unused_footer(ucount, total)
118
+ puts "Total unused repositories: #{ucount.to_s.bold.yellow}/#{total}"
119
+ end
120
+ end
121
+
122
+ #
123
+ # Table style output.
124
+ #
125
+ class Table
92
126
  def self.available(num, repo, max_col)
93
127
  if repo.unversioned? && repo.old_url
94
- Messages.ok("| #{num.to_s.rjust(2)} | #{repo.name.ljust(max_col, ' ')} | #{repo.enabled? ? ' Y ' : ' N '.yellow} | Unversioned repository")
128
+ Messages.ok("| #{num.to_s.rjust(2)} | #{repo.name.ljust(max_col, " ")} " \
129
+ "| #{repo.enabled? ? " Y " : " N ".yellow} | Unversioned repository")
95
130
  else
96
- Messages.ok("| #{num.to_s.rjust(2)} | #{repo.name.ljust(max_col, ' ')} | #{repo.enabled? ? ' Y ' : ' N '.yellow} |")
131
+ Messages.ok("| #{num.to_s.rjust(2)} | #{repo.name.ljust(max_col, " ")} " \
132
+ "| #{repo.enabled? ? " Y " : " N ".yellow} |")
97
133
  end
98
134
  end
99
135
 
100
136
  def self.redirected(num, repo, max_col, redirected)
101
- Messages.warning("| #{num.to_s.rjust(2)} | #{repo.name.ljust(max_col, ' ')} | #{repo.enabled? ? ' Y ' : ' N '.yellow} | #{'Redirection'.bold.yellow} of #{repo.url} ")
102
- puts " #{' ' * 3} | #{' ' * 2} | #{ ' ' * max_col} | #{ ' ' * 3 } | #{'To:'.bold.yellow} #{redirected}"
137
+ Messages.warning("| #{num.to_s.rjust(2)} | #{repo.name.ljust(max_col, " ")} " \
138
+ "| #{repo.enabled? ? " Y " : " N ".yellow} | #{"Redirection".bold.yellow} of #{repo.url} ")
139
+ puts " #{" " * 3} | #{" " * 2} | #{" " * max_col} | #{" " * 3} | #{"To:".bold.yellow} #{redirected}"
103
140
  end
104
141
 
105
142
  def self.not_found(num, repo, max_col)
106
- Messages.error("| #{num.to_s.rjust(2)} | #{repo.name.ljust(max_col, ' ')} | #{repo.enabled? ? ' Y ' : ' N '.yellow} | #{'Not Found'.bold.red}")
143
+ Messages.error("| #{num.to_s.rjust(2)} | #{repo.name.ljust(max_col, " ")} " \
144
+ "| #{repo.enabled? ? " Y " : " N ".yellow} | #{"Not Found".bold.red}")
107
145
  end
108
146
 
109
147
  def self.forbidden(num, repo, max_col)
110
- Messages.error("| #{num.to_s.rjust(2)} | #{repo.name.ljust(max_col, ' ')} | #{repo.enabled? ? ' Y ' : ' N '.yellow} | #{'Forbidden path'.bold.red}")
148
+ Messages.error("| #{num.to_s.rjust(2)} | #{repo.name.ljust(max_col, " ")} " \
149
+ "| #{repo.enabled? ? " Y " : " N ".yellow} | #{"Forbidden path".bold.red}")
111
150
  end
112
151
 
113
152
  def self.alternative(num, repo, max_col, alt)
114
- Messages.error("| #{num.to_s.rjust(2)} | #{repo.name.ljust(max_col, ' ')} | #{repo.enabled? ? ' Y ' : ' N '.yellow} | #{alt[:message].bold.yellow}")
115
- puts " #{' ' * 3} | #{' ' * 2} | #{' ' * max_col} | #{' ' * 3} | #{alt[:url]}" unless alt[:url].to_s.empty?
153
+ Messages.error("| #{num.to_s.rjust(2)} | #{repo.name.ljust(max_col, " ")} " \
154
+ "| #{repo.enabled? ? " Y " : " N ".yellow} | #{alt[:message].bold.yellow}")
155
+ puts " #{" " * 3} | #{" " * 2} | #{" " * max_col} | #{" " * 3} | #{alt[:url]}" unless alt[:url].to_s.empty?
116
156
  end
117
157
 
118
158
  def self.timeout(num, repo, max_col)
119
- Messages.error("| #{num.to_s.rjust(2)} | #{repo.name.ljust(max_col, ' ')} | #{repo.enabled? ? ' Y ' : ' N '.yellow} | #{'Server Timeout'.bold.yellow}")
159
+ Messages.error("| #{num.to_s.rjust(2)} | #{repo.name.ljust(max_col, " ")} " \
160
+ "| #{repo.enabled? ? " Y " : " N ".yellow} | #{"Server Timeout".bold.yellow}")
120
161
  end
121
162
 
122
- def self.upgraded(num, repo, max_col) #, old_data)
123
- Messages.ok("| #{num.to_s.rjust(2)} | #{repo.name.ljust(max_col, ' ')} | #{repo.enabled? ? ' Y ' : ' N '.yellow} | #{'From:'.bold.green} #{repo.old_url}")
124
- puts " #{' ' * 3} | #{' ' * 2} | #{' ' * max_col} | #{' ' * 3} | #{'To:'.bold.green} #{repo.url}"
163
+ def self.upgraded(num, repo, max_col)
164
+ Messages.ok("| #{num.to_s.rjust(2)} | #{repo.name.ljust(max_col, " ")} " \
165
+ "| #{repo.enabled? ? " Y " : " N ".yellow} | #{"From:".bold.green} #{repo.old_url}")
166
+ puts " #{" " * 3} | #{" " * 2} | #{" " * max_col} | #{" " * 3} | #{"To:".bold.green} #{repo.url}"
125
167
  end
126
168
 
127
169
  def self.untouched(num, repo, max_col)
128
- Messages.warning("| #{num.to_s.rjust(2)} | #{repo.name.ljust(max_col, ' ')} | #{repo.enabled? ? ' Y ' : ' N '.yellow} | #{'Untouched:'.bold.yellow} #{repo.old_url}")
170
+ Messages.warning("| #{num.to_s.rjust(2)} | #{repo.name.ljust(max_col, " ")} " \
171
+ "| #{repo.enabled? ? " Y " : " N ".yellow} | #{"Untouched:".bold.yellow} #{repo.old_url}")
129
172
  end
130
173
 
131
- def self.separator
132
- puts '-' * 90
174
+ def self.server_error(num, repo, max_col)
175
+ Messages.error("| #{num.to_s.rjust(2)} | #{repo.name.ljust(max_col, " ")} " \
176
+ "| #{repo.enabled? ? " Y " : " N ".yellow} | #{"Error:".bold.red} #{repo.status}")
133
177
  end
134
178
 
135
- def self.header(max_col, upgrade = false)
136
- puts " St. | # | #{'Name'.ljust(max_col, ' ')} | En. | #{upgrade ? 'Details' : 'Hint' }"
179
+ def self.separator(max_col, char = "-", color = :none)
180
+ puts (char * (max_col + 20)).send(color)
137
181
  end
138
182
 
139
- def self.footer
140
- self.separator
183
+ def self.header(max_col, upgrade: false)
184
+ puts " St. | # | #{"Name".ljust(max_col, " ")} | En. | #{upgrade ? "Details" : "Hint"}"
185
+ end
186
+
187
+ def self.footer(max_col)
188
+ separator max_col
141
189
  end
142
190
 
143
191
  def self.status(os_release)
@@ -146,123 +194,165 @@ module Zypper
146
194
  puts "---------------------------------------------------"
147
195
  puts " Current | Next | Last | Available"
148
196
  puts "--------------------------------------------------"
149
- puts " #{os_release.current} | #{os_release.seniority > 0 ? os_release.next.bold.green : ' - ' } | #{os_release.last.send(os_release.unstable ? :red : :clean)} | #{os_release.seniority > 0 ? os_release.newer.join(', ') : '-'}"
197
+ puts " #{os_release.current} " \
198
+ "| #{os_release.seniority.positive? ? os_release.next.bold.green : " - "} " \
199
+ "| #{os_release.last.send(os_release.unstable ? :red : :clean)} " \
200
+ "| #{os_release.seniority.positive? ? os_release.newer.join(", ") : "-"}"
150
201
  puts "--------------------------------------------------"
151
- Messages.warning "The #{'last'.bold.red} version should be considered #{'Unstable'.bold.red}" if os_release.unstable
152
- end
153
- end
154
-
155
-
156
- class Quiet
202
+ return unless os_release.unstable
157
203
 
158
- def self.available(num, repo, max_col)
204
+ Messages.warning "The #{"last".bold.red} version should be considered #{"Unstable".bold.red}"
159
205
  end
160
206
 
161
- def self.redirected(num, repo, max_col, redirected)
207
+ def self.duplicates_header(max_col)
208
+ puts " St. | # | #{"Name".ljust(max_col, " ")} | En. | Details"
162
209
  end
163
210
 
164
- def self.not_found(num, repo, max_col)
211
+ def self.duplicates_item(num, dnum, dcount, repo, max_col)
212
+ Messages.warning("| #{num.to_s.rjust(2)} | #{repo.name.ljust(max_col, " ")} " \
213
+ "| #{repo.enabled? ? " Y " : " N ".yellow} " \
214
+ "| Duplicate n.#{dnum.to_s.bold}/#{dcount.to_s.bold} ")
165
215
  end
166
216
 
167
- def self.forbidden(num, repo, max_col)
217
+ def self.duplicates_footer(dcount, total)
218
+ puts "Total duplicated repositories: #{dcount.to_s.bold.yellow}/#{total}"
168
219
  end
169
220
 
170
- def self.alternative(num, repo, max_col, alt)
221
+ def self.unused_header(max_col)
222
+ puts " St. | # | #{"Name".ljust(max_col, " ")} | En. | Details"
171
223
  end
172
224
 
173
- def self.timeout(num, repo, max_col)
225
+ def self.unused_item(num, unum, repo, max_col)
226
+ Messages.warning("| #{num.to_s.rjust(2)} | #{repo.name.ljust(max_col, " ")} " \
227
+ "| #{repo.enabled? ? " Y " : " N ".yellow} " \
228
+ "| Unused n.#{unum.to_s.bold}")
174
229
  end
175
230
 
176
- def self.upgraded(num, repo, max_col) #, old_data)
231
+ def self.unused_footer(ucount, total)
232
+ puts "Total unused repositories: #{ucount.to_s.bold.yellow}/#{total}"
177
233
  end
234
+ end
178
235
 
179
- def self.untouched(num, repo, max_col)
180
- end
236
+ #
237
+ # Quiet style output.
238
+ #
239
+ class Quiet
240
+ def self.available(num, repo, max_col); end
181
241
 
182
- def self.separator
183
- end
242
+ def self.redirected(num, repo, max_col, redirected); end
243
+
244
+ def self.not_found(num, repo, max_col); end
245
+
246
+ def self.forbidden(num, repo, max_col); end
247
+
248
+ def self.alternative(num, repo, max_col, alt); end
249
+
250
+ def self.timeout(num, repo, max_col); end
251
+
252
+ def self.upgraded(num, repo, max_col); end
253
+
254
+ def self.untouched(num, repo, max_col); end
255
+
256
+ def self.server_error(num, repo, max_col); end
257
+
258
+ def self.separator(_max_col, _char = "-", _color = :none); end
259
+
260
+ def self.header(max_col, upgrade: false); end
184
261
 
185
- def self.header(max_col, upgrade = false)
262
+ def self.footer(_max_col); end
263
+
264
+ def self.status(os_release)
265
+ puts "#{os_release.seniority} #{os_release.newer.join(" ")}"
186
266
  end
187
267
 
188
- def self.footer
268
+ def self.duplicates_header(_max_col); end
269
+
270
+ def self.duplicates_item(num, dnum, _dcount, _repo, _max_col)
271
+ puts "#{dnum}:#{num} "
189
272
  end
190
273
 
191
- def self.status(os_release)
192
- puts os_release.seniority.to_s + ' ' + os_release.newer.join(' ')
274
+ def self.duplicates_footer(dcount, total); end
275
+
276
+ def self.unused_header(_max_col); end
277
+
278
+ def self.unused_item(num, _unum, _repo, _max_col)
279
+ puts num
193
280
  end
194
281
 
282
+ def self.unused_footer(ucount, total); end
195
283
  end
196
284
 
197
-
285
+ #
286
+ # Ini style output.
287
+ #
198
288
  class Ini
199
-
200
- def self.available(num, repo, max_col)
201
- self.info num, 'Ok', repo
289
+ def self.available(num, repo, _max_col)
290
+ info num, "Ok", repo
202
291
  end
203
292
 
204
- def self.redirected(num, repo, max_col, redirected)
205
- self.info num, 'Redirected', repo, false
293
+ def self.redirected(num, repo, _max_col, redirected)
294
+ info num, "Redirected", repo, false
206
295
  puts "redirected_to=#{redirected}"
207
296
  end
208
297
 
209
- def self.not_found(num, repo, max_col)
210
- self.info num, 'Not Found', repo, false
298
+ def self.not_found(num, repo, _max_col)
299
+ info num, "Not Found", repo, valid: false
211
300
  end
212
301
 
213
- def self.forbidden(num, repo, max_col)
214
- self.info num, 'Forbidden Path', repo, false
302
+ def self.forbidden(num, repo, _max_col)
303
+ info num, "Forbidden Path", repo, valid: false
215
304
  end
216
305
 
217
- def self.alternative(num, repo, max_col, alt)
218
- self.info num, 'Not Found', repo, false, alt[:url]
306
+ def self.alternative(num, repo, _max_col, alt)
307
+ info num, "Not Found", repo, valid: false, suggested: alt[:url]
219
308
  puts "hint=#{alt[:message]}"
220
309
  puts "suggested_url=#{alt[:url]}" unless alt[:url].to_s.empty?
221
310
  end
222
311
 
223
- def self.timeout(num, repo, max_col)
224
- self.info num, 'Server Timeout', repo, false
312
+ def self.timeout(num, repo, _max_col)
313
+ info num, "Server Timeout", repo, valid: false
225
314
  end
226
315
 
227
- def self.upgraded(num, repo, max_col)
228
- self.info num, 'Upgraded', repo
316
+ def self.upgraded(num, repo, _max_col)
317
+ info num, "Upgraded", repo
229
318
  end
230
319
 
231
- def self.untouched(num, repo, max_col)
232
- self.info num, 'Untouched', repo
320
+ def self.untouched(num, repo, _max_col)
321
+ info num, "Untouched", repo
233
322
  end
234
323
 
235
- def self.separator
236
- puts ''
324
+ def self.server_error(num, repo, _max_col)
325
+ info num, "Server Error", repo
326
+ puts "error=#{repo.status}"
237
327
  end
238
328
 
239
- def self.header(max_col, upgrade = false)
329
+ def self.separator(_max_col, _char = "-", _color = :none)
330
+ puts ""
240
331
  end
241
332
 
242
- def self.footer
243
- end
333
+ def self.header(max_col, upgrade: false); end
334
+
335
+ def self.footer(_max_col); end
244
336
 
245
337
  def self.status(os_release)
246
- puts '[os_release]'
338
+ puts "[os_release]"
247
339
  puts "name=#{os_release.fullname}"
248
340
  puts "current=#{os_release.current}"
249
341
  puts "next=#{os_release.next}"
250
342
  puts "last=#{os_release.last}"
251
- puts "available=#{os_release.newer.join(' ')}"
343
+ puts "available=#{os_release.newer.join(" ")}"
252
344
  puts "allow_unstable=#{os_release.unstable}"
253
345
  end
254
346
 
255
- private
256
-
257
- def self.info(num, status, repo, valid = true, suggested = '')
347
+ def self.info(num, status, repo, valid: true, suggested: "")
258
348
  @@number = num
259
349
  puts "[repository_#{num}]"
260
350
  puts "name=#{repo.name}"
261
351
  puts "alias=#{repo.alias}"
262
- puts "old_url=#{repo.old_url}" if repo.upgraded? || (!suggested.empty?)
352
+ puts "old_url=#{repo.old_url}" if repo.upgraded? || !suggested.empty?
263
353
  if valid
264
354
  if repo.unversioned? && repo.old_url
265
- puts <<-'HEADER'.gsub(/^ +/, '')
355
+ puts <<-HEADER.gsub(/^ +/, "")
266
356
  # The repository is unversioned: its packages should be perfectly
267
357
  # working regardless the distribution version, that because all the
268
358
  # required dependencies are included in the repository itself and
@@ -271,7 +361,7 @@ module Zypper
271
361
  end
272
362
  puts "url=#{repo.url}"
273
363
  elsif repo.enabled?
274
- puts <<-'HEADER'.gsub(/^ +/, '')
364
+ puts <<-HEADER.gsub(/^ +/, "")
275
365
  # The interpolated URL is invalid, try overriding with the one suggested
276
366
  # in the field below or find it manually starting from the old_url.
277
367
  # The alternatives are:
@@ -282,7 +372,7 @@ module Zypper
282
372
  url=
283
373
  HEADER
284
374
  else
285
- puts <<-'HEADER'.gsub(/^ +/, '')
375
+ puts <<-HEADER.gsub(/^ +/, "")
286
376
  # The interpolated URL is invalid, but being the repository disabled you can
287
377
  # keep the old_url in the field below, it will be ignored anyway during the
288
378
  # normal update and upgrade process.
@@ -290,32 +380,58 @@ module Zypper
290
380
  puts "url=#{repo.old_url}"
291
381
  end
292
382
  puts "priority=#{repo.priority}"
293
- puts "enabled=#{repo.enabled? ? 'Yes' : 'No'}"
383
+ puts "enabled=#{repo.enabled? ? "Yes" : "No"}"
294
384
  puts "status=#{status}"
295
385
  end
296
- end
297
386
 
387
+ def self.duplicates_header(_max_col); end
298
388
 
299
- class Solved < Ini
389
+ def self.duplicates_item(num, dnum, dcount, repo, _max_col)
390
+ puts "[repository_#{num}]" if dnum == 1
391
+ puts "number_#{dnum}_#{dcount}=#{num}"
392
+ puts "name_#{dnum}_#{dcount}=#{repo.name}"
393
+ puts "alias_#{dnum}_#{dcount}=#{repo.alias}"
394
+ puts "url_#{dnum}_#{dcount}=#{repo.url}"
395
+ puts "priority_#{dnum}_#{dcount}=#{repo.priority}"
396
+ puts "enabled_#{dnum}_#{dcount}=#{repo.enabled? ? "Yes" : "No"}"
397
+ end
300
398
 
301
- def self.alternative(num, repo, max_col, alt)
302
- self.info num, 'Not Found', repo, false, alt[:url]
303
- puts "hint=#{alt[:message]}"
304
- puts "suggested_url=#{alt[:url]}" unless alt[:url].to_s.empty?
399
+ def self.duplicates_footer(dcount, total); end
400
+
401
+ def self.unused_header(_max_col); end
402
+
403
+ def self.unused_item(num, _unum, repo, _max_col)
404
+ puts "[repository_#{num}]"
405
+ puts "number=#{num}"
406
+ puts "name=#{repo.name}"
407
+ puts "alias=#{repo.alias}"
408
+ puts "url=#{repo.url}"
409
+ puts "priority=#{repo.priority}"
410
+ puts "enabled=#{repo.enabled? ? "Yes" : "No"}"
305
411
  end
306
412
 
413
+ def self.unused_footer(ucount, total); end
414
+ end
307
415
 
308
- private
416
+ #
417
+ # Ini style output with inferred solution.
418
+ #
419
+ class Solved < Ini
420
+ def self.alternative(num, repo, _max_col, alt)
421
+ info num, "Not Found", repo, valid: false, suggested: alt[:url]
422
+ puts "hint=#{alt[:message]}"
423
+ puts "suggested_url=#{alt[:url]}" unless alt[:url].to_s.empty?
424
+ end
309
425
 
310
- def self.info(num, status, repo, valid = true, suggested = '')
426
+ def self.info(num, status, repo, valid: true, suggested: "")
311
427
  @@number = num
312
428
  puts "[repository_#{num}]"
313
429
  puts "name=#{repo.name}"
314
430
  puts "alias=#{repo.alias}"
315
- puts "old_url=#{repo.old_url}" if repo.upgraded? || (!suggested.empty?)
431
+ puts "old_url=#{repo.old_url}" if repo.upgraded? || !suggested.empty?
316
432
  if valid
317
433
  if repo.unversioned? && repo.old_url
318
- puts <<-'HEADER'.gsub(/^ +/, '')
434
+ puts <<-HEADER.gsub(/^ +/, "")
319
435
  # The repository is unversioned: its packages should be perfectly
320
436
  # working regardless the distribution version, that because all the
321
437
  # required dependencies are included in the repository itself and
@@ -324,19 +440,8 @@ module Zypper
324
440
  end
325
441
  puts "url=#{repo.url}"
326
442
  elsif repo.enabled?
327
- unless suggested.empty?
328
- puts <<-'HEADER'.gsub(/^ +/, '')
329
- # The interpolated URL is invalid, but the script found an alternative
330
- # URL which will be used to override the old value.
331
- # Unfortunately the script is not able to know if the found URL is exact,
332
- # so review the result before accepting any change, and in case want
333
- # to disable it, just turn the "enabled" field below to "No".
334
- #
335
- HEADER
336
- puts "url=#{suggested}"
337
- puts 'enabled=Yes'
338
- else
339
- puts <<-'HEADER'.gsub(/^ +/, '')
443
+ if suggested.empty?
444
+ puts <<-HEADER.gsub(/^ +/, "")
340
445
  # The interpolated URL is invalid, and the script has not been able to find
341
446
  # an alternative. The best thing to do here is to disable the repository.
342
447
  # In case a valid alternative will be discovered, just replace its URL in
@@ -345,13 +450,24 @@ module Zypper
345
450
  #
346
451
  HEADER
347
452
  puts "url=#{repo.old_url}"
348
- puts 'enabled=No'
453
+ puts "enabled=No"
454
+ else
455
+ puts <<-HEADER.gsub(/^ +/, "")
456
+ # The interpolated URL is invalid, but the script found an alternative
457
+ # URL which will be used to override the old value.
458
+ # Unfortunately the script is not able to know if the found URL is exact,
459
+ # so review the result before accepting any change, and in case want
460
+ # to disable it, just turn the "enabled" field below to "No".
461
+ #
462
+ HEADER
463
+ puts "url=#{suggested}"
464
+ puts "enabled=Yes"
349
465
  end
350
466
  else
351
- puts <<-'HEADER'.gsub(/^ +/, '')
467
+ puts <<-HEADER.gsub(/^ +/, "")
352
468
  # The interpolated URL is invalid, but being the repository disabled you can
353
469
  # keep the old_url in the field below, it will be ignored anyway during the
354
- # system update and upgrade process until the repository is enabled again.
470
+ # system update and the upgrade process until the repository is enabled again.
355
471
  HEADER
356
472
  puts "url=#{suggested.empty? ? repo.old_url : suggested}"
357
473
  end
@@ -359,7 +475,6 @@ module Zypper
359
475
  puts "status=#{status}"
360
476
  end
361
477
  end
362
-
363
478
  end
364
479
  end
365
480
  end