line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
|
2
|
|
|
|
|
|
|
our $VERSION = '1.003029'; |
3
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
use Moose; |
5
|
1
|
|
|
1
|
|
1087
|
use Devel::REPL; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
6
|
|
6
|
1
|
|
|
1
|
|
5657
|
use File::Spec; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
31
|
|
7
|
1
|
|
|
1
|
|
6
|
use Module::Runtime 'use_module'; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
22
|
|
8
|
1
|
|
|
1
|
|
5
|
use namespace::autoclean; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
5
|
|
9
|
1
|
|
|
1
|
|
57
|
|
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
6
|
|
10
|
|
|
|
|
|
|
our $CURRENT_SCRIPT; |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
with 'MooseX::Getopt'; |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
has 'rcfile' => ( |
15
|
|
|
|
|
|
|
is => 'ro', isa => 'Str', |
16
|
|
|
|
|
|
|
default => sub { 'repl.rc' }, |
17
|
|
|
|
|
|
|
); |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
has 'profile' => ( |
20
|
|
|
|
|
|
|
is => 'ro', |
21
|
|
|
|
|
|
|
isa => 'Str', |
22
|
|
|
|
|
|
|
default => sub { $ENV{DEVEL_REPL_PROFILE} || 'Minimal' }, |
23
|
|
|
|
|
|
|
); |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
has '_repl' => ( |
26
|
|
|
|
|
|
|
is => 'ro', isa => 'Devel::REPL', |
27
|
|
|
|
|
|
|
default => sub { Devel::REPL->new() } |
28
|
|
|
|
|
|
|
); |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
my ($self) = @_; |
31
|
|
|
|
|
|
|
$self->load_profile($self->profile); |
32
|
0
|
|
|
0
|
0
|
|
$self->load_rcfile($self->rcfile); |
33
|
0
|
|
|
|
|
|
} |
34
|
0
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
my ($self, $profile) = @_; |
36
|
|
|
|
|
|
|
$profile = "Devel::REPL::Profile::${profile}" unless $profile =~ /::/; |
37
|
|
|
|
|
|
|
use_module $profile; |
38
|
0
|
|
|
0
|
0
|
|
confess "Profile class ${profile} doesn't do 'Devel::REPL::Profile'" |
39
|
0
|
0
|
|
|
|
|
unless $profile->does('Devel::REPL::Profile'); |
40
|
0
|
|
|
|
|
|
$profile->new->apply_profile($self->_repl); |
41
|
0
|
0
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
0
|
|
|
|
|
|
my ($self, $rc_file) = @_; |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
# plain name => ~/.re.pl/${rc_file} |
46
|
|
|
|
|
|
|
if ($rc_file !~ m!/!) { |
47
|
0
|
|
|
0
|
0
|
|
$rc_file = File::Spec->catfile(($^O eq 'MSWin32' && "$]" < 5.016 ? $ENV{HOME} || $ENV{USERPROFILE} : (<~>)[0]), '.re.pl', $rc_file); |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
|
50
|
0
|
0
|
|
|
|
|
$self->apply_script($rc_file); |
51
|
0
|
0
|
0
|
|
|
|
} |
|
|
|
0
|
|
|
|
|
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
my ($self, $script, $warn_on_unreadable) = @_; |
54
|
0
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
if (!-e $script) { |
56
|
|
|
|
|
|
|
warn "File '$script' does not exist" if $warn_on_unreadable; |
57
|
|
|
|
|
|
|
return; |
58
|
0
|
|
|
0
|
0
|
|
} |
59
|
|
|
|
|
|
|
elsif (!-r _) { |
60
|
0
|
0
|
|
|
|
|
warn "File '$script' is unreadable" if $warn_on_unreadable; |
|
|
0
|
|
|
|
|
|
61
|
0
|
0
|
|
|
|
|
return; |
62
|
0
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
open RCFILE, '<', $script or die "Couldn't open ${script}: $!"; |
65
|
0
|
0
|
|
|
|
|
my $rc_data; |
66
|
0
|
|
|
|
|
|
{ local $/; $rc_data = <RCFILE>; } |
67
|
|
|
|
|
|
|
close RCFILE; # Don't care if this fails |
68
|
|
|
|
|
|
|
$self->eval_script($rc_data); |
69
|
0
|
0
|
|
|
|
|
warn "Error executing script ${script}: $@\n" if $@; |
70
|
0
|
|
|
|
|
|
} |
71
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
72
|
0
|
|
|
|
|
|
my ($self, $data) = @_; |
73
|
0
|
|
|
|
|
|
local $CURRENT_SCRIPT = $self; |
74
|
0
|
0
|
|
|
|
|
$self->_repl->eval($data); |
75
|
|
|
|
|
|
|
} |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
my ($self) = @_; |
78
|
0
|
|
|
0
|
0
|
|
$self->_repl->run; |
79
|
0
|
|
|
|
|
|
} |
80
|
0
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
my ($class, @opts) = @_; |
82
|
|
|
|
|
|
|
return unless (@opts == 1 && $opts[0] eq 'run'); |
83
|
|
|
|
|
|
|
$class->new_with_options->run; |
84
|
0
|
|
|
0
|
0
|
|
} |
85
|
0
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
confess "->current should only be called as class method" if ref($_[0]); |
87
|
|
|
|
|
|
|
confess "No current instance (valid only during rc parse)" |
88
|
|
|
|
|
|
|
unless $CURRENT_SCRIPT; |
89
|
0
|
|
|
0
|
|
|
return $CURRENT_SCRIPT; |
90
|
0
|
0
|
0
|
|
|
|
} |
91
|
0
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
1; |