Navigation Menu

Skip to content

Commit

Permalink
Merge remote-tracking branch 'dolmen/faster-startup'
Browse files Browse the repository at this point in the history
  • Loading branch information
rjbs committed Nov 3, 2011
2 parents 6891389 + 4c85cf9 commit ed393c6
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 19 deletions.
1 change: 0 additions & 1 deletion lib/Dist/Zilla/App.pm
Expand Up @@ -8,7 +8,6 @@ use Carp ();
use Dist::Zilla::MVP::Reader::Finder;
use Dist::Zilla::Util;
use Moose::Autobox;
use Path::Class;
use Try::Tiny;

sub global_opt_spec {
Expand Down
5 changes: 3 additions & 2 deletions lib/Dist/Zilla/App/Command/authordeps.pm
Expand Up @@ -6,7 +6,6 @@ use Dist::Zilla::App -command;

use Dist::Zilla::Util ();
use Moose;
use Path::Class qw(dir);
use List::MoreUtils qw(uniq);
use Config::INI::Reader;

Expand Down Expand Up @@ -37,10 +36,12 @@ sub opt_spec {
sub execute {
my ($self, $opt, $arg) = @_;

require Path::Class;

$self->log(
$self->format_author_deps(
$self->extract_author_deps(
dir(defined $opt->root ? $opt->root : '.'),
Path::Class::dir(defined $opt->root ? $opt->root : '.'),
$opt->missing,
),
),
Expand Down
1 change: 0 additions & 1 deletion lib/Dist/Zilla/App/Command/new.pm
Expand Up @@ -34,7 +34,6 @@ directory of 'default' profile.

use MooseX::Types::Perl qw(DistName ModuleName);
use Moose::Autobox;
use Path::Class;

sub abstract { 'mint a new dist' }

Expand Down
1 change: 0 additions & 1 deletion lib/Dist/Zilla/App/Command/setup.pm
Expand Up @@ -17,7 +17,6 @@ the most commonly needed F<config.ini> sections.
=cut

use autodie;
use Path::Class;

sub abstract { 'set up a basic global config file' }

Expand Down
25 changes: 18 additions & 7 deletions lib/Dist/Zilla/Chrome/Term.pm
Expand Up @@ -10,11 +10,7 @@ terminal environment. It's the default chrome used by L<Dist::Zilla::App>.
=cut

use Dist::Zilla::Types qw(OneZero);
use Encode qw(decode_utf8);
use Log::Dispatchouli 1.102220;
use Term::ReadLine;
use Term::ReadKey;
use Term::UI;

use namespace::autoclean;

Expand All @@ -38,9 +34,22 @@ has term_ui => (
is => 'ro',
isa => 'Object',
lazy => 1,
default => sub { Term::ReadLine->new('dzil') },
default => sub {
require Term::ReadLine;
require Term::UI;
Term::ReadLine->new('dzil')
},
);

sub decode_utf8 ($;$)
{
require Encode;
no warnings 'redefine';
*decode_utf8 = \&Encode::decode_utf8;
goto \&decode_utf8;
}


sub prompt_str {
my ($self, $prompt, $arg) = @_;
$arg ||= {};
Expand Down Expand Up @@ -81,9 +90,11 @@ sub prompt_any_key {
if ($isa_tty) {
local $| = 1;
print $prompt;
Term::ReadKey::ReadMode 'cbreak';

require Term::ReadKey;
Term::ReadKey::ReadMode('cbreak');
Term::ReadKey::ReadKey(0);
Term::ReadKey::ReadMode 'normal';
Term::ReadKey::ReadMode('normal');
print "\n";
}
}
Expand Down
21 changes: 14 additions & 7 deletions lib/Dist/Zilla/Util.pm
Expand Up @@ -3,16 +3,21 @@ use warnings;
package Dist::Zilla::Util;
# ABSTRACT: random snippets of code that Dist::Zilla wants

use File::HomeDir ();
use Path::Class;
use String::RewritePrefix 0.002; # better string context behavior

{
package
Dist::Zilla::Util::PEA;
use Pod::Eventual 0.091480; # better nonpod/blank events
use base 'Pod::Eventual';
sub _new { bless {} => shift; }
@Dist::Zilla::Util::PEA::ISA = ('Pod::Eventual');
sub _new {
# Load Pod::Eventual only when used (and not yet loaded)
unless (exists $INC{'Pod/Eventual.pm'}) {
require Pod::Eventual;
Pod::Eventual->VERSION(0.091480); # better nonpod/blank events
}

bless {} => shift;
}
sub handle_nonpod {
my ($self, $event) = @_;
return if $self->{abstract};
Expand Down Expand Up @@ -86,12 +91,14 @@ sub expand_config_package_name {
}

sub _global_config_root {
return dir($ENV{DZIL_GLOBAL_CONFIG_ROOT}) if $ENV{DZIL_GLOBAL_CONFIG_ROOT};
require Path::Class;
return Path::Class::dir($ENV{DZIL_GLOBAL_CONFIG_ROOT}) if $ENV{DZIL_GLOBAL_CONFIG_ROOT};

require File::HomeDir;
my $homedir = File::HomeDir->my_home
or Carp::croak("couldn't determine home directory");

return dir($homedir)->subdir('.dzil');
return Path::Class::dir($homedir)->subdir('.dzil');
}

1;

0 comments on commit ed393c6

Please sign in to comment.