From 528230a0411897a14cbb79d0dae02ea89827bf1e Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Sat, 28 May 2016 01:57:14 +0000 Subject: remove redundant NewsGroup class Most of its functionality is in the PublicInbox::Inbox class. While we're at it, we no longer auto-create newsgroup names based on the inbox name, since newsgroup names probably deserve some thought when it comes to hierarchy. --- lib/PublicInbox/NewsGroup.pm | 84 -------------------------------------------- 1 file changed, 84 deletions(-) delete mode 100644 lib/PublicInbox/NewsGroup.pm (limited to 'lib/PublicInbox/NewsGroup.pm') diff --git a/lib/PublicInbox/NewsGroup.pm b/lib/PublicInbox/NewsGroup.pm deleted file mode 100644 index 500f61e3..00000000 --- a/lib/PublicInbox/NewsGroup.pm +++ /dev/null @@ -1,84 +0,0 @@ -# Copyright (C) 2015 all contributors -# License: AGPLv3 or later (https://www.gnu.org/licenses/agpl-3.0.txt) -# -# Used only by the NNTP server to represent a public-inbox git repository -# as a newsgroup -package PublicInbox::NewsGroup; -use strict; -use warnings; -use Scalar::Util qw(weaken); -require Danga::Socket; -require PublicInbox::Msgmap; -require PublicInbox::Search; -require PublicInbox::Git; - -sub new { - my ($class, $newsgroup, $git_dir, $address, $url) = @_; - - # first email address is preferred - $address = $address->[0] if ref($address); - if ($url) { - # assume protocol-relative URLs which start with '//' means - # the server supports both HTTP and HTTPS, favor HTTPS. - $url = "https:$url" if $url =~ m!\A//!; - $url .= '/' if $url !~ m!/\z!; - } - my $self = bless { - newsgroup => $newsgroup, - git_dir => $git_dir, - address => $address, - url => $url, - }, $class; - $self->{domain} = ($address =~ /\@(\S+)\z/) ? $1 : 'localhost'; - $self; -} - -sub weaken_all { - my ($self) = @_; - weaken($self->{$_}) foreach qw(gcf mm search); -} - -sub gcf { - my ($self) = @_; - $self->{gcf} ||= eval { PublicInbox::Git->new($self->{git_dir}) }; -} - -sub usable { - my ($self) = @_; - eval { - PublicInbox::Msgmap->new($self->{git_dir}); - PublicInbox::Search->new($self->{git_dir}); - }; -} - -sub mm { - my ($self) = @_; - $self->{mm} ||= eval { PublicInbox::Msgmap->new($self->{git_dir}) }; -} - -sub search { - my ($self) = @_; - $self->{search} ||= eval { PublicInbox::Search->new($self->{git_dir}) }; -} - -sub description { - my ($self) = @_; - open my $fh, '<', "$self->{git_dir}/description" or return ''; - my $desc = eval { local $/; <$fh> }; - chomp $desc; - $desc =~ s/\s+/ /smg; - $desc; -} - -sub update { - my ($self, $new) = @_; - $self->{address} = $new->{address}; - $self->{domain} = $new->{domain}; - if ($self->{git_dir} ne $new->{git_dir}) { - # new git_dir requires a new mm and gcf - $self->{mm} = $self->{gcf} = undef; - $self->{git_dir} = $new->{git_dir}; - } -} - -1; -- cgit v1.2.3-24-ge0c7