Sha256: 32c5e7b3f271bb9e570dbaee9b741124e69e7542ff38d2ea765563f3f52bb71c

Contents?: true

Size: 1.22 KB

Versions: 13

Compression:

Stored size: 1.22 KB

Contents

module Beet
  module Execution
    # Executes a command
    #
    # ==== Example
    #
    #   inside('vendor') do
    #     run('ln -s ~/edge rails)
    #   end
    #
    def run(command, log_action = true)
      log 'executing',  "#{command} from #{Dir.pwd}" if log_action
      system(command)
    end

    # Executes a command with sudo
    #
    # ==== Example
    #
    #   inside('vendor') do
    #     sudo('mkdir /var/log/something')
    #   end
    #
    def sudo(command, log_action = true)
      command = "#{SUDO}#{command}"
      run(command,log_action)
    end

    # Executes a ruby script (taking into account WIN32 platform quirks)
    def run_ruby_script(command, log_action = true)
      ruby_command = RUBY_PLATFORM=~ /win32/ ? 'ruby ' : ''
      run("#{ruby_command}#{command}", log_action)
    end

    # Runs the supplied rake task
    #
    # ==== Example
    #
    #   rake("db:migrate")
    #   rake("db:migrate", :env => "production")
    #   rake("gems:install", :sudo => true)
    #
    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
  end
end

Version data entries

13 entries across 13 versions & 2 rubygems

Version Path
jackdempsey-beet-0.2.1 lib/beet/execution.rb
jackdempsey-beet-0.2.2 lib/beet/execution.rb
jackdempsey-beet-0.3.0 lib/beet/execution.rb
jackdempsey-beet-0.3.1 lib/beet/execution.rb
beet-0.5.0 lib/beet/execution.rb
beet-0.4.6 lib/beet/execution.rb
beet-0.4.5 lib/beet/execution.rb
beet-0.4.4 lib/beet/execution.rb
beet-0.4.3 lib/beet/execution.rb
beet-0.4.2 lib/beet/execution.rb
beet-0.4.1 lib/beet/execution.rb
beet-0.4.0 lib/beet/execution.rb
beet-0.3.1 lib/beet/execution.rb