1package Reply::Plugin::AutoRefresh; 2our $AUTHORITY = 'cpan:DOY'; 3$Reply::Plugin::AutoRefresh::VERSION = '0.42'; 4use strict; 5use warnings; 6# ABSTRACT: automatically refreshes the external code you use 7 8use base 'Reply::Plugin'; 9use Class::Refresh 0.05 (); 10 11 12sub new { 13 my $class = shift; 14 my %opts = @_; 15 16 $opts{track_require} = 1 17 unless defined $opts{track_require}; 18 19 Class::Refresh->import(track_require => $opts{track_require}); 20 21 # so that when we load things after this plugin, they get a copy of 22 # Module::Runtime which has the call to require() rebound to our overridden 23 # copy. if this plugin is loaded first, these should be the only 24 # modules loaded so far which load arbitrary user-specified modules. 25 Class::Refresh->refresh_module('Module::Runtime'); 26 Class::Refresh->refresh_module('base'); 27 28 return $class->SUPER::new(@_); 29} 30 31sub compile { 32 my $self = shift; 33 my ($next, @args) = @_; 34 35 Class::Refresh->refresh; 36 $next->(@args); 37} 38 391; 40 41__END__ 42 43=pod 44 45=encoding UTF-8 46 47=head1 NAME 48 49Reply::Plugin::AutoRefresh - automatically refreshes the external code you use 50 51=head1 VERSION 52 53version 0.42 54 55=head1 SYNOPSIS 56 57 ; .replyrc 58 [AutoRefresh] 59 track_require = 1 60 61=head1 DESCRIPTION 62 63This plugin automatically refreshes all loaded modules before every 64statement execution. It's useful if you are working on a module in 65a file and you want the changes to automatically be loaded in Reply. 66 67It takes a single argument, C<track_require>, which defaults to true. 68If this option is set, the C<track_require> functionality from 69L<Class::Refresh> will be enabled. 70 71Note that to use the C<track_require> functionality, this module must 72be loaded as early as possible (preferably first), so that other 73modules correctly see the global override. 74 75=head1 AUTHOR 76 77Jesse Luehrs <doy@tozt.net> 78 79=head1 COPYRIGHT AND LICENSE 80 81This software is Copyright (c) 2016 by Jesse Luehrs. 82 83This is free software, licensed under: 84 85 The MIT (X11) License 86 87=cut 88