Sha256: cb4037befe62ca1c5961b708c0d78772f3a34be0625c0d55814d04978a1ccb5e

Contents?: true

Size: 1.26 KB

Versions: 17

Compression:

Stored size: 1.26 KB

Contents

# frozen_string_literal: true

module Cri
  # A command runner is responsible for the execution of a command. Using it
  # is optional, but it is useful for commands whose execution block is large.
  class CommandRunner
    # @return [Hash] A hash contain the options and their values
    attr_reader :options

    # @return [Array] The list of arguments
    attr_reader :arguments

    # @return [Command] The command
    attr_reader :command

    # Creates a command runner from the given options, arguments and command.
    #
    # @param [Hash] options A hash contain the options and their values
    #
    # @param [Array] arguments The list of arguments
    #
    # @param [Cri::Command] command The Cri command
    def initialize(options, arguments, command)
      @options   = options
      @arguments = arguments
      @command   = command
    end

    # Runs the command. By default, this simply does the actual execution, but
    # subclasses may choose to add error handling around the actual execution.
    #
    # @return [void]
    def call
      run
    end

    # Performs the actual execution of the command.
    #
    # @return [void]
    #
    # @abstract
    def run
      raise NotImplementedError, 'Cri::CommandRunner subclasses must implement #run'
    end
  end
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
cri-2.15.12 lib/cri/command_runner.rb
cri-2.15.11 lib/cri/command_runner.rb
cri-2.15.10 lib/cri/command_runner.rb
cri-2.15.9 lib/cri/command_runner.rb
cri-2.15.8 lib/cri/command_runner.rb
cri-2.15.7 lib/cri/command_runner.rb
cri-2.15.6 lib/cri/command_runner.rb
cri-2.15.5 lib/cri/command_runner.rb
cri-2.15.4 lib/cri/command_runner.rb
cri-2.15.3 lib/cri/command_runner.rb
cri-2.15.2 lib/cri/command_runner.rb
cri-2.15.1 lib/cri/command_runner.rb
cri-2.15.0 lib/cri/command_runner.rb
cri-2.14.0 lib/cri/command_runner.rb
cri-2.13.0 lib/cri/command_runner.rb
cri-2.12.0 lib/cri/command_runner.rb
cri-2.11.0 lib/cri/command_runner.rb