Sha256: 3811b8d0827c410487c85517211872a2106d09bc20d40266bc75cbc57fdd467a

Contents?: true

Size: 773 Bytes

Versions: 5

Compression:

Stored size: 773 Bytes

Contents

# frozen_string_literal: true

require 'open4'

module Lino
  module Executors
    class Open4
      def execute(command_line, opts = {})
        opts = with_defaults(opts)

        ::Open4.spawn(
          command_line.env,
          *command_line.array,
          stdin: opts[:stdin],
          stdout: opts[:stdout],
          stderr: opts[:stderr],
          cwd: command_line.working_directory
        )
      end

      def ==(other)
        self.class == other.class
      end

      alias eql? ==

      def hash
        self.class.hash
      end

      private

      def with_defaults(opts)
        {
          stdin: opts[:stdin] || '',
          stdout: opts[:stdout] || $stdout,
          stderr: opts[:stderr] || $stderr
        }
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
lino-3.2.0.pre.10 lib/lino/executors/open4.rb
lino-3.2.0.pre.9 lib/lino/executors/open4.rb
lino-3.2.0.pre.8 lib/lino/executors/open4.rb
lino-3.2.0.pre.7 lib/lino/executors/open4.rb
lino-3.2.0.pre.6 lib/lino/executors/open4.rb