Class: Vagabond::Vagabond

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

Constant Summary collapse

DISABLE_HOST_SOLO_ON =
%w(status init)
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'
  )

  class_option(:callbacks,
    :type => :boolean,
    :default => true,
    :desc => 'Enable/disable action callbacks'
  )
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|
      @original_args = args.dup
      unless(args.include?(:no_setup))
        setup(meth, *args)
      end
      result = execute
      callbacks(meth)
      chain!
      result
    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



82
83
84
85
86
# File 'lib/vagabond/vagabond.rb', line 82

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

Instance Attribute Details

#actionObject

Returns the value of attribute action.



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

def action
  @action
end

#configObject

Returns the value of attribute config.



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

def config
  @config
end

#lxcObject

Returns the value of attribute lxc.



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

def lxc
  @lxc
end

#mappings_keyObject

Returns the value of attribute mappings_key.



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

def mappings_key
  @mappings_key
end