class RSpecSystem::Node
This class represents a node in a nodeset
Public Class Methods
Create a new node object.
@param options [Hash] options for new node @option options [String] :name name of node. Mandatory. @option options [String] :prefab prefab setting. Mandatory. @option options [String] :options options setting. Optional. @option options [RSpecSystem::NodeSet] :nodeset the parent nodeset for
this node. Mandatory.
@option options [String] :custom_prefabs_path path of custom prefabs
yaml file. Optional.
# File lib/rspec-system/node.rb, line 34 def initialize(options) @name = options[:name] prefab = options[:prefab] @options = options[:options] @nodeset = options[:nodeset] @custom_prefabs_path = options[:custom_prefabs_path] if prefab.nil? # TODO: do not support not prefabs yet raise "No prefab defined, bailing" else @prefab = RSpecSystem::Prefab.prefab(prefab, @custom_prefabs_path) @facts = @prefab.facts @provider_specifics = @prefab.provider_specifics end end
Static helper for generating a node direct from the hash returned by the nodeset YAML file.
@param nodeset [RSpecSystem::Node] nodeset that this node belongs to @param k [String] name of node @param v [Hash<String,String>] hash configuration as given from the nodeset yaml file @param custom_prefabs_path [String] path of custom prefabs yaml file @return [RSpecSystem::Node] returns a new node object
# File lib/rspec-system/node.rb, line 14 def self.node_from_yaml(nodeset, k, v, custom_prefabs_path) RSpecSystem::Node.new( :nodeset => nodeset, :custom_prefabs_path => custom_prefabs_path, :name => k, :prefab => v['prefab'], :options => v['options'] ) end
Public Instance Methods
Retreives facts from the nodeset definition or prefab.
@return [Hash] returns a hash of facter facts defined for this node
# File lib/rspec-system/node.rb, line 75 def facts @facts end
Return name when inspected
@return [String] name of node
# File lib/rspec-system/node.rb, line 103 def inspect name end
Returns the name of the node as specified in the nodeset file.
@return [String] name of node
# File lib/rspec-system/node.rb, line 54 def name @name end
Returns the nodeset this node belongs in.
@return [RSpecSystem::NodeSet] the nodeset this node belongs to
# File lib/rspec-system/node.rb, line 82 def nodeset @nodeset end
Returns the custom object for this node (if any).
@return [Hash] the options object used to customize the node
# File lib/rspec-system/node.rb, line 68 def options @options end
Returns the prefab object for this node (if any).
@return [RSpecSystem::Prefab] the prefab object used to create this node
# File lib/rspec-system/node.rb, line 61 def prefab @prefab end
Return provider specific settings
@return [Hash] provider specific settings
# File lib/rspec-system/node.rb, line 89 def provider_specifics @provider_specifics end
Return name when stringified
@return [String] name of node
# File lib/rspec-system/node.rb, line 96 def to_s name end