X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FDevel%2FREPL%2FScript.pm;h=d4c0a29ce37d84054b1bb8df7e98b8c53d99d060;hb=refs%2Fheads%2Fmaster;hp=fec8e7df02d7d027f470e75240a6fafa428dff21;hpb=aa8b764738156914d48d182ee0706e4c3d4e5c99;p=p5sagit%2FDevel-REPL.git diff --git a/lib/Devel/REPL/Script.pm b/lib/Devel/REPL/Script.pm index fec8e7d..d4c0a29 100644 --- a/lib/Devel/REPL/Script.pm +++ b/lib/Devel/REPL/Script.pm @@ -1,27 +1,30 @@ package Devel::REPL::Script; +our $VERSION = '1.003030'; + use Moose; use Devel::REPL; -use File::HomeDir; use File::Spec; -use vars qw($CURRENT_SCRIPT); +use Module::Runtime 'use_module'; use namespace::autoclean; +our $CURRENT_SCRIPT; + with 'MooseX::Getopt'; has 'rcfile' => ( - is => 'ro', isa => 'Str', required => 1, default => sub { 'repl.rc' }, + is => 'ro', isa => 'Str', + default => sub { 'repl.rc' }, ); has 'profile' => ( is => 'ro', isa => 'Str', - required => 1, - default => sub { $ENV{DEVEL_REPL_PROFILE} || 'Default' }, + default => sub { $ENV{DEVEL_REPL_PROFILE} || 'Minimal' }, ); has '_repl' => ( - is => 'ro', isa => 'Devel::REPL', required => 1, + is => 'ro', isa => 'Devel::REPL', default => sub { Devel::REPL->new() } ); @@ -34,7 +37,7 @@ sub BUILD { sub load_profile { my ($self, $profile) = @_; $profile = "Devel::REPL::Profile::${profile}" unless $profile =~ /::/; - Class::MOP::load_class($profile); + use_module $profile; confess "Profile class ${profile} doesn't do 'Devel::REPL::Profile'" unless $profile->does('Devel::REPL::Profile'); $profile->new->apply_profile($self->_repl); @@ -45,7 +48,7 @@ sub load_rcfile { # plain name => ~/.re.pl/${rc_file} if ($rc_file !~ m!/!) { - $rc_file = File::Spec->catfile(File::HomeDir->my_home, '.re.pl', $rc_file); + $rc_file = File::Spec->catfile(($^O eq 'MSWin32' && "$]" < 5.016 ? $ENV{HOME} || $ENV{USERPROFILE} : (<~>)[0]), '.re.pl', $rc_file); } $self->apply_script($rc_file);