Sha256: 9164867704f28952f39818b76abf762a388f482139f652ece79db8ab99c9c21d

Contents?: true

Size: 552 Bytes

Versions: 2

Compression:

Stored size: 552 Bytes

Contents

require 'subprocess'

module Todidnt
  class GitCommand
    def initialize(command, options)
      @command = command
      @options = options

      @process = Subprocess::Process.new(command_with_options, :stdout => Subprocess::PIPE)
    end

    def execute!(&blk)
      @process.stdout.each_line do |line|
        yield line.chomp
      end
    end

    def command_with_options
      full_command = @command.to_s

      for option in @options
        full_command << " #{option.join(' ')}"
      end

      "git #{full_command}"
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
todidnt-0.4.1 lib/todidnt/git_command.rb
todidnt-0.3.1 lib/todidnt/git_command.rb