| 1 | package CPAN::Index::API::File::ModList; | ||||||||||
| 2 | |||||||||||
| 3 | 1 | our $VERSION = '0.008'; | |||||||||
| 4 | |||||||||||
| 5 | 1 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 6 | 1 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 7 | 1 | ▶ | use URI; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 8 | 1 | ▶ | use Carp qw(carp croak); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 9 | 1 | ▶ | use Path::Class qw(file); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 10 | 1 | ▶ | use namespace::autoclean; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 11 | 1 | ▶ | use Moose; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 12 | |||||||||||
| 13 | 1 | with qw( | |||||||||
| 14 | CPAN::Index::API::Role::Writable | ||||||||||
| 15 | CPAN::Index::API::Role::Readable | ||||||||||
| 16 | CPAN::Index::API::Role::Clonable | ||||||||||
| 17 | CPAN::Index::API::Role::HavingFilename | ||||||||||
| 18 | CPAN::Index::API::Role::HavingGeneratedBy | ||||||||||
| 19 | ); | ||||||||||
| 20 | |||||||||||
| 21 | 1 | has description => ( | |||||||||
| 22 | is => 'ro', | ||||||||||
| 23 | isa => 'Str', | ||||||||||
| 24 | required => 1, | ||||||||||
| 25 | default => 'Package names found in directory $CPAN/authors/id/', | ||||||||||
| 26 | ); | ||||||||||
| 27 | |||||||||||
| 28 | has modules => ( | ||||||||||
| 29 | is => 'bare', | ||||||||||
| 30 | isa => 'ArrayRef', | ||||||||||
| 31 | 2 | ▶ | default => sub { [] }, | ||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||
| 32 | 1 | traits => ['Array'], | |||||||||
| 33 | handles => { | ||||||||||
| 34 | module_count => 'count', | ||||||||||
| 35 | modules => 'elements', | ||||||||||
| 36 | }, | ||||||||||
| 37 | ); | ||||||||||
| 38 | |||||||||||
| 39 | # lots of code from Parse::CPAN::Modlist here | ||||||||||
| 40 | 2 | ▶ | sub parse { | ||||||||
|
Subroutine
parse: called CC=8 SCAR=21.0
Pod
documented
| |||||||||||
| 41 | 2 | my ( $self, $content ) = @_; | |||||||||
| 42 | |||||||||||
| 43 | ### get rid of the comments and the code ### | ||||||||||
| 44 | ### need a smarter parser, some people have this in their dslip info: | ||||||||||
| 45 | # [ | ||||||||||
| 46 | # 'Statistics::LTU', | ||||||||||
| 47 | # 'R', | ||||||||||
| 48 | # 'd', | ||||||||||
| 49 | # 'p', | ||||||||||
| 50 | # 'O', | ||||||||||
| 51 | # '?', | ||||||||||
| 52 | # 'Implements Linear Threshold Units', | ||||||||||
| 53 | # ...skipping... | ||||||||||
| 54 | # "\x{c4}dd \x{fc}ml\x{e4}\x{fc}ts t\x{f6} \x{eb}v\x{eb}r\x{ff}th\x{ef}ng!", | ||||||||||
| 55 | # 'BENNIE', | ||||||||||
| 56 | # '11' | ||||||||||
| 57 | # ], | ||||||||||
| 58 | ### also, older versions say: | ||||||||||
| 59 | ### $cols = [....] | ||||||||||
| 60 | ### and newer versions say: | ||||||||||
| 61 | ### $CPANPLUS::Modulelist::cols = [...] | ||||||||||
| 62 | 2 | $content =~ s/.+}\s+(\$(?:CPAN::Modulelist::)?cols)/$1/s; | |||||||||
| 63 | |||||||||||
| 64 | ### split '$cols' and '$data' into 2 variables ### | ||||||||||
| 65 | 2 | my ($ds_one, $ds_two) = split ';', $content, 2; | |||||||||
| 66 | |||||||||||
| 67 | ### eval them into existance ### | ||||||||||
| 68 | 2 | my ($columns, $data, @modules, %args ); | |||||||||
| 69 | |||||||||||
| 70 | 2 | $columns = eval $ds_one; | |||||||||
| 71 | 2 | ▶ | croak "Error in eval of 03modlist.data source files: $@" if $@; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 72 | |||||||||||
| 73 | 2 | $data = eval $ds_two; | |||||||||
| 74 | 2 | ▶ | croak "Error in eval of 03modlist.data source files: $@" if $@; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 75 | |||||||||||
| 76 | 2 | my %map = ( | |||||||||
| 77 | modid => 'name', | ||||||||||
| 78 | statd => 'development_stage', | ||||||||||
| 79 | stats => 'support_level', | ||||||||||
| 80 | statl => 'language_used', | ||||||||||
| 81 | stati => 'interface_style', | ||||||||||
| 82 | statp => 'public_license', | ||||||||||
| 83 | userid => 'authorid', | ||||||||||
| 84 | chapterid => 'chapterid', | ||||||||||
| 85 | description => 'description', | ||||||||||
| 86 | ); | ||||||||||
| 87 | |||||||||||
| 88 | 2 | ▶ | if ( my @unknown_columns = grep { ! $map{$_} } @$columns ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 89 | 0 | carp "Found unknown columns in 03modlist.data: " | |||||||||
| 90 | . join ', ', @unknown_columns; | ||||||||||
| 91 | } | ||||||||||
| 92 | |||||||||||
| 93 | 2 | foreach my $entry ( @$data ) { | |||||||||
| 94 | 3 | my %module; | |||||||||
| 95 | |||||||||||
| 96 | 3 | @module{@map{@$columns}} = @$entry; | |||||||||
| 97 | 3 | $module{chapterid} = int($module{chapterid}); | |||||||||
| 98 | |||||||||||
| 99 | 3 | my @dslip = qw( | |||||||||
| 100 | development_stage | ||||||||||
| 101 | support_level | ||||||||||
| 102 | language_used | ||||||||||
| 103 | interface_style | ||||||||||
| 104 | public_license | ||||||||||
| 105 | ); | ||||||||||
| 106 | |||||||||||
| 107 | 3 | undef $module{$_} for grep { $module{$_} eq '?' } @dslip; | |||||||||
| 108 | |||||||||||
| 109 | 3 | ▶ | $module{dslip} = join '', map { defined $_ ? $_ : '?' } @dslip; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 110 | |||||||||||
| 111 | 3 | push @modules, \%module; | |||||||||
| 112 | } | ||||||||||
| 113 | |||||||||||
| 114 | 2 | ▶ | $args{modules} = \@modules if @modules; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 115 | |||||||||||
| 116 | 2 | return %args; | |||||||||
| 117 | } | ||||||||||
| 118 | |||||||||||
| 119 | 4 | ▶ | sub default_location { 'modules/03modlist.data.gz' } | ||||||||
|
Subroutine
default_location: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 120 | |||||||||||
| 121 | 1 | __PACKAGE__->meta->make_immutable; | |||||||||
| 122 | |||||||||||
| 123 | =pod | ||||||||||
| 124 | |||||||||||
| 125 | =encoding UTF-8 | ||||||||||
| 126 | |||||||||||
| 127 | =head1 NAME | ||||||||||
| 128 | |||||||||||
| 129 | CPAN::Index::File::ModList - Interface to C<03modlist.data>. | ||||||||||
| 130 | |||||||||||
| 131 | =head1 SYNOPSIS | ||||||||||
| 132 | |||||||||||
| 133 | my $modlist = CPAN::Index::File::ModList->parse_from_repo_uri( | ||||||||||
| 134 | 'http://cpan.perl.org' | ||||||||||
| 135 | ); | ||||||||||
| 136 | |||||||||||
| 137 | foreach my $module ($modlist->modules) { | ||||||||||
| 138 | ... # do something | ||||||||||
| 139 | } | ||||||||||
| 140 | |||||||||||
| 141 | =head1 DESCRIPTION | ||||||||||
| 142 | |||||||||||
| 143 | This is a class to read and write C<03modlist.data>. | ||||||||||
| 144 | |||||||||||
| 145 | =head1 METHODS | ||||||||||
| 146 | |||||||||||
| 147 | =head2 modules | ||||||||||
| 148 | |||||||||||
| 149 | List of hashrefs containing module data. Each hashref has the following | ||||||||||
| 150 | structure. | ||||||||||
| 151 | |||||||||||
| 152 | =over | ||||||||||
| 153 | |||||||||||
| 154 | =item name | ||||||||||
| 155 | |||||||||||
| 156 | Module name, e.g. C<Foo::Bar>. | ||||||||||
| 157 | |||||||||||
| 158 | =item description | ||||||||||
| 159 | |||||||||||
| 160 | Short description of the module. | ||||||||||
| 161 | |||||||||||
| 162 | =item authorid | ||||||||||
| 163 | |||||||||||
| 164 | CPAN id of the module author. | ||||||||||
| 165 | |||||||||||
| 166 | =item chapterid | ||||||||||
| 167 | |||||||||||
| 168 | Number of the chapter under which the module is classified. Valid options are: | ||||||||||
| 169 | |||||||||||
| 170 | =over | ||||||||||
| 171 | |||||||||||
| 172 | =item 2 - Perl Core Modules | ||||||||||
| 173 | |||||||||||
| 174 | =item 3 - Development Support | ||||||||||
| 175 | |||||||||||
| 176 | =item 4 - Operating System Interfaces | ||||||||||
| 177 | |||||||||||
| 178 | =item 5 - Networking Devices IPC | ||||||||||
| 179 | |||||||||||
| 180 | =item 6 -Data Type Utilities | ||||||||||
| 181 | |||||||||||
| 182 | =item 7 - Database Interfaces | ||||||||||
| 183 | |||||||||||
| 184 | =item 8 - User Interfaces | ||||||||||
| 185 | |||||||||||
| 186 | =item 9 - Language Interfaces | ||||||||||
| 187 | |||||||||||
| 188 | =item 10 - File Names Systems Locking | ||||||||||
| 189 | |||||||||||
| 190 | =item 11 - String Lang Text Proc | ||||||||||
| 191 | |||||||||||
| 192 | =item 12 - Opt Arg Param Proc | ||||||||||
| 193 | |||||||||||
| 194 | =item 13 - Internationalization Locale | ||||||||||
| 195 | |||||||||||
| 196 | =item 14 - Security and Encryption | ||||||||||
| 197 | |||||||||||
| 198 | =item 15 - World Wide Web HTML HTTP CGI | ||||||||||
| 199 | |||||||||||
| 200 | =item 16 - Server and Daemon Utilities | ||||||||||
| 201 | |||||||||||
| 202 | =item 17 - Archiving and Compression | ||||||||||
| 203 | |||||||||||
| 204 | =item 18 - Images Pixmaps Bitmaps | ||||||||||
| 205 | |||||||||||
| 206 | =item 19 - Mail and Usenet News | ||||||||||
| 207 | |||||||||||
| 208 | =item 20 - Control Flow Utilities | ||||||||||
| 209 | |||||||||||
| 210 | =item 21 - File Handle Input Output | ||||||||||
| 211 | |||||||||||
| 212 | =item 22 - Microsoft Windows Modules | ||||||||||
| 213 | |||||||||||
| 214 | =item 23 - Miscellaneous Modules | ||||||||||
| 215 | |||||||||||
| 216 | =item 24 - Commercial Software Interfaces | ||||||||||
| 217 | |||||||||||
| 218 | =item 26 - Documentation | ||||||||||
| 219 | |||||||||||
| 220 | =item 27 - Pragma | ||||||||||
| 221 | |||||||||||
| 222 | =item 28 - Perl6 | ||||||||||
| 223 | |||||||||||
| 224 | =item 99 - Not In Module list | ||||||||||
| 225 | |||||||||||
| 226 | =back | ||||||||||
| 227 | |||||||||||
| 228 | =item development_stage | ||||||||||
| 229 | |||||||||||
| 230 | Single character indicating the development stage of the module. Valid | ||||||||||
| 231 | options are: | ||||||||||
| 232 | |||||||||||
| 233 | =over | ||||||||||
| 234 | |||||||||||
| 235 | =item M - Mature (no rigorous definition) | ||||||||||
| 236 | |||||||||||
| 237 | =item R - Released | ||||||||||
| 238 | |||||||||||
| 239 | =item S - Standard, supplied with Perl 5 | ||||||||||
| 240 | |||||||||||
| 241 | =item a - Alpha testing | ||||||||||
| 242 | |||||||||||
| 243 | =item b - Beta testing | ||||||||||
| 244 | |||||||||||
| 245 | =item c - Under construction but pre-alpha (not yet released) | ||||||||||
| 246 | |||||||||||
| 247 | =item i - Idea, listed to gain consensus or as a placeholder | ||||||||||
| 248 | |||||||||||
| 249 | =back | ||||||||||
| 250 | |||||||||||
| 251 | =item support_level | ||||||||||
| 252 | |||||||||||
| 253 | Single character indicating the type of support provided for the module. | ||||||||||
| 254 | Valid options are: | ||||||||||
| 255 | |||||||||||
| 256 | =over | ||||||||||
| 257 | |||||||||||
| 258 | =item a - Abandoned, the module has been abandoned by its author | ||||||||||
| 259 | |||||||||||
| 260 | =item d - Developer | ||||||||||
| 261 | |||||||||||
| 262 | =item m - Mailing-list | ||||||||||
| 263 | |||||||||||
| 264 | =item n - None known, try comp.lang.perl.modules | ||||||||||
| 265 | |||||||||||
| 266 | =item u - Usenet newsgroup comp.lang.perl.modules | ||||||||||
| 267 | |||||||||||
| 268 | =back | ||||||||||
| 269 | |||||||||||
| 270 | =item language_used | ||||||||||
| 271 | |||||||||||
| 272 | Single character indicating the programming languages used in the module. | ||||||||||
| 273 | Valid options are: | ||||||||||
| 274 | |||||||||||
| 275 | =over | ||||||||||
| 276 | |||||||||||
| 277 | =item + - C++ and perl, a C++ compiler will be needed | ||||||||||
| 278 | |||||||||||
| 279 | =item c - C and perl, a C compiler will be needed | ||||||||||
| 280 | |||||||||||
| 281 | =item h - Hybrid, written in perl with optional C code, no compiler needed | ||||||||||
| 282 | |||||||||||
| 283 | =item o - perl and another language other than C or C++ | ||||||||||
| 284 | |||||||||||
| 285 | =item p - Perl-only, no compiler needed, should be platform independent | ||||||||||
| 286 | |||||||||||
| 287 | =back | ||||||||||
| 288 | |||||||||||
| 289 | =item interface_style | ||||||||||
| 290 | |||||||||||
| 291 | Single character indicating the interface of the module. Valid options are: | ||||||||||
| 292 | |||||||||||
| 293 | =over | ||||||||||
| 294 | |||||||||||
| 295 | =item O - Object oriented using blessed references and/or inheritance | ||||||||||
| 296 | |||||||||||
| 297 | =item f - plain Functions, no references used | ||||||||||
| 298 | |||||||||||
| 299 | =item h - hybrid, object and function interfaces available | ||||||||||
| 300 | |||||||||||
| 301 | =item n - no interface at all (huh?) | ||||||||||
| 302 | |||||||||||
| 303 | =item r - some use of unblessed References or ties | ||||||||||
| 304 | |||||||||||
| 305 | =back | ||||||||||
| 306 | |||||||||||
| 307 | =item public_license | ||||||||||
| 308 | |||||||||||
| 309 | Single character indicating the license under which the module is distributed. | ||||||||||
| 310 | Valid options are: | ||||||||||
| 311 | |||||||||||
| 312 | =over | ||||||||||
| 313 | |||||||||||
| 314 | =item a - Artistic license alone | ||||||||||
| 315 | |||||||||||
| 316 | =item b - BSD: The BSD License | ||||||||||
| 317 | |||||||||||
| 318 | =item g - GPL: GNU General Public License | ||||||||||
| 319 | |||||||||||
| 320 | =item l - LGPL: "GNU Lesser General Public License" (previously known as "GNU Library General Public License") | ||||||||||
| 321 | |||||||||||
| 322 | =item o - other (but distribution allowed without restrictions) | ||||||||||
| 323 | |||||||||||
| 324 | =item p - Standard-Perl: user may choose between GPL and Artistic | ||||||||||
| 325 | |||||||||||
| 326 | =back | ||||||||||
| 327 | |||||||||||
| 328 | =back | ||||||||||
| 329 | |||||||||||
| 330 | =head2 module_count | ||||||||||
| 331 | |||||||||||
| 332 | Number of modules indexed in the file. | ||||||||||
| 333 | |||||||||||
| 334 | =head2 filename | ||||||||||
| 335 | |||||||||||
| 336 | Name of this file - defaults to C<03modlist.data.gz>; | ||||||||||
| 337 | |||||||||||
| 338 | =head2 description | ||||||||||
| 339 | |||||||||||
| 340 | Short description of the file. | ||||||||||
| 341 | |||||||||||
| 342 | =head2 parse | ||||||||||
| 343 | |||||||||||
| 344 | Parses the file and returns its representation as a data structure. | ||||||||||
| 345 | |||||||||||
| 346 | =head2 default_location | ||||||||||
| 347 | |||||||||||
| 348 | Default file location - C<modules/03modlist.data.gz>. | ||||||||||
| 349 | |||||||||||
| 350 | =head1 METHODS FROM ROLES | ||||||||||
| 351 | |||||||||||
| 352 | =over | ||||||||||
| 353 | |||||||||||
| 354 | =item <CPAN::Index::API::Role::Readable/read_from_string> | ||||||||||
| 355 | |||||||||||
| 356 | =item <CPAN::Index::API::Role::Readable/read_from_file> | ||||||||||
| 357 | |||||||||||
| 358 | =item <CPAN::Index::API::Role::Readable/read_from_tarball> | ||||||||||
| 359 | |||||||||||
| 360 | =item <CPAN::Index::API::Role::Readable/read_from_repo_path> | ||||||||||
| 361 | |||||||||||
| 362 | =item <CPAN::Index::API::Role::Readable/read_from_repo_uri> | ||||||||||
| 363 | |||||||||||
| 364 | =item L<CPAN::Index::API::Role::Writable/tarball_is_default> | ||||||||||
| 365 | |||||||||||
| 366 | =item L<CPAN::Index::API::Role::Writable/repo_path> | ||||||||||
| 367 | |||||||||||
| 368 | =item L<CPAN::Index::API::Role::Writable/template> | ||||||||||
| 369 | |||||||||||
| 370 | =item L<CPAN::Index::API::Role::Writable/content> | ||||||||||
| 371 | |||||||||||
| 372 | =item L<CPAN::Index::API::Role::Writable/write_to_file> | ||||||||||
| 373 | |||||||||||
| 374 | =item L<CPAN::Index::API::Role::Writable/write_to_tarball> | ||||||||||
| 375 | |||||||||||
| 376 | =item L<CPAN::Index::API::Role::Clonable/clone> | ||||||||||
| 377 | |||||||||||
| 378 | =item L<CPAN::Index::API::Role::HavingFilename/filename> | ||||||||||
| 379 | |||||||||||
| 380 | =item L<CPAN::Index::API::Role::HavingGeneratedBy/generated_by> | ||||||||||
| 381 | |||||||||||
| 382 | =item L<CPAN::Index::API::Role::HavingGeneratedBy/last_generated> | ||||||||||
| 383 | |||||||||||
| 384 | =back | ||||||||||
| 385 | |||||||||||
| 386 | =cut | ||||||||||
| 387 | |||||||||||
| 388 | __DATA__ | ||||||||||