Class: VagrantPlugins::Babushka::Dep

Inherits:
Object
  • Object
show all
Defined in:
lib/vagrant-babushka/dep.rb

Overview

A class representing a Babushka dep that should be met

This represents the dep after parameters are bound (if there are any). So it’s not so much a “dep”, but more in line with the “DepRequirement” class from Babushka itself.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(dep_name, options = {}) ⇒ Dep

Initialezes a dep from a name and options

* dep_name: The name of the dep (excluding source prefix)
* options:  A Hash of options. Valid keys:
     * source: The name of the source containing the dep
               (will be used as a source prefix if provided,
               otherwise no source prefix will be used)
     * params: A Hash of parameters to pass to the dep
               (mapping parameter names as keys to values)


20
21
22
23
# File 'lib/vagrant-babushka/dep.rb', line 20

def initialize(dep_name, options = {})
  @dep_name = dep_name.to_s
  @options = options
end

Instance Attribute Details

#dep_nameObject (readonly)

Returns the value of attribute dep_name.



9
10
11
# File 'lib/vagrant-babushka/dep.rb', line 9

def dep_name
  @dep_name
end

Instance Method Details

#==(other) ⇒ Object Also known as: eql?



64
65
66
# File 'lib/vagrant-babushka/dep.rb', line 64

def ==(other)
  other.class == self.class && other.state == state
end

#argumentsObject

Retrieves the command-line arguments for the dep

This returns a hash including all the Babushka command-line arguments (to override the global settings) when meeting this dep.



60
61
62
# File 'lib/vagrant-babushka/dep.rb', line 60

def arguments
  @options.select {|key, value| Config::ARGUMENTS.include? key }
end

#idObject

Retrieves the full name of this dep (including source prefix)

This will be in the format “source:dep_name” if a source was specified, otherwise it will be the bare dep name (in which case Babushka would look for it in the default sources).



30
31
32
33
34
35
36
# File 'lib/vagrant-babushka/dep.rb', line 30

def id
  if source
    "#{source}:#{dep_name}"
  else
    dep_name
  end
end

#paramsObject

Retrieves the parameters for the dep

Parameters are values for variables that the dep accepts. This method returns a Hash mapping parameter names as keys to their values.



51
52
53
# File 'lib/vagrant-babushka/dep.rb', line 51

def params
  @options[:params] || Hash.new
end

#sourceObject

Determines the source that this dep belongs to

If the source can’t be determined (a source wasn’t specified), nil is returned.



42
43
44
# File 'lib/vagrant-babushka/dep.rb', line 42

def source
  @options[:source] ? @options[:source].to_s : nil
end