Skip to content

hercynium/IPC-Pipeline-Composable

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

24 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

NAME

IPC::Pipeline::Composable - compose commands and pipelines

VERSION

version 0.001

METHODS

new

Standard constructor.

  • procs - an arrayref of processes you want in this pipeline.

procs

Get the list of processes that make up this pipeline

pids

When the pipeline is running, get the list of process IDs. Please note - they may not all be running. Checking them is your (or another module's) job.

run

Run the pipeline with the given inputs and outputs

TODO: describe the arguments

Construct a pipeline from a series of commands, placeholders or other pipelines

Arguments represent processes to run, and each can be any one of the following:

  • arrayref - ['sort', '-k2,2', '-g']

  • subref - sub { print map { join '', @$_ } sort { $a->[1] <=> $b->[1] } map { [split] } <> }

  • Object of type IPC::Pipeline::Composable::Process or IPC::Pipeline::Composable

    my $pl = ipc_pipeline($obj, &some_sub, @some_array, ...)

Construct a process from a command and a series of arguments or placeholders

Turn a pipeline or process into a process substitution

Construct a placeholder with a name and arguments

TODO: describe arguments

SEE ALSO: the new() method in IPC::Pipeline::Composable::Placeholder

Notes to self:

The desired feature is to have shell-like process-substitution.

The way to do that in the API is to pass a pipeline or command as the argument for a command.

examples:
  my $pl = ipc_pipeline(ipc_cmd('gunzip', '-c', ipc_sub('<', 'gzip -c', $0)));
  my $pl = ipc_pipeline(ipc_cmd('gunzip', '-c', ipc_sub('<', ipc_cmd('gzip -c', $0))));

Technically, a command should just be a single-command pipeline.
    my $pl = ipc_cmd('gunzip', '-c', ipc_sub('<', 'gzip -c', $0));

And of course, placeholders...
    my $pl = ipc_cmd('gunzip', '-c', ipc_sub('<', 'gzip -c', ipc_placeholder('file')));
    $pl->run(sink => $sink_fh, file => $0);

To get really silly, perhaps this should work:
    $pl->run(sink_fh => $sink_fh, file => sub{ open my $f, '<', $0; print lc while <$f>; 1 });
  Description:
    - put a perl process that reads the current script as lowercase in the file placeholder
    - connect the stdout of that perl process to a fifo
    - pass the name of the fifo as an argument to gzip -c
    - connect the stdout of gzip to a fifo
    - pass the name of that fifo as an argument to gunzip -c
    - connect the stdout of gunzip to the sink_fh so it will write to it
    * the result should be the script, in lowercase.

What should really happen:
  - see the ipc_sub when scanning the gunzip command's args
  - create a fifo/named pipe (store the path in a hash assocuated to the ipc_sub)
  - start the gunzip process with its output connected to $sink_fh, passing the fifo as an argument in place of the ipc_sub
  - start the gzip process with its output connected to the fifo for writing

=end notes

AUTHOR

Stephen R. Scaffidi stephen@scaffidi.net

COPYRIGHT AND LICENSE

This software is copyright (c) 2012 by Stephen R. Scaffidi.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.

EXTENDS

SUPPORT

Perldoc

You can find documentation for this module with the perldoc command.

perldoc IPC::Pipeline::Composable

Websites

The following websites have more information about this module, and may be of help to you. As always, in addition to those websites please use your favorite search engine to discover more resources.

  • MetaCPAN

A modern, open-source CPAN search engine, useful to view POD in HTML format.

http://metacpan.org/release/IPC-Pipeline-Composable

  • Search CPAN

The default CPAN search engine, useful to view POD in HTML format.

http://search.cpan.org/dist/IPC-Pipeline-Composable

  • RT: CPAN's Bug Tracker

The RT ( Request Tracker ) website is the default bug/issue tracking system for CPAN.

http://rt.cpan.org/NoAuth/Bugs.html?Dist=IPC-Pipeline-Composable

  • AnnoCPAN

The AnnoCPAN is a website that allows community annotations of Perl module documentation.

http://annocpan.org/dist/IPC-Pipeline-Composable

  • CPAN Ratings

The CPAN Ratings is a website that allows community ratings and reviews of Perl modules.

http://cpanratings.perl.org/d/IPC-Pipeline-Composable

  • CPAN Forum

The CPAN Forum is a web forum for discussing Perl modules.

http://cpanforum.com/dist/IPC-Pipeline-Composable

  • CPANTS

The CPANTS is a website that analyzes the Kwalitee ( code metrics ) of a distribution.

http://cpants.perl.org/dist/overview/IPC-Pipeline-Composable

  • CPAN Testers

The CPAN Testers is a network of smokers who run automated tests on uploaded CPAN distributions.

http://www.cpantesters.org/distro/I/IPC-Pipeline-Composable

  • CPAN Testers Matrix

The CPAN Testers Matrix is a website that provides a visual overview of the test results for a distribution on various Perls/platforms.

http://matrix.cpantesters.org/?dist=IPC-Pipeline-Composable

  • CPAN Testers Dependencies

The CPAN Testers Dependencies is a website that shows a chart of the test results of all dependencies for a distribution.

http://deps.cpantesters.org/?module=IPC::Pipeline::Composable

Bugs / Feature Requests

Please report any bugs or feature requests by email to bug-ipc-pipeline-composable at rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=IPC-Pipeline-Composable. You will be automatically notified of any progress on the request by the system.

Source Code

The code is open to the world, and available for you to hack on. Please feel free to browse it and play with it, or whatever. If you want to contribute patches, please send me a diff or prod me to pull from your repository :)

https://github.com/Hercynium/IPC-Pipeline-Composable

git clone https://github.com/Hercynium/IPC-Pipeline-Composable.git

BUGS

Please report any bugs or feature requests to bug-ipc-pipeline-composable@rt.cpan.org or through the web interface at: http://rt.cpan.org/Public/Dist/Display.html?Name=IPC-Pipeline-Composable

About

Compose together commands and processes to form pipelines

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages