line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package News::Pan::Server; |
2
|
3
|
|
|
3
|
|
68359
|
use strict; |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
92
|
|
3
|
3
|
|
|
3
|
|
18
|
use Carp; |
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
401
|
|
4
|
3
|
|
|
3
|
|
16
|
use warnings; |
|
3
|
|
|
|
|
8
|
|
|
3
|
|
|
|
|
131
|
|
5
|
3
|
|
|
3
|
|
16
|
use Cwd; |
|
3
|
|
|
|
|
4
|
|
|
3
|
|
|
|
|
226
|
|
6
|
3
|
|
|
3
|
|
2395
|
use LEOCHARRE::DEBUG; |
|
3
|
|
|
|
|
5634
|
|
|
3
|
|
|
|
|
16
|
|
7
|
3
|
|
|
3
|
|
1554
|
use News::Pan::Server::Group; |
|
3
|
|
|
|
|
9
|
|
|
3
|
|
|
|
|
2090
|
|
8
|
|
|
|
|
|
|
our $VERSION = sprintf "%d.%02d", q$Revision: 1.2 $ =~ /(\d+)/g; |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
sub new { |
11
|
3
|
|
|
3
|
1
|
16678
|
my ($class,$self) = @_; |
12
|
3
|
|
50
|
|
|
438
|
$self||={}; |
13
|
3
|
|
|
|
|
52
|
bless $self, $class; |
14
|
3
|
|
|
|
|
161
|
return $self; |
15
|
|
|
|
|
|
|
} |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
sub set_abs_path { |
18
|
3
|
|
|
3
|
1
|
10
|
my ($self,$arg) = @_; |
19
|
3
|
50
|
|
|
|
14
|
defined $arg or confess('missing arg'); |
20
|
|
|
|
|
|
|
|
21
|
3
|
|
|
|
|
35
|
$self->_reset; # reset everything |
22
|
3
|
50
|
0
|
|
|
501
|
my $resolved = Cwd::abs_path($arg) or warn("cannot resolve $arg") and return 0; |
23
|
3
|
50
|
0
|
|
|
96
|
-d $resolved or warn($resolved." is not a dir") and return 0; |
24
|
|
|
|
|
|
|
|
25
|
3
|
|
50
|
|
|
141
|
$self->{_data_} ||={}; |
26
|
3
|
|
|
|
|
22
|
$self->{_data_}->{abs_path} = $resolved; |
27
|
3
|
|
|
|
|
12
|
$self->{abs_path} = undef; # so it wont stay with original value if the object is used multiple times for diff servers |
28
|
3
|
|
|
|
|
4246
|
return 1; |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
sub abs_path { |
32
|
16
|
|
|
16
|
1
|
105
|
my $self = shift; |
33
|
16
|
100
|
|
|
|
72
|
unless( defined $self->{_data_}->{abs_path} ){ |
34
|
|
|
|
|
|
|
|
35
|
3
|
50
|
|
|
|
29
|
defined $self->{abs_path} or confess('missing abs_path argument to constructor'); |
36
|
3
|
50
|
|
|
|
31
|
$self->set_abs_path( $self->{abs_path} ) or confess("can't set abs path to $$self{abs_path}"); |
37
|
|
|
|
|
|
|
} |
38
|
16
|
|
|
|
|
482
|
return $self->{_data_}->{abs_path}; |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
sub groups_subscribed { |
42
|
3
|
|
|
3
|
1
|
3073
|
my $self = shift; |
43
|
3
|
|
|
|
|
28
|
return $self->_groups; |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
sub groups_subscribed_binaries { |
48
|
1
|
|
|
1
|
1
|
1149
|
my $self = shift; |
49
|
1
|
|
|
|
|
3
|
my @g = grep { /\.binaries\./i } @{$self->groups_subscribed}; |
|
3
|
|
|
|
|
16
|
|
|
1
|
|
|
|
|
2
|
|
50
|
1
|
|
|
|
|
4
|
return \@g; |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
# reset all data |
55
|
|
|
|
|
|
|
sub _reset { |
56
|
3
|
|
|
3
|
|
13
|
my $self = shift; |
57
|
3
|
|
|
|
|
9
|
$self->{_data_} = undef; |
58
|
3
|
|
|
|
|
13
|
return 1; |
59
|
|
|
|
|
|
|
} |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
sub _groups { |
63
|
3
|
|
|
3
|
|
14
|
my $self = shift; |
64
|
|
|
|
|
|
|
|
65
|
3
|
100
|
|
|
|
32
|
unless( $self->{_data_}->{subscribed_groups} ){ |
66
|
|
|
|
|
|
|
|
67
|
2
|
50
|
|
|
|
21
|
opendir(DIR,$self->abs_path) or confess($!); |
68
|
2
|
|
|
|
|
55
|
my @files = grep { -f $self->abs_path.'/'.$_ } readdir DIR; |
|
10
|
|
|
|
|
32
|
|
69
|
2
|
50
|
|
|
|
37
|
closedir DIR or confess($!); |
70
|
|
|
|
|
|
|
|
71
|
2
|
|
|
|
|
17
|
$self->{_data_}->{subscribed_groups} = \@files; |
72
|
|
|
|
|
|
|
} |
73
|
3
|
|
|
|
|
15
|
return $self->{_data_}->{subscribed_groups}; |
74
|
|
|
|
|
|
|
} |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
sub group { |
78
|
4
|
|
|
4
|
1
|
1627
|
my ($self,$name) = @_; |
79
|
4
|
50
|
|
|
|
28
|
defined $name or confess('misssing arg'); |
80
|
4
|
|
100
|
|
|
106
|
$self->{_data}->{group_objects} ||={}; |
81
|
4
|
50
|
|
|
|
27
|
unless($self->{_data}->{group_objects}->{$name}){ |
82
|
|
|
|
|
|
|
|
83
|
4
|
|
|
|
|
60
|
$self->{_data}->{group_objects}->{$name} = new News::Pan::Server::Group; |
84
|
4
|
50
|
|
|
|
32
|
$self->{_data}->{group_objects}->{$name}->set_abs_path( $self->abs_path.'/'.$name ) or warn("cant set $name group"); |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
} |
87
|
|
|
|
|
|
|
|
88
|
4
|
|
|
|
|
29
|
return $self->{_data}->{group_objects}->{$name}; |
89
|
|
|
|
|
|
|
} |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
1; |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
__END__ |