<commit_before>= tty-process-ctl

This gem was created to enable control of interactive terminal applications.
It is using pseudo TTY to communicate with the process via simple API.

For more advanced gem see also: https://github.com/avdi/greenletters

== Example

=== Reading program output

Here we run *ls* command and iterate its output:

  TTYProcessCtl.new('ls').each do |line|
  	puts line
  end

Result:

  Gemfile      LICENSE.txt  Rakefile     lib
  Gemfile.lock README.rdoc  examples     spec

=== Sending commands

This example show how to send command to *irb* process.
Output can be skipped with *wait_until* and iterated until pattern matches with *each_until*:

  irb = TTYProcessCtl.new('irb')
  
  # send command
  irb.send_command('2 + 2')
  
  # wait until prompt line was printed
  irb.wait_until(/:001 >/)
  
  # print all output lines until we get to the result line (including) 
  irb.each_until(/=>/) do |line|
  	puts line
  end
  
  # ask irb to quit
  irb.send_command('quit')
  
  # wait irb to exit
  irb.wait_exit

Result:

   => 4

== Timeout support

Normally *each* and *wait* methods will wait infinitely for event to happen.
They accept options hash as additional argument where *:timeout* key value will be respected as number of seconds after which the method will rise *TTYProcessCtl::Timeout* exception if awaited event did not happen:

   TTYProcessCtl.new('sleep 10').wait_until(/Done/, timeout: 1) => TTYProcessCtl::Timeout

== Contributing to tty-process-ctl
 
* Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet.
* Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it.
* Fork the project.
* Start a feature/bugfix branch.
* Commit and push until you are happy with your contribution.
* Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
* Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.

== Copyright
<commit_msg>README update<commit_after>= tty-process-ctl

This gem was created to enable control of interactive terminal applications.
It is using pseudo TTY to communicate with the process via simple API.

For more advanced gem see also: https://github.com/avdi/greenletters

== Example

=== Reading program output

Here we run *ls* command and iterate its output:

  TTYProcessCtl.new('ls').each do |line|
  	puts line
  end

Result:

  Gemfile      LICENSE.txt  Rakefile     lib
  Gemfile.lock README.rdoc  examples     spec

=== Sending commands

This example show how to send command to *irb* process.
Output can be skipped with *wait_until* and iterated until pattern matches with *each_until*:

  irb = TTYProcessCtl.new('irb')
  
  # send command
  irb.send_command('2 + 2')
  
  # wait until prompt line was printed
  irb.wait_until(/:001 >/)
  
  # print all output lines until we get to the result line (including) 
  irb.each_until(/=>/) do |line|
  	puts line
  end
  
  # ask irb to quit
  irb.send_command('quit')
  
  # wait irb to exit
  irb.wait_exit

Result:

   => 4

== Timeout support

Normally *each* and *wait* methods will wait infinitely for event to happen.
They accept options hash as additional argument where *:timeout* key value will be respected as number of seconds after which the method will rise *TTYProcessCtl*::*Timeout* exception if awaited event did not happen:

   TTYProcessCtl.new('sleep 10').wait_until(/Done/, timeout: 1) => TTYProcessCtl::Timeout

== Contributing to tty-process-ctl
 
* Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet.
* Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it.
* Fork the project.
* Start a feature/bugfix branch.
* Commit and push until you are happy with your contribution.
* Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
* Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.

== Copyright

{'fraction_non_alphanumeric': 0.07146129180027486, 'fraction_numerical': 0.004122766834631242, 'mean_word_length': 3.7570806100217866, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 11, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6454996', 'n_tokens_mistral': 1297, 'n_tokens_neox': 1246, 'n_words': 593}