~ubuntu-branches/ubuntu/utopic/libapp-cmd-perl/utopic

« back to all changes in this revision

Viewing changes to lib/App/Cmd/Setup.pm

  • Committer: Bazaar Package Importer
  • Author(s): Salvatore Bonaccorso, gregor herrmann, Salvatore Bonaccorso
  • Date: 2011-02-08 16:31:34 UTC
  • mfrom: (1.2.6 upstream)
  • Revision ID: james.westby@ubuntu.com-20110208163134-7k8djok0u23hov9i
Tags: 0.310-1

[ gregor herrmann ]
* Add libtest-simple-perl (>= 0.96) to Build-Depends-Indep.

[ Salvatore Bonaccorso ]
* New upstream release
* Add libclass-load-perl to (Build-)Depends(-Indep).
* Email change: Salvatore Bonaccorso -> carnil@debian.org
* debian/copyright: Refresh and update copyright years for debian/*
  packaging.

Show diffs side-by-side

added added

removed removed

Lines of Context:
2
2
use warnings;
3
3
package App::Cmd::Setup;
4
4
BEGIN {
5
 
  $App::Cmd::Setup::VERSION = '0.309';
 
5
  $App::Cmd::Setup::VERSION = '0.310';
6
6
}
7
7
# ABSTRACT: helper for setting up App::Cmd classes
8
8
 
14
14
use Data::OptList ();
15
15
use String::RewritePrefix ();
16
16
 
 
17
# 0.06 is needed for load_optional_class
 
18
use Class::Load 0.06 qw();
 
19
 
17
20
use Sub::Exporter -setup => {
18
21
  -as     => '_import',
19
22
  exports => [ qw(foo) ],
43
46
 
44
47
  $self->_make_x_isa_y($into, $self->_app_base_class);
45
48
 
46
 
  my $cmd_base = $into->_default_command_base;
47
 
  my $has_cmd_base;
48
 
 
49
 
  # test for the $cmd_base module existing.
50
 
  # it being missing is fine, but if its broken, we should tell somebody
51
 
  if (eval "require $cmd_base; 1") {
52
 
    # loading the file works
53
 
    $has_cmd_base = 1;
54
 
  } else {
55
 
    # Determine if the file is just missing, or if its broken.
56
 
    # If its broken, perl will have stashed a path in $INC for it.
57
 
    my $modpath = $cmd_base;
58
 
    $modpath =~ s{::}{/}g;
59
 
    $modpath .= '.pm';
60
 
 
61
 
    if (exists $INC{$modpath}) {
62
 
      die $@;
63
 
    }
64
 
  }
65
 
 
66
 
  unless (
67
 
    eval { $cmd_base->isa( $self->_command_base_class ) }
68
 
    or
69
 
    $has_cmd_base
70
 
  ) {
 
49
  if ( ! Class::Load::load_optional_class( $into->_default_command_base ) ) {
71
50
    my $base = $self->_command_base_class;
72
51
    Sub::Install::install_sub({
73
52
      code => sub { $base },
76
55
    });
77
56
  }
78
57
 
 
58
  # TODO Check this is right. -- kentnl, 2010-12
 
59
  #
 
60
  #  my $want_plugin_base = $self->_plugin_base_class;
 
61
  my $want_plugin_base = 'App::Cmd::Plugin';
 
62
 
79
63
  my @plugins;
80
64
  for my $plugin (@{ $val->{plugins} || [] }) {
81
65
    $plugin = String::RewritePrefix->rewrite(
85
69
      },
86
70
      $plugin,
87
71
    );
88
 
 
89
 
    unless (eval { $plugin->isa($self->_plugin_base_class) }) {
90
 
      eval "require $plugin; 1" or die "couldn't load plugin $plugin: $@";
 
72
    Class::Load::load_class( $plugin );
 
73
    unless( $plugin->isa( $want_plugin_base ) ){
 
74
        die "$plugin is not a " . $want_plugin_base;
91
75
    }
92
 
 
93
76
    push @plugins, $plugin;
94
77
  }
95
78
 
166
149
 
167
150
=head1 VERSION
168
151
 
169
 
version 0.309
 
152
version 0.310
170
153
 
171
154
=head1 OVERVIEW
172
155