| 1 | package PAUSE::Users::UserIterator; | ||||||||||
| 2 | 2 | $PAUSE::Users::UserIterator::VERSION = '0.13'; | |||||||||
| 3 | 2 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | 2 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | 2 | ▶ | use 5.14.0; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 6 | |||||||||||
| 7 | 2 | ▶ | use Moo; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 8 | 2 | ▶ | use PAUSE::Users::User; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 9 | 2 | ▶ | use autodie; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 10 | 2 | ▶ | use feature 'unicode_strings'; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 11 | |||||||||||
| 12 | 2 | has 'users' => ( is => 'ro' ); | |||||||||
| 13 | 2 | has _fh => ( is => 'rw' ); | |||||||||
| 14 | |||||||||||
| 15 | sub next_user | ||||||||||
| 16 | 14732 | ▶ | { | ||||||||
|
Subroutine
next_user: called CC=9 SCAR=22.0
Pod
undocumented
| |||||||||||
| 17 | 14732 | my $self = shift; | |||||||||
| 18 | 14732 | my @fields; | |||||||||
| 19 | my $inuser; | ||||||||||
| 20 | 14732 | my $fh; | |||||||||
| 21 | 14732 | local $_; | |||||||||
| 22 | |||||||||||
| 23 | 14732 | ▶ | if (not defined $self->_fh) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 24 | 2 | $fh = $self->users->open_file(); | |||||||||
| 25 | 2 | $self->_fh($fh); | |||||||||
| 26 | } | ||||||||||
| 27 | else { | ||||||||||
| 28 | 14730 | $fh = $self->_fh; | |||||||||
| 29 | } | ||||||||||
| 30 | |||||||||||
| 31 | 14732 | $inuser = 0; | |||||||||
| 32 | LINE: | ||||||||||
| 33 | 14732 | ▶ | while (<$fh>) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 34 | |||||||||||
| 35 | 101878 | ▶ | if (m!<cpanid>!) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 36 | 14758 | $inuser = 1; | |||||||||
| 37 | 14758 | next LINE; | |||||||||
| 38 | } | ||||||||||
| 39 | |||||||||||
| 40 | 87120 | ▶ | next LINE unless $inuser; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 41 | |||||||||||
| 42 | 86956 | ▶ | if (m!<([a-zA-Z0-6_]+)>(.*?)</\1>!) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 43 | 72226 | my ($field, $value) = ($1, $2); | |||||||||
| 44 | |||||||||||
| 45 | # <type>author</type> specified a user account | ||||||||||
| 46 | # <type>list</type> is a mailing list; we skip those | ||||||||||
| 47 | 72226 | ▶ | if ($field eq 'type') { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 48 | 14758 | ▶ | $inuser = 0 if $value eq 'list'; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 49 | 14758 | next LINE; | |||||||||
| 50 | } | ||||||||||
| 51 | |||||||||||
| 52 | 57468 | push(@fields, $field => $value); | |||||||||
| 53 | } | ||||||||||
| 54 | |||||||||||
| 55 | 72198 | ▶ | if (m!</cpanid>!) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 56 | 14730 | my $user = PAUSE::Users::User->new(@fields); | |||||||||
| 57 | 14730 | @fields = (); | |||||||||
| 58 | 14730 | return $user; | |||||||||
| 59 | } | ||||||||||
| 60 | |||||||||||
| 61 | } | ||||||||||
| 62 | 2 | close($fh); | |||||||||
| 63 | 2 | return undef; | |||||||||
| 64 | } | ||||||||||
| 65 | |||||||||||
| 66 | 2 | 1; | |||||||||