Class: Skewer::Source
- Inherits:
-
Object
- Object
- Skewer::Source
- Defined in:
- lib/source.rb
Overview
responsible for moving source to remote nodes
Instance Method Summary collapse
- #create_destination(node) ⇒ Object
- #excludes ⇒ Object
-
#initialize(path = nil) ⇒ Source
constructor
A new instance of Source.
- #mock_rsync(command) ⇒ Object
- #real_rsync(node, command) ⇒ Object
- #rsync(node) ⇒ Object
- #rsync_command(node) ⇒ Object
Constructor Details
Instance Method Details
#create_destination(node) ⇒ Object
16 17 18 19 20 21 22 23 |
# File 'lib/source.rb', line 16 def create_destination(node) begin node.ssh('mkdir -p infrastructure') rescue location = @util.get_location(node) raise "Couldn't SSH to #{location} with #{node.username}" end end |
#excludes ⇒ Object
12 13 14 |
# File 'lib/source.rb', line 12 def excludes '--exclude Gemfile --exclude Gemfile.lock --exclude ' + ['.git'].join(' ') end |
#mock_rsync(command) ⇒ Object
30 31 32 |
# File 'lib/source.rb', line 30 def mock_rsync(command) Skewer.logger.debug "MOCK: #{command}" end |
#real_rsync(node, command) ⇒ Object
34 35 36 37 |
# File 'lib/source.rb', line 34 def real_rsync(node, command) location = @util.get_location(node) raise "Failed to rsync to #{location} with #{node.username}" unless system(command) end |
#rsync(node) ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/source.rb', line 39 def rsync(node) location = @util.get_location(node) Skewer.logger.debug "Copying code to #{location} ..." create_destination(node) command = self.rsync_command(node) if node.class.to_s =~ /StubNode/ mock_rsync(command) else real_rsync(node, command) end Skewer.logger.debug " Done." end |
#rsync_command(node) ⇒ Object
25 26 27 28 |
# File 'lib/source.rb', line 25 def rsync_command(node) location = @util.get_location(node) "rsync #{self.excludes} --delete -arpze ssh #{@path}/. #{node.username}@#{location}:infrastructure/." end |