Module: Beet::CommandExecution

Included in:
Executor
Defined in:
lib/beet/command_execution.rb

Instance Method Summary collapse

Instance Method Details

#rake(command, options = {}) ⇒ Object

Runs the supplied rake task

Example

rake("db:migrate")
rake("db:migrate", :env => "production")
rake("gems:install", :sudo => true)


43
44
45
46
47
48
# File 'lib/beet/command_execution.rb', line 43

def rake(command, options = {})
  log 'rake', command
  env = options[:env] || 'development'
  sudo = options[:sudo] ? 'sudo ' : ''
  in_root { run("#{sudo}rake #{command} RAILS_ENV=#{env}", false) }
end

#run(command, log_action = true) ⇒ Object

Executes a command

Example

inside('vendor') do
  run('ln -s ~/edge rails)
end


11
12
13
14
# File 'lib/beet/command_execution.rb', line 11

def run(command, log_action = true)
  log 'executing',  "#{command} from #{Dir.pwd}" if log_action
  system(command)
end

#run_ruby_script(command, log_action = true) ⇒ Object

Executes a ruby script (taking into account WIN32 platform quirks)



30
31
32
33
# File 'lib/beet/command_execution.rb', line 30

def run_ruby_script(command, log_action = true)
  ruby_command = RUBY_PLATFORM=~ /win32/ ? 'ruby ' : ''
  run("#{ruby_command}#{command}", log_action)
end

#sudo(command, log_action = true) ⇒ Object

Executes a command with sudo

Example

inside('vendor') do
  sudo('mkdir /var/log/something')
end


24
25
26
27
# File 'lib/beet/command_execution.rb', line 24

def sudo(command, log_action = true)
  command = "#{SUDO}#{command}"
  run(command,log_action)
end