Sha256: 1ba215d84bcaf3b80817da4f38421b9b770b993be1602e67b575089ba4a2e9cd

Contents?: true

Size: 1.17 KB

Versions: 2

Compression:

Stored size: 1.17 KB

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

    #
    # Executes a command.
    #
    # @param [String] command
    #   The command to be executed.
    #
    # @since 0.5.2
    #
    def exec(command)
      system(command)
    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.4 lib/deployml/local_shell.rb
deployml-0.5.2 lib/deployml/local_shell.rb