lib/testlab/labfile.rb in testlab-1.5.1 vs lib/testlab/labfile.rb in testlab-1.6.0

- old
+ new

@@ -5,21 +5,43 @@ # Labfile Class # # @author Zachary Patten <zachary AT jovelabs DOT com> class Labfile < ZTK::DSL::Base - has_many :nodes, :class_name => 'TestLab::Node' + has_many :dependencies, :class_name => 'TestLab::Dependency' + has_many :sources, :class_name => 'TestLab::Source' + has_many :nodes, :class_name => 'TestLab::Node' attribute :testlab - attribute :config, :default => Hash.new - attribute :version, :default => TestLab::VERSION + attribute :config, :default => Hash.new + attribute :version def initialize(*args) @ui = TestLab.ui - @ui.logger.info { "Loading Labfile '#{self.id}'" } + @ui.logger.debug { "Loading Labfile" } super(*args) - @ui.logger.info { "Labfile '#{self.id}' Loaded" } + @ui.logger.debug { "Labfile '#{self.id}' Loaded" } + + if version.nil? + raise LabfileError, 'You must version the Labfile!' + else + @ui.logger.debug { "Labfile Version: #{version}" } + version_arguments = version.split + @ui.logger.debug { version_arguments.inspect } + + if version_arguments.count == 1 + if (TestLab::VERSION != version_arguments.first) + raise LabfileError, "This Labfile is not compatible with this version of TestLab! (#{version})" + end + elsif version_arguments.count == 2 + if !TestLab::VERSION.send(version_arguments.first, version_arguments.last) + raise LabfileError, "This Labfile is not compatible with this version of TestLab! (#{version})" + end + else + raise LabfileError, 'Invalid version!' + end + end end def config_dir self.testlab.config_dir end