File: Loopback.pm

package info (click to toggle)
libnet-cli-interact-perl 2.142720-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 420 kB
  • ctags: 127
  • sloc: perl: 1,907; makefile: 2
file content (113 lines) | stat: -rw-r--r-- 2,331 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
package Net::CLI::Interact::Transport::Loopback;
{
  $Net::CLI::Interact::Transport::Loopback::VERSION = '2.142720';
}

use Moo;
use Sub::Quote;
use MooX::Types::MooseLike::Base qw(InstanceOf);

extends 'Net::CLI::Interact::Transport::Base';

{
    package # hide from pause
        Net::CLI::Interact::Transport::Loopback::Options;

    use Moo;
    extends 'Net::CLI::Interact::Transport::Options';
}

# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

has 'connect_options' => (
    is => 'ro',
    isa => InstanceOf['Net::CLI::Interact::Transport::Loopback::Options'],
    default => sub { {} },
    coerce => quote_sub(
        q{ Net::CLI::Interact::Transport::Loopback::Options->new(@_) if ref '' ne ref $_[0] }),
    required => 1,
);

#sub _which_perl {
#    use Config;
#    $secure_perl_path = $Config{perlpath};
#    if ($^O ne 'VMS')
#        {$secure_perl_path .= $Config{_exe}
#            unless $secure_perl_path =~ m/$Config{_exe}$/i;}
#    return $secure_perl_path;
#}

sub _build_app { return $^X }

sub runtime_options {
    return ('-ne', 'BEGIN { $| = 1 }; print $_, time, "\nPROMPT> ";');
}

1;

# ABSTRACT: Testable CLI connection


__END__
=pod

=head1 NAME

Net::CLI::Interact::Transport::Loopback - Testable CLI connection

=head1 VERSION

version 2.142720

=head1 DECRIPTION

This module provides a wrapped instance of Perl which simply echoes back any
input provided. This is used for the L<Net::CLI::Interact> test suite.

=head1 INTERFACE

=head2 app

Defaults to the value of C<$^X> (that is, Perl itself).

=head2 runtime_options

Returns Perl options which turn it into a CLI emulator:

 -ne 'BEGIN { $| = 1 }; print $_, time, "\nPROMPT>\n";'

For example:

 some command
 some command
 1301578196
 PROMPT>

In this case the output command was "some command" which was echoed, followed
by the dummy command output (epoch seconds), followed by a "prompt".

=head1 COMPOSITION

See the following for further interface details:

=over 4

=item *

L<Net::CLI::Interact::Transport::Base>

=back

=head1 AUTHOR

Oliver Gorwits <oliver@cpan.org>

=head1 COPYRIGHT AND LICENSE

This software is copyright (c) 2014 by Oliver Gorwits.

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

=cut