Module: Visionbundles::Helpers::Servers

Defined in:
lib/visionbundles/helpers/servers.rb

Instance Method Summary collapse

Instance Method Details

#current_serverObject



26
27
28
# File 'lib/visionbundles/helpers/servers.rb', line 26

def current_server
  capture("echo $CAPISTRANO:HOST$").strip
end

#mkdir(remote_path) ⇒ Object



22
23
24
# File 'lib/visionbundles/helpers/servers.rb', line 22

def mkdir(remote_path)
  run "mkdir -p #{remote_path}"
end

#remote_file_exists?(path) ⇒ Boolean

Returns:

  • (Boolean)


4
5
6
7
8
9
10
11
12
# File 'lib/visionbundles/helpers/servers.rb', line 4

def remote_file_exists?(path)
  results = []

  invoke_command("if [ -f '#{path}' ]; then echo -n 'true'; fi") do |ch, stream, out|
    results << (out == 'true')
  end

  !results.empty?
end

#run_if_file_exists?(path, command) ⇒ Boolean

Returns:

  • (Boolean)


14
15
16
# File 'lib/visionbundles/helpers/servers.rb', line 14

def run_if_file_exists?(path, command)
  run "if [ -f '#{path}' ]; then #{command}; fi"
end

#run_if_file_not_exists?(path, command) ⇒ Boolean

Returns:

  • (Boolean)


18
19
20
# File 'lib/visionbundles/helpers/servers.rb', line 18

def run_if_file_not_exists?(path, command)
  run "if [ ! -f '#{path}' ]; then #{command}; fi"
end