diff options
Diffstat (limited to 'lib/leap_cli/config')
-rw-r--r-- | lib/leap_cli/config/node.rb | 8 | ||||
-rw-r--r-- | lib/leap_cli/config/object_list.rb | 18 |
2 files changed, 26 insertions, 0 deletions
diff --git a/lib/leap_cli/config/node.rb b/lib/leap_cli/config/node.rb index 5b911bf..740f9bb 100644 --- a/lib/leap_cli/config/node.rb +++ b/lib/leap_cli/config/node.rb @@ -32,6 +32,14 @@ module LeapCli; module Config end return vagrant_range.include?(ip_address) end + + # + # can be overridden by the platform. + # returns a list of node names that should be tested before this node + # + def test_dependencies + [] + end end end; end diff --git a/lib/leap_cli/config/object_list.rb b/lib/leap_cli/config/object_list.rb index 9ca4697..910e2f7 100644 --- a/lib/leap_cli/config/object_list.rb +++ b/lib/leap_cli/config/object_list.rb @@ -1,9 +1,12 @@ +require 'tsort' + module LeapCli module Config # # A list of Config::Object instances (internally stored as a hash) # class ObjectList < Hash + include TSort def initialize(config=nil) if config @@ -171,6 +174,21 @@ module LeapCli end end + # + # topographical sort based on test dependency + # + def tsort_each_node(&block) + self.each_key(&block) + end + + def tsort_each_child(node_name, &block) + self[node_name].test_dependencies.each(&block) + end + + def names_in_test_dependency_order + self.tsort + end + end end end |