Sha256: b8d66d8b9d21312e6a0c97b8bf3ef4901103f334c47e8de726f14420f850de9f

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 "sh -c '#{command_array.joined_by_semi_colon}'", :as => user
        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.1.1 lib/delta_capistrano/configuration/actions/run_in_shell.rb