Sha256: a1abc287b36a09c3f5236f56e4f68e7246c12061911bba6bcaeb79dceaba89ea

Contents?: true

Size: 607 Bytes

Versions: 1

Compression:

Stored size: 607 Bytes

Contents

require 'open3'

module ChoresKit
  module Executors
    class Shell
      attr_reader :name

      def initialize(name, attributes)
        @name = name
        @callee = attributes.fetch(:callee)
        @callable = attributes.fetch(:callable)
      end

      def friendly_name
        'Shell'
      end

      def command
        @callable.join(' ')
      end

      def run!
        output, status = Open3.capture2e(*@callable)

        raise "Running #{friendly_name} '#{@callable}' failed with status #{status.exitstatus}. Error message: #{output}" unless status.success?
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
chores_kit-0.2.5 lib/chores_kit/executors/shell.rb