user/dev discussion of public-inbox itself
 help / color / mirror / code / Atom feed
From: Eric Wong <e@80x24.org>
To: meta@public-inbox.org
Subject: [PATCH] nntp: use "newsgroup" instead of "name"
Date: Sat, 14 May 2016 02:56:20 +0000	[thread overview]
Message-ID: <20160514025620.18295-1-e@80x24.org> (raw)

This reduces the cognitive overhead for mapping names of
configuration values to internal field names of our classes.
Further changes along these lines coming...
---
 lib/PublicInbox/NNTP.pm      | 22 +++++++++++-----------
 lib/PublicInbox/NewsGroup.pm |  4 ++--
 2 files changed, 13 insertions(+), 13 deletions(-)

diff --git a/lib/PublicInbox/NNTP.pm b/lib/PublicInbox/NNTP.pm
index a632148..e77ccaa 100644
--- a/lib/PublicInbox/NNTP.pm
+++ b/lib/PublicInbox/NNTP.pm
@@ -189,7 +189,7 @@ sub list_active ($;$) {
 	my ($self, $wildmat) = @_;
 	wildmat2re($wildmat);
 	foreach my $ng (@{$self->{nntpd}->{grouplist}}) {
-		$ng->{name} =~ $wildmat or next;
+		$ng->{newsgroup} =~ $wildmat or next;
 		group_line($self, $ng);
 	}
 }
@@ -198,9 +198,9 @@ sub list_active_times ($;$) {
 	my ($self, $wildmat) = @_;
 	wildmat2re($wildmat);
 	foreach my $ng (@{$self->{nntpd}->{grouplist}}) {
-		$ng->{name} =~ $wildmat or next;
+		$ng->{newsgroup} =~ $wildmat or next;
 		my $c = eval { $ng->mm->created_at } || time;
-		more($self, "$ng->{name} $c $ng->{address}");
+		more($self, "$ng->{newsgroup} $c $ng->{address}");
 	}
 }
 
@@ -208,9 +208,9 @@ sub list_newsgroups ($;$) {
 	my ($self, $wildmat) = @_;
 	wildmat2re($wildmat);
 	foreach my $ng (@{$self->{nntpd}->{grouplist}}) {
-		$ng->{name} =~ $wildmat or next;
+		$ng->{newsgroup} =~ $wildmat or next;
 		my $d = $ng->description;
-		more($self, "$ng->{name} $d");
+		more($self, "$ng->{newsgroup} $d");
 	}
 }
 
@@ -289,7 +289,7 @@ sub parse_time ($$;$) {
 sub group_line ($$) {
 	my ($self, $ng) = @_;
 	my ($min, $max) = $ng->mm->minmax;
-	more($self, "$ng->{name} $max $min n") if defined $min && defined $max;
+	more($self, "$ng->{newsgroup} $max $min n") if defined $min && defined $max;
 }
 
 sub cmd_newgroups ($$$;$$) {
@@ -349,8 +349,8 @@ sub cmd_newnews ($$$$;$$) {
 	ngpat2re($skip);
 	my @srch;
 	foreach my $ng (@{$self->{nntpd}->{grouplist}}) {
-		$ng->{name} =~ $keep or next;
-		$ng->{name} =~ $skip and next;
+		$ng->{newsgroup} =~ $keep or next;
+		$ng->{newsgroup} =~ $skip and next;
 		my $srch = $ng->search or next;
 		push @srch, $srch;
 	};
@@ -441,7 +441,7 @@ sub set_nntp_headers {
 	my ($hdr, $ng, $n, $mid) = @_;
 
 	# clobber some
-	$hdr->header_set('Newsgroups', $ng->{name});
+	$hdr->header_set('Newsgroups', $ng->{newsgroup});
 	$hdr->header_set('Xref', xref($ng, $n));
 	header_append($hdr, 'List-Post', "<mailto:$ng->{address}>");
 	if (my $url = $ng->{url}) {
@@ -670,7 +670,7 @@ sub hdr_message_id ($$$) { # optimize XHDR Message-ID [range] for slrnpull.
 
 sub xref ($$) {
 	my ($ng, $n) = @_;
-	"$ng->{domain} $ng->{name}:$n"
+	"$ng->{domain} $ng->{newsgroup}:$n"
 }
 
 sub mid_lookup ($$) {
@@ -894,7 +894,7 @@ sub cmd_xpath ($$) {
 	my @paths;
 	foreach my $ng (values %{$self->{nntpd}->{groups}}) {
 		my $n = $ng->mm->num_for($mid);
-		push @paths, "$ng->{name}/$n" if defined $n;
+		push @paths, "$ng->{newsgroup}/$n" if defined $n;
 	}
 	return '430 no such article on server' unless @paths;
 	'223 '.join(' ', @paths);
diff --git a/lib/PublicInbox/NewsGroup.pm b/lib/PublicInbox/NewsGroup.pm
index 98a3595..500f61e 100644
--- a/lib/PublicInbox/NewsGroup.pm
+++ b/lib/PublicInbox/NewsGroup.pm
@@ -13,7 +13,7 @@ require PublicInbox::Search;
 require PublicInbox::Git;
 
 sub new {
-	my ($class, $name, $git_dir, $address, $url) = @_;
+	my ($class, $newsgroup, $git_dir, $address, $url) = @_;
 
 	# first email address is preferred
 	$address = $address->[0] if ref($address);
@@ -24,7 +24,7 @@ sub new {
 		$url .= '/' if $url !~ m!/\z!;
 	}
 	my $self = bless {
-		name => $name,
+		newsgroup => $newsgroup,
 		git_dir => $git_dir,
 		address => $address,
 		url => $url,

             reply	other threads:[~2016-05-14  2:56 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-05-14  2:56 Eric Wong [this message]
2016-05-14  3:08 ` [PATCH] rename most instances of "list" to "inbox" Eric Wong

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://public-inbox.org/README

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20160514025620.18295-1-e@80x24.org \
    --to=e@80x24.org \
    --cc=meta@public-inbox.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/public-inbox.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).