MozRepl::Plugin::Repl::Load - Load external script


MozRepl documentation Contained in the MozRepl distribution.

Index


Code Index:

NAME

Top

MozRepl::Plugin::Repl::Load - Load external script

VERSION

Top

version 0.01

SYNOPSIS

Top

    use MozRepl;

    my $repl = MozRepl->new;
    $repl->setup({ plugins => { plugins => [qw/Repl::Load/] } });

    $repl->repl_load({
      uri => q|http://json.org/json.js|
    });
    print $repl->execute("String.prototype.toJSONString;");

DESCRIPTION

Top

Add repl_load() method to MozRepl.

METHODS

Top

execute($ctx, $args)

Load external script

$ctx

Context object. See MozRepl.

$args

Hash reference.

uri

External script location.

context

Default undefined.

SEE ALSO

Top

MozRepl::Plugin::Base
MozRepl::Util

AUTHOR

Top

Toru Yamaguchi, <zigorou@cpan.org>

BUGS

Top

Please report any bugs or feature requests to bug-mozrepl-plugin-repl-load@rt.cpan.org, or through the web interface at http://rt.cpan.org. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.

COPYRIGHT & LICENSE

Top


MozRepl documentation Contained in the MozRepl distribution.
package MozRepl::Plugin::Repl::Load;

use strict;
use warnings;

use base qw(MozRepl::Plugin::Base);

use MozRepl::Util;

our $VERSION = '0.01';

sub execute {
    my ($self, $ctx, $args) = @_;

    my $params = {};

    $params->{repl} = $ctx->repl;
    $params->{uri} = MozRepl::Util->javascript_value(MozRepl::Util->javascript_uri($args->{uri}));
    $params->{context} ||= MozRepl::Util->javascript_value(undef);

    my $command = $self->process('execute', $params);
    $ctx->execute($command);

    return 1;
}

1; # End of MozRepl::Plugin::Repl::Load

__DATA__
__execute__
[% repl %].load([% uri %], [% context %]);
__END__