Top Level Namespace

Defined Under Namespace

Modules: Rake, Vlad Classes: String

Instance Method Summary collapse

Instance Method Details

#host(host_name, *roles) ⇒ Object

Declare a remote host and its roles. Equivalent to role, but shorter for multiple roles.



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

def host host_name, *roles
  Rake::RemoteTask.host host_name, *roles
end

#nowObject

used by update, out here so we can ensure all threads have the same value



5
6
7
# File 'lib/vlad/core.rb', line 5

def now
  @now ||= Time.now.utc.strftime("%Y%m%d%H%M.%S")
end

#put(remote_path, base_name = 'vlad.unknown') ⇒ Object

Copy a (usually generated) file to remote_path. Contents of block are copied to remote_path and you may specify an optional base_name for the tempfile (aids in debugging).



46
47
48
49
50
51
52
# File 'lib/rake_remote_task.rb', line 46

def put remote_path, base_name = 'vlad.unknown'
  Tempfile.open base_name do |fp|
    fp.puts yield
    fp.flush
    rsync fp.path, remote_path
  end
end

#remote_task(name, options = {}, &b) ⇒ Object

Declare a Vlad task that will execute on all hosts by default. To limit that task to specific roles, use:

remote_task :example, :roles => [:app, :web] do


59
60
61
# File 'lib/rake_remote_task.rb', line 59

def remote_task name, options = {}, &b
  Rake::RemoteTask.remote_task name, options, &b
end

#role(role_name, host, args = {}) ⇒ Object

Declare a role and assign a remote host to it. Equivalent to the host method; provided for capistrano compatibility.



66
67
68
# File 'lib/rake_remote_task.rb', line 66

def role role_name, host, args = {}
  Rake::RemoteTask.role role_name, host, args
end

#rsync(local, remote) ⇒ Object

rsync the given files to target_host.



78
79
80
# File 'lib/rake_remote_task.rb', line 78

def rsync local, remote
  Thread.current[:task].rsync local, remote
end

#run(*args, &b) ⇒ Object

Execute the given command on the target_host for the current task.



73
74
75
# File 'lib/rake_remote_task.rb', line 73

def run *args, &b
  Thread.current[:task].run(*args, &b)
end

#set(name, val = nil, &b) ⇒ Object

Declare a variable called name and assign it a value. A globally-visible method with the name of the variable is defined. If a block is given, it will be called when the variable is first accessed. Subsequent references to the variable will always return the same value. Raises ArgumentError if the name would conflict with an existing method.



88
89
90
# File 'lib/rake_remote_task.rb', line 88

def set name, val = nil, &b
  Rake::RemoteTask.set name, val, &b
end

#sudo(*args, &b) ⇒ Object

Execute the given command with sudo on the target_host for the current task.



102
103
104
# File 'lib/rake_remote_task.rb', line 102

def sudo *args, &b
  Thread.current[:task].sudo(*args, &b)
end

#target_hostObject

Returns the name of the host that the current task is executing on. target_host can uniquely identify a particular task/host combination.



95
96
97
# File 'lib/rake_remote_task.rb', line 95

def target_host
  Thread.current[:task].target_host
end