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

Constants included from Helpers

Helpers::GEN_NAME_LENGTH, Helpers::RAND_CHARS

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



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

def initialize(*args)
  super
  @threads = Mash.new
  @mappings_key = :mappings
end

Instance Attribute Details

#actionObject

Returns the value of attribute action.



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

def action
  @action
end

#configObject

Returns the value of attribute config.



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

def config
  @config
end

#internal_configObject (readonly)

Returns the value of attribute internal_config.



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

def internal_config
  @internal_config
end

#lxcObject

Returns the value of attribute lxc.



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

def lxc
  @lxc
end

#mappings_keyObject

Returns the value of attribute mappings_key.



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

def mappings_key
  @mappings_key
end

#nameObject (readonly)

Returns the value of attribute name.



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

def name
  @name
end

#optionsObject (readonly)

Returns the value of attribute options.



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

def options
  @options
end

#uiObject (readonly)

Returns the value of attribute ui.



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

def ui
  @ui
end

#vagabondfileObject (readonly)

Returns the value of attribute vagabondfile.



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

def vagabondfile
  @vagabondfile
end