Sha256: 176264f0520f52c71a6e50ce70ee6523a50e49cb0e91aa986424396daf12f4d2

Contents?: true

Size: 949 Bytes

Versions: 3

Compression:

Stored size: 949 Bytes

Contents

module CapistranoExtensions

  module Invocation
    def local_run(*args, &block)
      args.pop if Hash===args.last
      args = args.first
      logger.debug "executing locally: #{args}"
      system args
    end
    
    def sudo_as(*args, &block)
      options = Hash===args.last ? args.pop.dup :  {}
      options[:as] = fetch(:runner, nil)
      sudo *args.push(options), &block
    end
    
    def sudo_su(*args, &block)
      options = Hash===args.last ? args.pop.dup :  {}
      args[0] = "su #{fetch(:runner, nil)} -c '#{args[0]}'"
      sudo *args.push(options), &block
    end
    
    def sudo_su_to(*args, &block)
      options = Hash===args.last ? args.pop.dup :  {}
      options[:shell] = false
      cmd = args[0].gsub(/[$\\`"]/) { |m| "\\#{m}" }
      args[0] = "echo \"#{cmd}\" | #{sudo} su - #{fetch(:runner, nil)}"
      run *args.push(options), &block
    end
  end

  Capistrano::Configuration.send :include, Invocation
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
joekhoobyar-capistrano-extensions-0.0.5 lib/capistrano_extensions/invocation.rb
joekhoobyar-capistrano-extensions-0.0.7 lib/capistrano_extensions/invocation.rb
joekhoobyar-capistrano-extensions-0.0.8 lib/capistrano_extensions/invocation.rb