lib/testlab.rb in testlab-0.1.0 vs lib/testlab.rb in testlab-0.2.0
- old
+ new
@@ -1,9 +1,14 @@
require 'ztk'
require 'testlab/version'
+# Monkey Patch the String class so we can have some easy ANSI methods
+class String
+ include ZTK::ANSI
+end
+
# Top-Level LXC Class
#
# @author Zachary Patten <zachary@jovelabs.net>
class TestLab
@@ -18,10 +23,12 @@
autoload :Provider, 'testlab/provider'
autoload :Provisioner, 'testlab/provisioner'
autoload :Router, 'testlab/router'
autoload :Utility, 'testlab/utility'
+ include TestLab::Utility::Misc
+
@@ui ||= nil
def initialize(options={})
labfile = (options[:labfile] || 'Labfile')
labfile_path = ZTK::Locator.find(labfile)
@@ -59,22 +66,22 @@
!alive?
end
def status
if alive?
- @@ui.stdout.puts("NODES:")
- ZTK::Report.new(:ui => @@ui).spreadsheet(TestLab::Node.all, TestLab::Node::STATUS_KEYS) do |node|
+ @@ui.stdout.puts("NODES:".green.bold)
+ ZTK::Report.new(:ui => @@ui).list(TestLab::Node.all, TestLab::Node::STATUS_KEYS) do |node|
OpenStruct.new(node.status)
end
@@ui.stdout.puts
- @@ui.stdout.puts("NETWORKS:")
- ZTK::Report.new(:ui => @@ui).spreadsheet(TestLab::Network.all, TestLab::Network::STATUS_KEYS) do |network|
+ @@ui.stdout.puts("NETWORKS:".green.bold)
+ ZTK::Report.new(:ui => @@ui).list(TestLab::Network.all, TestLab::Network::STATUS_KEYS) do |network|
OpenStruct.new(network.status)
end
@@ui.stdout.puts
- @@ui.stdout.puts("CONTAINERS:")
- ZTK::Report.new(:ui => @@ui).spreadsheet(TestLab::Container.all, TestLab::Container::STATUS_KEYS) do |container|
+ @@ui.stdout.puts("CONTAINERS:".green.bold)
+ ZTK::Report.new(:ui => @@ui).list(TestLab::Container.all, TestLab::Container::STATUS_KEYS) do |container|
OpenStruct.new(container.status)
end
true
else
@@ -96,11 +103,10 @@
node_method_proxy(:teardown)
end
# Proxy various method calls to our subordinate classes
def node_method_proxy(method_name, *method_args)
- @@ui.logger.debug { "TestLab.#{method_name}" }
TestLab::Node.all.map do |node|
node.send(method_name.to_sym, *method_args)
end
end
@@ -111,9 +117,13 @@
if TestLab::Provider::PROXY_METHODS.include?(method_name) # || %w(setup teardown).map(&:to_sym).include?(method_name))
node_method_proxy(method_name, *method_args)
else
super(method_name, *method_args)
end
+ end
+
+ def ui
+ @@ui ||= ZTK::UI.new
end
# Class Helpers
class << self