File: GroupConfig.pm

package info (click to toggle)
noss 1.10-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 704 kB
  • sloc: perl: 6,571; sh: 569; xml: 294; makefile: 2
file content (206 lines) | stat: -rw-r--r-- 3,455 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
package WWW::Noss::GroupConfig;
use 5.016;
use strict;
use warnings;
our $VERSION = '1.10';

use parent 'WWW::Noss::BaseConfig';

sub new {

    my ($class, %param) = @_;

    my $self = bless {}, $class;

    $self->initialize(%param);

    return $self;

}

sub initialize {

    my ($self, %param) = @_;

    $self->SUPER::initialize(%param);
    $self->set_name($param{ name });
    $self->set_feeds($param{ feeds } // []);

    return 1;

}

sub name {

    my ($self) = @_;

    return $self->{ Name };

}

sub set_name {

    my ($self, $new) = @_;

    unless (defined $new) {
        die "group name cannot be undefined";
    }

    # ':' groups are reserved for internal use
    unless ($new =~ /^\:?\w+$/) {
        die "group name can only contain alphanumeric characters";
    }

    $self->{ Name } = $new;

}

sub feeds {

    my ($self) = @_;

    return $self->{ Feeds };

}

sub set_feeds {

    my ($self, $new) = @_;

    unless (ref $new eq 'ARRAY') {
        die "feeds must be an array ref";
    }

    $self->{ Feeds } = $new;

}

sub has_feed {

    my ($self, $feed) = @_;

    return !! grep { $feed eq $_ } @{ $self->feeds };

}

1;

=head1 NAME

WWW::Noss::GroupConfig - Class for storing feed group configurations

=head1 USAGE

  use WWW::Noss::GroupConfig;

  my $group = WWW::Noss::GroupConfig->new(
      name  => 'name',
      feeds => [ 'feed1', 'feed2' ],
  );

=head1 DESCRIPTION

B<WWW::Noss::GroupConfig> is a module that provides a class for storing feed
group configurations. This is a private module, please consult the L<noss>
manual for user documentation.

=head1 METHODS

Not all methods are documented here, as this class is derived from the
L<WWW::Noss::BaseConfig> module. Consult its documentation for additional
methods.

=over 4

=item $group = WWW::Noss::GroupConfig->new(%param)

Returns a blessed B<WWW::Noss::GroupConfig> object based on the parameters
provided in the C<%param> hash.

The following are valid fields for the C<%param> hash. The only required field
is C<name>.

=over 4

=item name

Name of the feed group. Can only contain alphanumeric and underscore
characters.

=item feeds

Array ref of feed names that the group contains.

=back

The following fields from the L<WWW::Noss::BaseConfig> module are also
available:

=over 4

=item limit

=item respect_skip

=item include_title

=item exclude_title

=item include_content

=item exclude_content

=item include_tags

=item exclude_tags

=item autoread

=item default_update

=item hidden

=back

=item $name = $group->name()

=item $group->set-name($name)

Getter/setter for the group's name attribute.

=item $feeds = $group->feeds()

=item $group->set_feeds($feeds)

Getter/setter for the group's feeds attribute.

=item $ok = $group->has_feed($feed)

Returns true if C<$group> has the feed C<$feed>.

=back

=head1 AUTHOR

Written by Samuel Young, E<lt>samyoung12788@gmail.comE<gt>.

This project's source can be found on its
L<Codeberg page|https://codeberg.org/1-1sam/noss.git>. Comments and pull
requests are welcome!

=head1 COPYRIGHT

Copyright (C) 2025 Samuel Young

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

=head1 SEE ALSO

L<WWW::Noss::BaseConfig>, L<WWW::Noss::FeedConfig>, L<noss>

=cut

# vim: expandtab shiftwidth=4