Class: Testjour::CLI::List
Instance Attribute Summary
Attributes inherited from BaseCommand
#non_options, #options
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from BaseCommand
detailed_help, help, #option_parser, options
Constructor Details
#initialize(*args) ⇒ List
Returns a new instance of List.
13
14
15
16
17
18
19
|
# File 'lib/testjour/commands/list.rb', line 13
def initialize(*args)
super
Testjour.load_cucumber
require "testjour/colorer"
rescue LoadError
end
|
Class Method Details
.command ⇒ Object
9
10
11
|
# File 'lib/testjour/commands/list.rb', line 9
def self.command
"list"
end
|
Instance Method Details
#colorize_status(status) ⇒ Object
40
41
42
43
44
45
46
47
48
49
50
|
# File 'lib/testjour/commands/list.rb', line 40
def colorize_status(status)
formatted_status = ("%-12s" % status)
return formatted_status unless defined?(Testjour::Colorer)
case formatted_status.strip
when "available"
Testjour::Colorer.green(formatted_status)
else
Testjour::Colorer.yellow(formatted_status)
end
end
|
#run ⇒ Object
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
|
# File 'lib/testjour/commands/list.rb', line 21
def run
available_servers = Testjour::Bonjour.list
if available_servers.any?
puts
puts "Testjour servers:"
puts
available_servers.each do |server|
slave_server = DRbObject.new(nil, server.uri)
status = colorize_status(slave_server.status)
puts " %-12s %s %s" % [server.name, status, "#{server.host}:#{server.port}"]
end
else
puts
puts "No testjour servers found."
end
end
|