~ubuntu-branches/ubuntu/wily/libmodule-info-perl/wily-proposed

« back to all changes in this revision

Viewing changes to .pc/spelling.patch/bin/module_info

  • Committer: Bazaar Package Importer
  • Author(s): Ansgar Burchardt, gregor herrmann, Ansgar Burchardt, Salvatore Bonaccorso
  • Date: 2010-06-06 21:51:52 UTC
  • Revision ID: james.westby@ubuntu.com-20100606215152-jixscux2upyst0lu
Tags: 0.31-2
[ gregor herrmann ]
* debian/control: Added: Vcs-Svn field (source stanza); Vcs-Browser
  field (source stanza); Homepage field (source stanza).
* Set Maintainer to Debian Perl Group.
* Use dist-based URL in debian/watch.
* debian/control: Added: ${misc:Depends} to Depends: field.

[ Ansgar Burchardt ]
* debian/watch: Use extended regexp to match upstream releases.
* Refresh rules for debhelper 7.
* Use Build.PL.
* Use source format 3.0 (quilt).
* Convert debian/copyright to proposed machine-readable format.
* Do not use embedded copy of Test-Simple during build.
* Compare versions as numbers, not as strings in tests.
  + new patch: version-comparison.patch
* Use is_deeply the right way.
  + new patch: is-deeply.patch
* Fix spelling errors.
  + new patch: spelling.patch
* Add missing whatis entry to B::Module::Info.
  + new patch: whatis-entry.patch
* Bump Standards-Version to 3.8.4.
* Add myself to Uploaders.

[ Salvatore Bonaccorso ]
* debian/control: Changed: Replace versioned (build-)dependency on
  perl (>= 5.6.0-{12,16}) with an unversioned dependency on perl (as
  permitted by Debian Policy 3.8.3).

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/usr/bin/perl -w
 
2
 
 
3
=head1 NAME
 
4
 
 
5
module_info - find informations about modules
 
6
 
 
7
=head1 SYNOPSIS
 
8
 
 
9
  module_info [B<-a>] [B<-s>] [B<-p>] [B<-m>] MODULE|FILE...
 
10
 
 
11
=head1 DESCRIPTION
 
12
 
 
13
List information about the arguments (either module names in the form
 
14
C<Module::Name> or paths in the form C<Foo/Bar.pm> or C<foo/bar.pl>).
 
15
 
 
16
By default only shows module name, version, directory, absolute path
 
17
and a flag indicating if it is a core module. Additional informations
 
18
can be requested through command line switches.
 
19
 
 
20
=over 4
 
21
 
 
22
=item B<-s>
 
23
 
 
24
Show subroutines created by the module.
 
25
 
 
26
=item B<-p>
 
27
 
 
28
Show packages created by the module.
 
29
 
 
30
=item B<-m>
 
31
 
 
32
Show modules C<use()>d by the module.
 
33
 
 
34
=item B<-a>
 
35
 
 
36
Equivalent to C<-s -p -m>.
 
37
 
 
38
=back
 
39
 
 
40
=head1 AUTHOR
 
41
 
 
42
Mattia Barbon <mbarbon@cpan.org>
 
43
 
 
44
=head1 SEE ALSO
 
45
 
 
46
L<Module::Info>
 
47
 
 
48
=cut
 
49
 
 
50
use strict;
 
51
use Module::Info;
 
52
use Getopt::Long;
 
53
 
 
54
my( $show_subroutines, $show_modules, $show_packages, $show_all, $help );
 
55
 
 
56
GetOptions( 's' => \$show_subroutines,
 
57
            'p' => \$show_packages,
 
58
            'm' => \$show_modules,
 
59
            'a' => \$show_all,
 
60
            'h' => \$help,
 
61
          );
 
62
 
 
63
if( $help || !@ARGV ) {
 
64
    print <<EOT;
 
65
Usage: module_info [-a] [-s] [-p] [-m] MODULE|FILE...
 
66
 
 
67
    -a Equivalent to -s -p -m
 
68
    -h Help message
 
69
    -m Show modules use()d by the module
 
70
    -p Show packages created by the module
 
71
    -s Show subroutines created by the module
 
72
EOT
 
73
    exit 0;
 
74
}
 
75
 
 
76
$show_subroutines ||= $show_all;
 
77
$show_modules ||= $show_all;
 
78
$show_packages ||= $show_all;
 
79
 
 
80
my $some_error = 0;
 
81
 
 
82
foreach my $module (@ARGV) {
 
83
    my $info;
 
84
 
 
85
    if( -f $module ) {
 
86
        $info = Module::Info->new_from_file($module);
 
87
    }
 
88
    else {
 
89
        $info = Module::Info->new_from_module($module);
 
90
    }
 
91
 
 
92
    unless( $info ) {
 
93
        warn "Can't create Module::Info object for module '$module'";
 
94
        $some_error = 1;
 
95
        next;
 
96
    }
 
97
 
 
98
    $info->die_on_compilation_error(1);
 
99
 
 
100
    my $name = $info->name || $module;
 
101
    my $version = $info->version || '(unknown)';
 
102
    my $dir = $info->inc_dir;
 
103
    my $file = $info->file;
 
104
    my $is_core = $info->is_core ? "yes" : "no";
 
105
 
 
106
    print <<EOT;
 
107
 
 
108
Name:        $name
 
109
Version:     $version
 
110
Directory:   $dir
 
111
File:        $file
 
112
Core module: $is_core
 
113
EOT
 
114
 
 
115
    my %packages_created;
 
116
    my @modules_used;
 
117
    my %subroutines;
 
118
 
 
119
    eval {
 
120
        @modules_used = $info->modules_used if $show_modules;
 
121
        %packages_created = $info->package_versions if $show_packages;
 
122
        %subroutines = $info->subroutines if $show_subroutines;
 
123
    };
 
124
    if( $@ ) {
 
125
        warn "Compilation failed for module '$module'";
 
126
        $some_error = 1;
 
127
        next;
 
128
    }
 
129
 
 
130
    ###########################################################################
 
131
    # Modules used
 
132
    ###########################################################################
 
133
    if( $show_modules ) {
 
134
        print "\nModules used:\n";
 
135
        foreach my $m (sort @modules_used) {
 
136
            print "    $m\n";
 
137
        }
 
138
        print "    (none)\n" unless @modules_used;
 
139
    }
 
140
 
 
141
    ###########################################################################
 
142
    # Packages defined
 
143
    ###########################################################################
 
144
    if( $show_packages ) {
 
145
        print "\nPackages created:\n";
 
146
        foreach my $p (sort keys %packages_created) {
 
147
            print "    $p\t";
 
148
            print +( defined( $packages_created{$p} ) ?
 
149
                                $packages_created{$p} :
 
150
                                      '(no version)' );
 
151
            print "\n";
 
152
        }
 
153
        print "    (none)\n" unless keys %packages_created;
 
154
    }
 
155
 
 
156
    ###########################################################################
 
157
    # Subroutines
 
158
    ###########################################################################
 
159
    if( $show_subroutines ) {
 
160
        print "\nSubroutines defined:\n";
 
161
        {
 
162
            my @subroutines =
 
163
              sort  { ( $a->[0] cmp $b->[0] ) || ( $a->[1] cmp $b->[1] ) }
 
164
              map   {
 
165
                        my($package, $subname) = ($_ =~ m/^(.*)?::(\w+)$/);
 
166
                        warn "Strange subroutine '$_'"
 
167
                          unless $package || $subname;
 
168
                        $package ||= '(unknown)';
 
169
                        $subname ||= '(unknown)';
 
170
                        [ $package, $subname ];
 
171
                    } keys %subroutines;
 
172
            my $prev_package = ':'; # impossible
 
173
            foreach my $s (@subroutines) {
 
174
                my($package, $subname) = @$s;
 
175
                if($prev_package ne $package) {
 
176
                    $prev_package = $package;
 
177
                    print "    $package\n";
 
178
                }
 
179
 
 
180
                print "        $subname\n";
 
181
            }
 
182
        }
 
183
        print "    (none)\n" unless %subroutines;
 
184
    }
 
185
}
 
186
 
 
187
exit $some_error;