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