lib/todidnt/git_command.rb in todidnt-0.2.0 vs lib/todidnt/git_command.rb in todidnt-0.3.1
- old
+ new
@@ -1,26 +1,28 @@
+require 'subprocess'
+
module Todidnt
class GitCommand
def initialize(command, options)
@command = command
@options = options
- end
- def output_lines
- run!.strip.split(/\n/)
+ @process = Subprocess::Process.new(command_with_options, :stdout => Subprocess::PIPE)
end
- def run!
- `git #{command_with_options}`
+ 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
- full_command
+ "git #{full_command}"
end
end
end