Class: LSync::Action

Inherits:
Object
  • Object
show all
Defined in:
lib/lsync/action.rb

Overview

A runnable action, such as a shell command or action script.

If the first argument is a symbol, then this will map to one of the standard actions in the ‘lsync/actions` subdirectory. These actions are sometimes implemented on a per-platform basis.

Instance Method Summary collapse

Constructor Details

#initialize(function) ⇒ Action

Returns a new instance of Action.



17
18
19
20
21
22
23
24
25
26
27
# File 'lib/lsync/action.rb', line 17

def initialize(function)
	@function = function
	
	case @function[0]
	when Symbol
		@script_name = @function[0].to_s
		@arguments = @function[1,@function.size]
	else
		@script_name = nil
	end
end

Instance Method Details

#run_on_server(server, logger) ⇒ Object

Run the action on the given server, typically in the root directory specified.



35
36
37
38
39
40
41
42
43
# File 'lib/lsync/action.rb', line 35

def run_on_server(server, logger)
	# logger.info "Running #{@function.to_cmd} on #{server}"

	if server.is_local?
		run_locally(server, logger)
	else
		run_remotely(server, logger)
	end
end

#to_sObject

Return a string representation of the action for logging.



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

def to_s
	@function.to_cmd
end