Module: Flynn::Helpers

Included in:
Recipes::NodeWeb, Recipes::RvmBase
Defined in:
lib/flynn/helpers.rb

Instance Method Summary collapse

Instance Method Details

#create_file(name, content) ⇒ Object



15
16
17
18
19
# File 'lib/flynn/helpers.rb', line 15

def create_file(name, content)
  throw Exception.new("File exists: #{name}") if File.exists?(name)
  File.open(name, 'w') { |f| f.write content }
  return true
end

#executable_path(cmd) ⇒ Object



21
22
23
24
25
26
27
# File 'lib/flynn/helpers.rb', line 21

def executable_path(cmd)
  ENV['PATH'].split(':').each do |folder|
    path = folder+'/'+cmd
    return path if File.exists?(path)
  end
  nil
end

#inside(dir) ⇒ Object



3
4
5
6
7
8
# File 'lib/flynn/helpers.rb', line 3

def inside(dir)
  current_dir = Dir.pwd
  Dir.chdir(dir)
  yield
  Dir.chdir(current_dir)
end

#run(cmd) ⇒ Object



10
11
12
13
# File 'lib/flynn/helpers.rb', line 10

def run(cmd)
  puts "Running: #{cmd}"
  system(cmd)
end