class Derelict::Connection
Connects a Derelict::Instance
to its use in a particular directory
Attributes
instance[R]
path[R]
Public Class Methods
new(instance, path)
click to toggle source
Initializes a Connection
for use in a particular directory
* instance: The Derelict::Instance to use to control Vagrant * path: The project path, which contains the Vagrantfile
# File lib/derelict/connection.rb, line 17 def initialize(instance, path) @instance = instance @path = path logger.debug "Successfully initialized #{description}" end
Public Instance Methods
description()
click to toggle source
Provides a description of this Connection
Mainly used for log messages.
# File lib/derelict/connection.rb, line 72 def description "Derelict::Connection at '#{path}' using #{instance.description}" end
execute(subcommand, *arguments, &block)
click to toggle source
Executes a Vagrant subcommand using this connection
* subcommand: Vagrant subcommand to run (:up, :status, etc.) * arguments: Arguments to pass to the subcommand (optional) * block: Passed through to @instance#execute
# File lib/derelict/connection.rb, line 40 def execute(subcommand, *arguments, &block) log_execute subcommand, *arguments Dir.chdir path do instance.execute subcommand.to_sym, *arguments, &block end end
execute!(subcommand, *arguments, &block)
click to toggle source
Executes a Vagrant subcommand, raising an exception on failure
* subcommand: Vagrant subcommand to run (:up, :status, etc.) * arguments: Arguments to pass to the subcommand (optional) * block: Passed through to Derelict::Executer.execute
Raises Derelict::Instance::CommandFailed
if the command fails.
# File lib/derelict/connection.rb, line 54 def execute!(subcommand, *arguments, &block) log_execute subcommand, *arguments Dir.chdir path do instance.execute! subcommand.to_sym, *arguments, &block end end
validate!()
click to toggle source
Validates the data used for this connection
Raises exceptions on failure:
* +Derelict::Connection::NotFound+ if the path is not found
# File lib/derelict/connection.rb, line 28 def validate! logger.debug "Starting validation for #{description}" raise NotFound.new path unless File.exists? path logger.info "Successfully validated #{description}" self end
vm(name)
click to toggle source
Retrieves a Derelict::VirtualMachine
for a particular VM
* name: The name of the virtual machine to retrieve
# File lib/derelict/connection.rb, line 64 def vm(name) logger.debug "Retrieving VM '#{name}' from #{description}" Derelict::VirtualMachine.new(self, name).validate! end
Private Instance Methods
log_execute(subcommand, *arguments)
click to toggle source
Handles the logging that should occur for a call to execute
(!)
# File lib/derelict/connection.rb, line 78 def log_execute(subcommand, *arguments) logger.debug do "Executing #{subcommand} #{arguments.inspect} on #{description}" end end