Sha256: bd18fa421e36033a2efe12125e9b698d6c3764e04b03a591a27a5534cab8c52f

Contents?: true

Size: 792 Bytes

Versions: 7

Compression:

Stored size: 792 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] ? opts[:stdin].read : '',
          stdout: opts[:stdout] || $stdout,
          stderr: opts[:stderr] || $stderr
        }
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
lino-4.2.0.pre.2 lib/lino/executors/open4.rb
lino-4.2.0.pre.1 lib/lino/executors/open4.rb
lino-4.1.0 lib/lino/executors/open4.rb
lino-4.1.0.pre.2 lib/lino/executors/open4.rb
lino-4.1.0.pre.1 lib/lino/executors/open4.rb
lino-4.0.0 lib/lino/executors/open4.rb
lino-4.0.0.pre.2 lib/lino/executors/open4.rb