Service#summary cleaned a bit.

Not provided tokens will also be printed in red.
This commit is contained in:
Luka Vandervelden 2019-06-08 19:24:52 +02:00
parent 9a93937176
commit 5aadf3c7ed

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" +
"Provides:\n" +
(provides.map { |x| " - " + x.token + "\n" }).join +
"Consumes:\n" +
(@reference.consumes.map { |x|
provider = @providers[x.token]?
if provider
" - #{x.token} (from #{provider.to_s})\n"
(
if provides.size > 0
"Provides:\n" +
(provides.map { |x| " - " + x.token + "\n" }).join
else
" - #{x.token} (NOT CURRENTLY PROVIDED)\n"
""
end
}).join
) +
(
if @reference.consumes.size > 0
"Consumes:\n" +
(@reference.consumes.map { |x|
provider = @providers[x.token]?
if provider
" - #{x.token} (from #{provider.id})\n"
else
" - #{x.token} " +
"(NOT CURRENTLY PROVIDED)".colorize(:red).to_s +
"\n"
end
}).join
else
""
end
)
end
class_getter all = [] of Service