Service#summary cleaned a bit.

Not provided tokens will also be printed in red.
master
Luka Vandervelden 2019-06-08 19:24:52 +02:00
parent 9a93937176
commit 5aadf3c7ed
1 changed files with 24 additions and 9 deletions

View File

@ -1,5 +1,6 @@
require "option_parser"
require "yaml"
require "colorize"
# Those are set to local to make testing easier.
PID_DIRECTORY = "./pid"
@ -302,17 +303,31 @@ class Service
def summary
"Name: #{name}\n" +
"Environment: #{environment.name} (#{environment.type.to_s.downcase})\n" +
(
if provides.size > 0
"Provides:\n" +
(provides.map { |x| " - " + x.token + "\n" }).join +
(provides.map { |x| " - " + x.token + "\n" }).join
else
""
end
) +
(
if @reference.consumes.size > 0
"Consumes:\n" +
(@reference.consumes.map { |x|
provider = @providers[x.token]?
if provider
" - #{x.token} (from #{provider.to_s})\n"
" - #{x.token} (from #{provider.id})\n"
else
" - #{x.token} (NOT CURRENTLY PROVIDED)\n"
" - #{x.token} " +
"(NOT CURRENTLY PROVIDED)".colorize(:red).to_s +
"\n"
end
}).join
else
""
end
)
end
class_getter all = [] of Service