lib/testlab.rb in testlab-0.7.3 vs lib/testlab.rb in testlab-0.7.4

- old
+ new

@@ -82,14 +82,10 @@ # testlab.teardown # teardown the lab, destroy all networks and containers # # @author Zachary Patten <zachary AT jovelabs DOT com> class TestLab - unless const_defined?(:HOSTNAME) - HOSTNAME = Socket.gethostname.split('.').first.strip - end - # TestLab Error Class class TestLabError < StandardError; end # Main Classes autoload :Container, 'testlab/container' @@ -110,11 +106,11 @@ def initialize(options={}) self.ui = (options[:ui] || ZTK::UI.new) self.class.ui = self.ui - @config_dir = (options[:config_dir] || File.join(Dir.pwd, ".testlab-#{HOSTNAME}")) + @config_dir = (options[:config_dir] || File.join(Dir.pwd, ".testlab-#{TestLab.hostname}")) @repo_dir = (options[:repo_dir] || Dir.pwd) labfile = (options[:labfile] || File.join(Dir.pwd, 'Labfile')) @labfile_path = ZTK::Locator.find(labfile) @labfile = TestLab::Labfile.load(labfile_path) @@ -336,9 +332,18 @@ # # @return [ZTK::UI] def ui=(value) @@ui = value value + end + + # TestLab Hostname + # + # Gets the hostname portion of the fqdn for the current host. + # + # @return [String] The hostname for the current host. + def hostname + Socket.gethostname.split('.').first.strip end # Test Lab Gem Directory # # Returns the directory path to where the gem is installed.