File Coverage

blib/lib/WWW/Noss/GroupConfig.pm
Criterion Covered Total %
statement 35 38 92.1
branch 3 6 50.0
condition 2 2 100.0
subroutine 11 11 100.0
pod 5 7 71.4
total 56 64 87.5


line stmt bran cond sub pod time code
1             package WWW::Noss::GroupConfig;
2 2     2   691 use 5.016;
  2         10  
3 2     2   14 use strict;
  2         5  
  2         59  
4 2     2   11 use warnings;
  2         2  
  2         157  
5             our $VERSION = '2.02';
6              
7 2     2   15 use parent 'WWW::Noss::BaseConfig';
  2         6  
  2         19  
8              
9             sub new {
10              
11 5     5 1 209108 my ($class, %param) = @_;
12              
13 5         17 my $self = bless {}, $class;
14              
15 5         29 $self->initialize(%param);
16              
17 5         48 return $self;
18              
19             }
20              
21             sub initialize {
22              
23 5     5 0 37 my ($self, %param) = @_;
24              
25 5         42 $self->SUPER::initialize(%param);
26 5         29 $self->set_name($param{ name });
27 5   100     28 $self->set_feeds($param{ feeds } // []);
28              
29 5         16 return 1;
30              
31             }
32              
33             sub name {
34              
35 10     10 1 674 my ($self) = @_;
36              
37 10         45 return $self->{ Name };
38              
39             }
40              
41             sub set_name {
42              
43 5     5 0 11 my ($self, $new) = @_;
44              
45 5 50       16 unless (defined $new) {
46 0         0 die "group name cannot be undefined";
47             }
48              
49             # ':' groups are reserved for internal use
50 5 50       37 unless ($new =~ /^\:?\w+$/) {
51 0         0 die "group name can only contain alphanumeric characters";
52             }
53              
54 5         27 $self->{ Name } = $new;
55              
56             }
57              
58             sub feeds {
59              
60 4     4 1 9 my ($self) = @_;
61              
62 4         18 return $self->{ Feeds };
63              
64             }
65              
66             sub set_feeds {
67              
68 5     5 1 10 my ($self, $new) = @_;
69              
70 5 50       26 unless (ref $new eq 'ARRAY') {
71 0         0 die "feeds must be an array ref";
72             }
73              
74 5         13 $self->{ Feeds } = $new;
75              
76             }
77              
78             sub has_feed {
79              
80 3     3 1 1066 my ($self, $feed) = @_;
81              
82 3         7 return !! grep { $feed eq $_ } @{ $self->feeds };
  9         29  
  3         11  
83              
84             }
85              
86             1;
87              
88             =head1 NAME
89              
90             WWW::Noss::GroupConfig - Class for storing feed group configurations
91              
92             =head1 USAGE
93              
94             use WWW::Noss::GroupConfig;
95              
96             my $group = WWW::Noss::GroupConfig->new(
97             name => 'name',
98             feeds => [ 'feed1', 'feed2' ],
99             );
100              
101             =head1 DESCRIPTION
102              
103             B is a module that provides a class for storing feed
104             group configurations. This is a private module, please consult the L
105             manual for user documentation.
106              
107             =head1 METHODS
108              
109             Not all methods are documented here, as this class is derived from the
110             L module. Consult its documentation for additional
111             methods.
112              
113             =over 4
114              
115             =item $group = WWW::Noss::GroupConfig->new(%param)
116              
117             Returns a blessed B object based on the parameters
118             provided in the C<%param> hash.
119              
120             The following are valid fields for the C<%param> hash. The only required field
121             is C.
122              
123             =over 4
124              
125             =item name
126              
127             Name of the feed group. Can only contain alphanumeric and underscore
128             characters.
129              
130             =item feeds
131              
132             Array ref of feed names that the group contains.
133              
134             =back
135              
136             The following fields from the L module are also
137             available:
138              
139             =over 4
140              
141             =item limit
142              
143             =item respect_skip
144              
145             =item include_title
146              
147             =item exclude_title
148              
149             =item include_content
150              
151             =item exclude_content
152              
153             =item include_tags
154              
155             =item exclude_tags
156              
157             =item autoread
158              
159             =item default_update
160              
161             =item hidden
162              
163             =back
164              
165             =item $name = $group->name()
166              
167             =item $group->set-name($name)
168              
169             Getter/setter for the group's name attribute.
170              
171             =item $feeds = $group->feeds()
172              
173             =item $group->set_feeds($feeds)
174              
175             Getter/setter for the group's feeds attribute.
176              
177             =item $ok = $group->has_feed($feed)
178              
179             Returns true if C<$group> has the feed C<$feed>.
180              
181             =back
182              
183             =head1 AUTHOR
184              
185             Written by Samuel Young, Esamyoung12788@gmail.comE.
186              
187             This project's source can be found on its
188             L. Comments and pull
189             requests are welcome!
190              
191             =head1 COPYRIGHT
192              
193             Copyright (C) 2025-2026 Samuel Young
194              
195             This program is free software: you can redistribute it and/or modify
196             it under the terms of the GNU General Public License as published by
197             the Free Software Foundation, either version 3 of the License, or
198             (at your option) any later version.
199              
200             =head1 SEE ALSO
201              
202             L, L, L
203              
204             =cut
205              
206             # vim: expandtab shiftwidth=4