Sha256: 5bee96350ea8fab599cdc3b8cd9a1903b65ec85458b48ab5a2b6da181e1a9faf

Contents?: true

Size: 581 Bytes

Versions: 2

Compression:

Stored size: 581 Bytes

Contents

# encoding: utf-8
module Git
  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}" unless status.success?

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

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

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
git_hook-pre_receive-0.1.0 lib/git_hook-pre_receive/runner.rb
git_hook-pre_receive-0.0.2 lib/git_hook-pre_receive/runner.rb