The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

MozRepl::AnyEvent - AnyEvent-enabled MozRepl client

SYNOPSIS

  use MozRepl::RemoteObject;
  $ENV{ MOZREPL_CLASS } = 'MozRepl::AnyEvent';
  my $bridge = MozRepl::RemoteObject->install_bridge();

This module provides a compatible API to MozRepl solely for what MozRepl::RemoteObject uses. It does not provide plugin support. If you want a fully compatible AnyEvent-enabled MozRepl, please consider porting Net::Telnet to AnyEvent::Handle.

Instead of using the process environment, you can also pass the backend class using the repl_class parameter in the constructor:

  use MozRepl::RemoteObject;
  my $bridge = MozRepl::RemoteObject->install_bridge(
      repl_class => 'MozRepl::AnyEvent',
  );

The module in repl_class will be loaded through require. If the module does not load, the fatal error will propagate. No fallbacks are tried.

METHODS

MozRepl::AnyEvent->new( %options )

Creates a new instance.

Options

  • log - arrayref of log levels to enable

    Currently only debug is implemented, which will dump some information.

      log => [qw[debug],
  • hdl - a premade AnyEvent::Handle to talk to Firefox (optional)

  • prompt - the regex that defines the repl prompt to look for.

    Default is

      prompt => qr/^(?:\.+>\s)*(repl\d*)>\s+/m

$repl->log( $level, @info )

Prints the information to STDERR if logging is enabled for the level.

$repl->setup_async( $options )

  my $repl = MozRepl::AnyEvent->setup({
      client => { host => 'localhost',
                  port => 4242,
                },
       log   => ['debug'],
       cv    => $cv,
  });

Sets up the repl connection. See MozRepl::setup for detailed documentation.

The optional CV will get the repl through ->send().

Returns the CV to wait on that signals when setup is done.

$repl->setup(...)

Synchronous version of ->setup_async, provided for API compatibility. This one will do a ->recv call inside.

$repl->repl

Returns the name of the repl in Firefox.

$repl->hdl

Returns the socket handle of the repl.

$repl->execute_async( $command, $cb )

    my $cv = $repl->execute_async( '1+1' );
    # do stuff
    my $two = $cv->recv;
    print "1+1 is $two\n";

Sends a command to Firefox for execution. Returns the condvar to wait for the response.

$repl->execute( ... )

Synchronous version of ->execute_async. Internally calls ->recv. Provided for API compatibility.

SEE ALSO

MozRepl for the module defining the API

AnyEvent for AnyEvent

REPOSITORY

The public repository of this module is http://github.com/Corion/mozrepl-remoteobject.

AUTHOR

Max Maischein corion@cpan.org

COPYRIGHT (c)

Copyright 2009-2012 by Max Maischein corion@cpan.org.

LICENSE

This module is released under the same terms as Perl itself.