Sha256: 8963d08a16780f9239e2a1d1aa134b32eaf0e9671e91b438a5e4b4ccb64faa55

Contents?: true

Size: 721 Bytes

Versions: 1

Compression:

Stored size: 721 Bytes

Contents

module DeltaCapistrano
  module Configuration
    module Actions
      
      module RunInShell

        def in_a_shell_as(user, cmd = "")
          command_array = array_of_commands
          
          command_array << cmd
          
          yield command_array  if block_given?

          sudo "su - #{user} sh -c '#{command_array.joined_by_semi_colon}'"
        end

        private

        def array_of_commands
          a = []
          
          def a.run(command_string)
            self <<  command_string
          end

          def a.joined_by_semi_colon
            reject {|s| s.nil? || s == ""  }.join("; ")
          end
          
          return a
        end

      end
      
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
delta-capistrano-0.2.0 lib/delta_capistrano/configuration/actions/run_in_shell.rb