line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package News::Pan::Server::Group; |
2
|
3
|
|
|
3
|
|
15
|
use strict; |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
88
|
|
3
|
3
|
|
|
3
|
|
12
|
use warnings; |
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
64
|
|
4
|
3
|
|
|
3
|
|
14
|
use Carp; |
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
173
|
|
5
|
3
|
|
|
3
|
|
14
|
use base 'News::Pan::Server::Group::_Search'; |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
1610
|
|
6
|
3
|
|
|
3
|
|
20
|
use LEOCHARRE::DEBUG; |
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
13
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
sub new { |
9
|
4
|
|
|
4
|
1
|
71
|
my ($class,$self) = @_; |
10
|
4
|
|
50
|
|
|
39
|
$self||={}; |
11
|
4
|
|
|
|
|
28
|
bless $self, $class; |
12
|
4
|
|
|
|
|
29
|
return $self; |
13
|
|
|
|
|
|
|
} |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
sub name { |
16
|
0
|
|
|
0
|
0
|
0
|
my $self = shift; |
17
|
0
|
|
|
|
|
0
|
my $abs = $self->abs_path; |
18
|
0
|
0
|
|
|
|
0
|
$abs=~/([^\/]+)$/ or confess('cant get group name'); |
19
|
0
|
|
|
|
|
0
|
return $1; |
20
|
|
|
|
|
|
|
} |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
sub set_abs_path { |
23
|
4
|
|
|
4
|
1
|
10
|
my ($self,$arg) = @_; |
24
|
4
|
50
|
|
|
|
14
|
defined $arg or confess('missing arg'); |
25
|
|
|
|
|
|
|
|
26
|
4
|
|
|
|
|
17
|
$self->_reset; # reset everything |
27
|
4
|
50
|
0
|
|
|
744
|
my $resolved = Cwd::abs_path($arg) or warn("cannot resolve $arg") and return 0; |
28
|
4
|
50
|
0
|
|
|
101
|
-f $resolved or warn($resolved." is not a file") and return 0; |
29
|
|
|
|
|
|
|
|
30
|
4
|
|
50
|
|
|
39
|
$self->{_data_} ||={}; |
31
|
4
|
|
|
|
|
13
|
$self->{_data_}->{abs_path} = $resolved; |
32
|
4
|
|
|
|
|
7
|
$self->{abs_path} = undef; # so it wont stay with original value if the object is used multiple times for diff groups |
33
|
4
|
|
|
|
|
37
|
return 1; |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
sub abs_path { |
37
|
4
|
|
|
4
|
1
|
9
|
my $self = shift; |
38
|
4
|
50
|
|
|
|
18
|
unless( defined $self->{_data_}->{abs_path} ){ |
39
|
|
|
|
|
|
|
|
40
|
0
|
0
|
|
|
|
0
|
defined $self->{abs_path} or confess('missing abs_path argument to constructor'); |
41
|
0
|
0
|
|
|
|
0
|
$self->set_abs_path( $self->{abs_path} ) or confess("can't set abs path to $$self{abs_path}"); |
42
|
|
|
|
|
|
|
} |
43
|
4
|
|
|
|
|
13
|
return $self->{_data_}->{abs_path}; |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
sub subjects { |
48
|
5
|
|
|
5
|
0
|
9
|
my $self = shift; |
49
|
5
|
|
|
|
|
16
|
return $self->_subjects; |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
sub _subjects { |
58
|
5
|
|
|
5
|
|
8
|
my $self = shift; |
59
|
|
|
|
|
|
|
|
60
|
5
|
100
|
|
|
|
26
|
unless( defined $self->{_data_}->{subjects} ){ |
61
|
4
|
|
|
|
|
15
|
my $abs = $self->abs_path; |
62
|
4
|
|
|
|
|
12
|
my $subjects=[]; |
63
|
|
|
|
|
|
|
|
64
|
4
|
50
|
|
|
|
272
|
open(INF,"< $abs") or confess($!); |
65
|
|
|
|
|
|
|
|
66
|
4
|
|
|
|
|
7
|
my $lastline; |
67
|
|
|
|
|
|
|
|
68
|
4
|
|
|
|
|
175
|
while(){ |
69
|
3030
|
|
|
|
|
3893
|
my $line = $_; |
70
|
3030
|
100
|
|
|
|
7098
|
if ($line=~/^\s+$/){ #article ended |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
# then last line was subject |
73
|
135
|
|
|
|
|
296
|
push @$subjects, $lastline; |
74
|
|
|
|
|
|
|
} |
75
|
3030
|
|
|
|
|
18638
|
$line=~s/^\s|\s$//g; |
76
|
3030
|
|
|
|
|
17393
|
$lastline = $line; |
77
|
|
|
|
|
|
|
} |
78
|
4
|
50
|
|
|
|
97
|
close INF or confess($!); |
79
|
|
|
|
|
|
|
|
80
|
4
|
|
|
|
|
35
|
$self->{_data_}->{subjects} = $subjects; |
81
|
|
|
|
|
|
|
} |
82
|
|
|
|
|
|
|
|
83
|
5
|
|
|
|
|
35
|
return $self->{_data_}->{subjects}; |
84
|
|
|
|
|
|
|
} |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
sub subjects_count { |
87
|
3
|
|
|
3
|
0
|
5
|
my $self = shift; |
88
|
3
|
|
|
|
|
4
|
my $count = scalar @{$self->subjects}; |
|
3
|
|
|
|
|
9
|
|
89
|
3
|
|
|
|
|
34
|
return $count; |
90
|
|
|
|
|
|
|
} |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
sub _reset { |
93
|
4
|
|
|
4
|
|
7
|
my $self = shift; |
94
|
4
|
|
|
|
|
33
|
$self->{_data_} = undef; |
95
|
4
|
|
|
|
|
9
|
return 1; |
96
|
|
|
|
|
|
|
} |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
1; |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
__END__ |