-
Notifications
You must be signed in to change notification settings - Fork 0
/
eric-report-console.rb
executable file
·63 lines (54 loc) · 1.92 KB
/
eric-report-console.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
require "Paludis"
include Paludis
$length = 80
:left
:center
def print_line(content = "", align = :center, side_char = "+", fill_char = "-")
length = $length
length -= side_char.length * 2
length -= content.length
case align
when :center
left_hand_side = (length / 2).floor
right_hand_side = (length / 2).floor
when :left
left_hand_side = 0
right_hand_side = length
end
left_hand_line = ""
right_hand_line = ""
(0...left_hand_side).each do |i|
left_hand_line += fill_char
end
(0...right_hand_side).each do |i|
right_hand_line += fill_char
end
output = side_char + left_hand_line + content + right_hand_line + side_char
while output.length < $length do
right_hand_line += fill_char
output = side_char + left_hand_line + content + right_hand_line + side_char
end
puts output
end
def eric_report_console(env, packages)
puts packages.length.to_s + " package(s) needs updating."
packages.each do |package|
print_line(package.name)
package.best_version_in_each_slot.each do |slot, local_version|
repository = ""
local_packages = env[Selection::AllVersionsSorted.new(Generator::Matches.new(parse_user_package_dep_spec("=" + package.name + "-" + local_version, env, []), nil, []))]
local_packages.each do |local_package|
if local_package.repository_name != "installed"
repository = local_package.repository_name
end
end
remote_version = package.best_remote_version_in_each_slot[slot]
if remote_version != nil
print_line("::" + repository + " " + local_version + " {:" + slot + "} -> " + remote_version, :left, "|", " ")
end
end
print_line()
puts "\n\n"
end
puts packages.length.to_s + " package(s) needs updating."
end