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 ' : ''
  rvm("#{ruby_command}#{command}", log_action)
end

#rvm(command, log_action = true) ⇒ Object

Installs the gems using the specified ruby if rvmrc recipe is included



51
52
53
54
# File 'lib/beet/command_execution.rb', line 51

def rvm(command, log_action = true)
  command = "rvm #{@ruby_version} exec #{command}" unless @ruby_version.nil?
  run(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