Class: Buffet::Slave
- Inherits:
-
Object
- Object
- Buffet::Slave
- Defined in:
- lib/buffet/slave.rb
Instance Attribute Summary collapse
-
#host ⇒ Object
readonly
Returns the value of attribute host.
-
#user ⇒ Object
readonly
Returns the value of attribute user.
Instance Method Summary collapse
- #execute(command) ⇒ Object
- #execute_in_project(command) ⇒ Object
-
#initialize(user, host, project) ⇒ Slave
constructor
A new instance of Slave.
- #name ⇒ Object
- #rsync(src, dest) ⇒ Object
- #scp(src, dest, options = {}) ⇒ Object
- #user_at_host ⇒ Object
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
#host ⇒ Object (readonly)
Returns the value of attribute host.
3 4 5 |
# File 'lib/buffet/slave.rb', line 3 def host @host end |
#user ⇒ Object (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 |
#name ⇒ Object
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, = {} args = [src, "#{user_at_host}:#{dest}"] args.unshift '-r' if [:recurse] Buffet.run! 'scp', *args end |
#user_at_host ⇒ Object
35 36 37 |
# File 'lib/buffet/slave.rb', line 35 def user_at_host "#{@user}@#{@host}" end |