lib/bolt/target.rb in bolt-0.20.3 vs lib/bolt/target.rb in bolt-0.20.5
- old
+ new
@@ -4,10 +4,11 @@
require 'bolt/error'
module Bolt
class Target
attr_reader :uri, :options
+ attr_writer :inventory
# Satisfies the Puppet datatypes API
def self.from_asserted_hash(hash)
new(hash['uri'], hash['options'])
end
@@ -41,9 +42,23 @@
# Initialize with an empty scheme to ensure we parse the hostname correctly
Addressable::URI.parse("//#{string}")
end
end
private :parse
+
+ def select_impl(task, additional_features = [])
+ available_features = features + additional_features
+ suitable_impl = task.implementations.find { |impl| Set.new(impl['requirements']).subset?(available_features) }
+ return suitable_impl['path'] if suitable_impl
+ end
+
+ def features
+ if @inventory
+ @inventory.features(self)
+ else
+ Set.new
+ end
+ end
def eql?(other)
self.class.equal?(other.class) && @uri == other.uri
end
alias == eql?