Sha256: 3fc2c35dd64f251c3d52c463016a96bc4b263baafecb403232e2a65e920feb8f

Contents?: true

Size: 613 Bytes

Versions: 23

Compression:

Stored size: 613 Bytes

Contents

# encoding: utf-8
module LocalPac
  class Runner
    private

    attr_reader :command, :stdout

    public

    def initialize(command)
      @command = command
    end

    def run
      stdout, stderr, status = Open3.capture3(command)
      fail RuntimeError, "Error executing command #{command}: #{stderr}, #{stdout}" unless status.success?

      @stdout = stdout.split("\n")
    rescue Errno::ENOENT => e
      fail RuntimeError, "Error executing command #{command}: #{stderr}, #{e.message}"
    end

    def result
      $stderr.puts command if LocalPac.debug_mode
      run
      stdout
    end
  end
end

Version data entries

23 entries across 23 versions & 1 rubygems

Version Path
local_pac-0.1.2 lib/local_pac/runner.rb
local_pac-0.1.1 lib/local_pac/runner.rb
local_pac-0.1.0 lib/local_pac/runner.rb