Project

justrun

0.0
No commit activity in last 3 years
No release in over 3 years
Wraps popen3 in a nice interface that allows to just run a command and get live stdout and stderr on line by line basis using a callback. Additionally a live chat with a command can be implemented with a buffered non-blocking writer that's working out of the box.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
 Dependencies

Development

= 3.2.0
= 3.2.0
 Project Readme

ruby-justrun

Wraps popen3 in a nice interface that allows to just run a command and get live stdout and stderr on line by line basis using a callback

Install

gem install justrun

or add to your Gemfile

gem 'justrun', '~> 1.0.1'

Examples

  • Just run and forget
JustRun.command 'echo foo && echo bar>&2' do |line, type|
  puts "#{type}: #{line}"
end
  • Using writer to communicate with the process
JustRun.command 'read line; echo $line; read line; echo $line',
init: ->(writer) { writer.puts 'hello' } do |line, _, writer|
    if line == 'hello'
      writer.puts 'world'
    elsif line == 'world'
      puts "GOT WORLD, THE CHAT WORKS!"
    end
  end
end

Writer interface

  • writer.end str = '' - end stdin once every byte is written, optionally provide some data to write before end
  • writer.write str - queue some data to write to the process, data will be written automatically as the process reads it
  • writer.puts str - same as write but add newline to str

License

MIT