Sha256: 0a152acf3d57d75d4c9c16c1ed928cb93a202b4527f5c0b13dfca4eaf246a1ca

Contents?: true

Size: 1011 Bytes

Versions: 2

Compression:

Stored size: 1011 Bytes

Contents

require 'deployml/shell'

module DeploYML
  #
  # Represents a shell running on the local system.
  #
  class LocalShell < Shell

    #
    # Runs a program locally.
    #
    # @param [String] program
    #   The name or path of the program to run.
    #
    # @param [Array<String>] arguments
    #   Additional arguments for the program.
    #
    def run(program,*arguments)
      program = program.to_s
      arguments = arguments.map { |arg| arg.to_s }

      system(program,*arguments)
    end

    #
    # Prints out a message.
    #
    # @param [String] message
    #   The message to print.
    #
    def echo(message)
      puts message
    end

    #
    # Changes the current working directory.
    #
    # @param [String] path
    #   The path of the new current working directory to use.
    #
    # @yield []
    #   If a block is given, then the directory will be changed back after
    #   the block has returned.
    #
    def cd(path,&block)
      Dir.chdir(path,&block)
    end

  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
deployml-0.5.1 lib/deployml/local_shell.rb
deployml-0.5.0 lib/deployml/local_shell.rb