Class: Buffet::Slave

Inherits:
Object
  • Object
show all
Defined in:
lib/buffet/slave.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(user, host, project) ⇒ Slave

Returns a new instance of Slave.



5
6
7
8
9
# File 'lib/buffet/slave.rb', line 5

def initialize user, host, project
  @user = user
  @host = host
  @project = project
end

Instance Attribute Details

#hostObject (readonly)

Returns the value of attribute host.



3
4
5
# File 'lib/buffet/slave.rb', line 3

def host
  @host
end

#userObject (readonly)

Returns the value of attribute user.



3
4
5
# File 'lib/buffet/slave.rb', line 3

def user
  @user
end

Instance Method Details

#execute(command) ⇒ Object



27
28
29
# File 'lib/buffet/slave.rb', line 27

def execute command
  Buffet.run! 'ssh', "#{user_at_host}", command
end

#execute_in_project(command) ⇒ Object



23
24
25
# File 'lib/buffet/slave.rb', line 23

def execute_in_project command
  execute "cd #{@project.directory_on_slave} && #{command}"
end

#nameObject



31
32
33
# File 'lib/buffet/slave.rb', line 31

def name
  user_at_host
end

#rsync(src, dest) ⇒ Object



11
12
13
14
15
# File 'lib/buffet/slave.rb', line 11

def rsync src, dest
  Buffet.run! 'rsync', '-aqz', '--delete',
              '--delete-excluded', rsync_exclude_flags,
              '-e', 'ssh', src, "#{user_at_host}:#{dest}"
end

#scp(src, dest, options = {}) ⇒ Object



17
18
19
20
21
# File 'lib/buffet/slave.rb', line 17

def scp src, dest, options = {}
  args = [src, "#{user_at_host}:#{dest}"]
  args.unshift '-r' if options[:recurse]
  Buffet.run! 'scp', *args
end

#user_at_hostObject



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

def user_at_host
  "#{@user}@#{@host}"
end