This repository has been archived by the owner on Jan 25, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 108
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Relocate and update dependencies Signed-off-by: Sandy Cash <[email protected]>
- Loading branch information
Michael Fraenkel
authored and
Anonymous Coward
committed
Jan 8, 2016
1 parent
09c37bf
commit 3916db2
Showing
10 changed files
with
1,188 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
source "http://rubygems.org" | ||
gemspec |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
PATH | ||
remote: . | ||
specs: | ||
em-posix-spawn (0.1.10) | ||
eventmachine | ||
posix-spawn | ||
|
||
GEM | ||
remote: http://rubygems.org/ | ||
specs: | ||
eventmachine (1.0.8) | ||
minitest (5.8.3) | ||
posix-spawn (0.3.11) | ||
rake (10.4.2) | ||
|
||
PLATFORMS | ||
ruby | ||
|
||
DEPENDENCIES | ||
em-posix-spawn! | ||
minitest | ||
rake | ||
|
||
BUNDLED WITH | ||
1.11.2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
# `em-posix-spawn` | ||
|
||
This module provides an interface to `POSIX::Spawn` for EventMachine. In | ||
particular, it contains an EventMachine equivalent to `POSIX::Spawn::Child`. | ||
This class encapsulates writing to the child process its stdin and reading from | ||
both its stdout and stderr. Only when the process has exited, it triggers a | ||
callback to notify others of its completion. Just as `POSIX::Spawn::Child`, | ||
this module allows the caller to include limits for execution time and number | ||
of bytes read from stdout and stderr. | ||
|
||
# Usage | ||
|
||
Please refer to the documentation of `POSIX::Spawn::Child` for the complete set | ||
of options that can be passed when creating `Child`. | ||
|
||
```ruby | ||
require "em/posix/spawn" | ||
|
||
EM.run { | ||
p = EM::POSIX::Spawn::Child.new("echo something") | ||
|
||
p.callback { | ||
puts "Child process echo'd: #{p.out.inspect}" | ||
EM.stop | ||
} | ||
|
||
p.errback { |err| | ||
puts "Error running child process: #{err.inspect}" | ||
EM.stop | ||
} | ||
|
||
# Add callbacks to listen to the child process' output streams. | ||
listeners = p.add_streams_listener { |listener, data| | ||
# Do something with the data. | ||
# Use listener.name to get the name of the stream. | ||
# Use listener.closed? to check if listener is closed. | ||
# This block is called exactly once after the listener is closed. | ||
} | ||
|
||
# Optionally, wait for all the listeners to be closed. | ||
while !listeners.all?(&:closed?) { | ||
... | ||
} | ||
|
||
# Sends SIGTERM to the process, and SIGKILL after 5 seconds. | ||
# Returns true if this kill was successful, false otherwise. | ||
# The timeout is optional, default timeout is 0 (immediate SIGKILL | ||
# after SIGTERM). | ||
p.kill(5) | ||
} | ||
``` | ||
|
||
# Credit | ||
|
||
The implementation for `EM::POSIX::Spawn::Child` and its tests are based on the | ||
implementation and tests for `POSIX::Spawn::Child`, which is Copyright (c) 2011 | ||
by Ryan Tomayko <[email protected]> and Aman Gupta <[email protected]>. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
require "bundler/gem_tasks" | ||
|
||
require 'rake/testtask' | ||
|
||
Rake::TestTask.new 'test' do |t| | ||
t.test_files = FileList['test/test_*.rb'] | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# -*- encoding: utf-8 -*- | ||
$:.push File.expand_path("../lib", __FILE__) | ||
require "em/posix/spawn/version" | ||
|
||
Gem::Specification.new do |s| | ||
s.name = "em-posix-spawn" | ||
s.version = EventMachine::POSIX::Spawn::VERSION | ||
|
||
s.authors = ["Pieter Noordhuis"] | ||
s.email = ["[email protected]"] | ||
s.summary = "EventMachine-aware POSIX::Spawn::Child" | ||
|
||
s.files = Dir.glob("lib/**/*") | ||
s.test_files = Dir.glob("test/**/*") | ||
s.require_paths = ["lib"] | ||
|
||
s.add_runtime_dependency "eventmachine" | ||
s.add_runtime_dependency "posix-spawn" | ||
s.add_development_dependency "rake" | ||
s.add_development_dependency "minitest" | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
require "em/posix/spawn" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
require "em/posix/spawn/version" | ||
require "em/posix/spawn/child" |
Oops, something went wrong.