Class: Vagabond::Vagabond

Inherits:
Thor
  • Object
show all
Includes:
Thor::Actions, Helpers
Defined in:
lib/vagabond/vagabond.rb

Constant Summary collapse

CLI_OPTIONS =
lambda do
class_option(:debug,
  :type => :boolean,
  :default => false
)

class_option(:force_solo,
  :aliases => '--force-configure',
  :type => :boolean,
  :default => false,
  :desc => 'Force configuration of system'
)

class_option(:color,
  :type => :boolean,
  :default => true,
  :desc => 'Enable/disable colorized output'
)

class_option(:vagabond_file,
  :aliases => '-f',
  :type => :string,
  :desc => 'Provide path to Vagabondfile'
)

class_option(:local_server,
  :type => :boolean,
  :default => true,
  :desc => 'Enable/disable local Chef server usage if available'
)
end
COMMANDS =

COMMANDS

lambda do |show_node=true|
  Actions.constants.find_all do |const|
    Actions.const_get(const).is_a?(Module)
  end.map(&:to_s).map(&:downcase).each do |meth|
    if(self.respond_to?("_#{meth}_desc"))
      args = self.send("_#{meth}_desc")
    else
      args = ["#{meth}#{' NODE' if show_node}", "#{meth.capitalize} instance#{' of NODE' if show_node}"]
    end
    desc(*args)
    if(self.respond_to?("_#{meth}_options"))
      self.send("_#{meth}_options").each do |opts|
        method_option(*opts)
      end
    end
    define_method meth do |*args|
      setup(meth, *args)
      execute
    end
  end
end

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Helpers

included

Constructor Details

#initialize(*args) ⇒ Vagabond

action

Action to perform

name

Name of vagabond

config

Hash configuration

Creates an instance



79
80
81
82
# File 'lib/vagabond/vagabond.rb', line 79

def initialize(*args)
  super
  @mappings_key = :mappings
end

Instance Attribute Details

#actionObject

Returns the value of attribute action.



37
38
39
# File 'lib/vagabond/vagabond.rb', line 37

def action
  @action
end

#configObject

Returns the value of attribute config.



36
37
38
# File 'lib/vagabond/vagabond.rb', line 36

def config
  @config
end

#internal_configObject (readonly)

Returns the value of attribute internal_config.



30
31
32
# File 'lib/vagabond/vagabond.rb', line 30

def internal_config
  @internal_config
end

#lxcObject

Returns the value of attribute lxc.



35
36
37
# File 'lib/vagabond/vagabond.rb', line 35

def lxc
  @lxc
end

#mappings_keyObject

Returns the value of attribute mappings_key.



34
35
36
# File 'lib/vagabond/vagabond.rb', line 34

def mappings_key
  @mappings_key
end

#nameObject (readonly)

Returns the value of attribute name.



28
29
30
# File 'lib/vagabond/vagabond.rb', line 28

def name
  @name
end

#optionsObject (readonly)

Returns the value of attribute options.



32
33
34
# File 'lib/vagabond/vagabond.rb', line 32

def options
  @options
end

#uiObject (readonly)

Returns the value of attribute ui.



31
32
33
# File 'lib/vagabond/vagabond.rb', line 31

def ui
  @ui
end

#vagabondfileObject (readonly)

Returns the value of attribute vagabondfile.



29
30
31
# File 'lib/vagabond/vagabond.rb', line 29

def vagabondfile
  @vagabondfile
end