Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Miscellaneous fixes #2

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
19 changes: 10 additions & 9 deletions lib/POE/Component/OpenSSH.pm
Expand Up @@ -9,12 +9,12 @@ use Moose;
use Net::OpenSSH; use Net::OpenSSH;
use POE::Component::Generic; use POE::Component::Generic;


has 'args' => ( is => 'ro', isa => 'ArrayRef', default => sub { [] } ); has 'args' => ( is => 'ro', isa => 'ArrayRef', default => sub { [] } );
has 'options' => ( is => 'ro', isa => 'HashRef', default => sub { {} } ); has 'options' => ( is => 'ro', isa => 'HashRef', default => sub { {} } );
has 'error' => ( is => 'ro', isa => 'HashRef', default => sub { {} } ); has 'error' => ( is => 'ro', isa => 'HashRef|Str', default => sub { {} } );
has 'alias' => ( is => 'ro', isa => 'Str', default => q{} ); has 'alias' => ( is => 'ro', isa => 'Str', default => q{} );
has 'debug' => ( is => 'ro', isa => 'Bool', default => 0 ); has 'debug' => ( is => 'ro', isa => 'Bool', default => 0 );
has 'verbose' => ( is => 'ro', isa => 'Bool', default => 0 ); has 'verbose' => ( is => 'ro', isa => 'Bool', default => 0 );


has 'object' => ( has 'object' => (
is => 'rw', is => 'rw',
Expand All @@ -26,14 +26,14 @@ has 'object' => (
sub _build_object { sub _build_object {
my $self = shift; my $self = shift;


my @optional = ( qw( alias debug verbose options ) );
my $object = POE::Component::Generic->spawn( my $object = POE::Component::Generic->spawn(
alias => $self->alias, alias => $self->alias,
package => 'Net::OpenSSH', package => 'Net::OpenSSH',
object_options => $self->args, object_options => $self->args,
debug => $self->debug, debug => $self->debug,
verbose => $self->verbose, verbose => $self->verbose,
error => $self->error, error => $self->error,
options => $self->options,
); );


return $object; return $object;
Expand Down Expand Up @@ -95,6 +95,7 @@ Here is a more elaborate example using L<MooseX::POE>:


package Runner; package Runner;
use MooseX::POE; use MooseX::POE;
use POE::Component::Generic;


has 'host' => ( is => 'ro', isa => 'Str', default => 'localhost' ); has 'host' => ( is => 'ro', isa => 'Str', default => 'localhost' );
has 'user' => ( is => 'ro', isa => 'Str', default => 'root' ); has 'user' => ( is => 'ro', isa => 'Str', default => 'root' );
Expand All @@ -111,11 +112,11 @@ Here is a more elaborate example using L<MooseX::POE>:
], ],
); );


$ssh->capture( { event => 'parse_cmd' }, $cmd ); $ssh->capture( { event => 'parse_cmd' }, $self->cmd );
} }


event 'parse_cmd' => sub { event 'parse_cmd' => sub {
my ( $self, $output ) @_[ OBJECT, ARG1 ]; my ( $self, $output ) = @_[ OBJECT, ARG1 ];
my $host = $self->host; my $host = $self->host;
print "[$host]: $output"; print "[$host]: $output";
}; };
Expand Down