Class: Vagabond::Core

Inherits:
Object
  • Object
show all
Includes:
Thor::Actions, Helpers
Defined in:
lib/vagabond/core.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) ⇒ Core

action

Action to perform

name

Name of vagabond

config

Hash configuration

Creates an instance



75
76
77
78
79
# File 'lib/vagabond/core.rb', line 75

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

Instance Attribute Details

#actionObject

Returns the value of attribute action.



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

def action
  @action
end

#configObject

Returns the value of attribute config.



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

def config
  @config
end

#lxcObject

Returns the value of attribute lxc.



26
27
28
# File 'lib/vagabond/core.rb', line 26

def lxc
  @lxc
end

#mappings_keyObject

Returns the value of attribute mappings_key.



25
26
27
# File 'lib/vagabond/core.rb', line 25

def mappings_key
  @mappings_key
end