Class: Blimpy::Livery::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/blimpy/livery/base.rb

Direct Known Subclasses

CWD

Instance Method Summary collapse

Instance Method Details

#can_rsync?(box) ⇒ Boolean

Returns:

  • (Boolean)


32
33
34
# File 'lib/blimpy/livery/base.rb', line 32

def can_rsync?(box)
  @can_rsync ||= box.ssh_into('-q', 'which rsync > /dev/null')
end

#dir_nameObject



55
56
57
# File 'lib/blimpy/livery/base.rb', line 55

def dir_name
  File.basename(livery_root)
end

#flight(*args) ⇒ Object

Raises:

  • (NotImplementedError)


8
9
10
# File 'lib/blimpy/livery/base.rb', line 8

def flight(*args)
  raise NotImplementedError
end

#livery_rootObject



51
52
53
# File 'lib/blimpy/livery/base.rb', line 51

def livery_root
  Dir.pwd
end

#postflight(*args) ⇒ Object



12
13
# File 'lib/blimpy/livery/base.rb', line 12

def postflight(*args)
end

#preflight(*args) ⇒ Object



5
6
# File 'lib/blimpy/livery/base.rb', line 5

def preflight(*args)
end

#rsync_commandObject



19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/blimpy/livery/base.rb', line 19

def rsync_command
  excludes = rsync_excludes.map { |x| "--exclude=#{x}" }

  if File.exists? '.blimpignore'
    excludes << '--exclude-from=.blimpignore'
  end

  ['rsync',
   '-avL',
   '-e',
   'ssh -o StrictHostKeyChecking=no'] + excludes
end

#rsync_excludesObject



15
16
17
# File 'lib/blimpy/livery/base.rb', line 15

def rsync_excludes
  ['.git', '.svn', '.blimpy.d']
end

#setup_on(box) ⇒ Object



59
60
61
# File 'lib/blimpy/livery/base.rb', line 59

def setup_on(box)
  sync_to(box)
end

#sync_to(box) ⇒ Object



36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/blimpy/livery/base.rb', line 36

def sync_to(box)
  if can_rsync? box
    command = rsync_command + ['.', "#{box.username}@#{box.dns}:#{dir_name}/"]
    box.run_command(*command)
  else
    puts "Remote host has no rsync(1), falling back to copying a full tarball over"
    tarball = Blimpy::Livery.tarball_directory(livery_root)
    box.scp_file(tarball)
    # HAXX
    basename = File.basename(tarball)
    box.ssh_into("tar -zxf #{basename} && cd #{dir_name}")
  end

end