Plugin/JSON2.pm untested

filter: Statementstmt 0.0% 0 / 20 Branchbran 0.0% 0 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 5 Podpod 0.0% 0 / 2 totaltotal 0.0% 0 / 29 CC 2 SCAR 12.0
CC
2
Cov
0%
execute
6.0
setup
2.0
BEGIN
2.0
CRAP 3.3
1 package MozRepl::Plugin::JSON2;
2 use strict;
3 use parent 'MozRepl::Plugin::Base';
4 use vars '$VERSION';
5  
6 =head1 NAME
7  
8 MozRepl::Plugin::JSON2 - use a 7bit safe json2.js for MozRepl/JS serialization
9  
10 =head1 SYNOPSIS
11  
12 This module only exists to serve as a container for
13 the MozRepl::RemoteObject JSON encoding/decoding.
14  
15 =cut
16  
17 $VERSION = '0.40';
18  
19 sub setup {
20 my ($self, $ctx, $args) = @_;
21 $ctx->execute($self->process('setup', { repl => $ctx->repl }));
22 }
23  
24 sub execute {
25 my ($self, $ctx, $args) = @_;
26  
27 my $cmd = $self->process('execute', { repl => $ctx->repl, source => $args->{source} });
28 my @result = $ctx->execute($cmd);
29  
30 if ($result[$#result - 1] =~ /\!{3} InternalError: /) { ### recursive error
31 $ctx->log->debug($result[$#result - 1]);
32  
33 croak($result[$#result - 1]);
34 }
35  
36 return join("", @result);
37 }
38  
39 1;
40  
41 =head1 MODIFIED VERSION OF json2.js
42  
43 This distribution contains a hacked, UTF-8 safe version of the json2.js
44 encoder. This is for channels that don't transfer data in an UTF-8 safe
45 manner. It is slower than using a native JSON encoder on the Javascript side.
46  
47 http://www.JSON.org/json2.js
48 2011-02-23
49  
50 Public Domain.
51  
52 NO WARRANTY EXPRESSED OR IMPLIED. USE AT YOUR OWN RISK.
53  
54 See http://www.JSON.org/js.html
55  
56 =head1 REPOSITORY
57  
58 The public repository of this module is
59 L<http://github.com/Corion/mozrepl-remoteobject>.
60  
61 =head1 AUTHOR
62  
63 Max Maischein C<corion@cpan.org>
64  
65 =head1 COPYRIGHT (c)
66  
67 Copyright 2009-2012 by Max Maischein C<corion@cpan.org>.
68  
69 =head1 LICENSE
70  
71 This module is released under the same terms as Perl itself.
72  
73 =cut
74  
75 __DATA__