user/dev discussion of public-inbox itself
 help / color / mirror / code / Atom feed
Search results ordered by [date|relevance]  view[summary|nested|Atom feed]
thread overview below | download mbox.gz: |
* [PATCH 7/7] inbox: move field population logic to initializer
  2016-06-20  0:57  6% [PATCH 0/7] www: various feed/streaming related cleanups Eric Wong
@ 2016-06-20  0:57  7% ` Eric Wong
  0 siblings, 0 replies; 2+ results
From: Eric Wong @ 2016-06-20  0:57 UTC (permalink / raw)
  To: meta

Inboxes are normally created by Config, but having the
population logic in Inbox should make it easier to mock
for testing.
---
 lib/PublicInbox/Config.pm | 4 +---
 lib/PublicInbox/Inbox.pm  | 3 +++
 t/feed.t                  | 1 -
 t/html_index.t            | 1 -
 4 files changed, 4 insertions(+), 5 deletions(-)

diff --git a/lib/PublicInbox/Config.pm b/lib/PublicInbox/Config.pm
index 43ffba7..ea84da3 100644
--- a/lib/PublicInbox/Config.pm
+++ b/lib/PublicInbox/Config.pm
@@ -129,10 +129,8 @@ sub _fill {
 	my $name = $pfx;
 	$name =~ s/\Apublicinbox\.//;
 	$rv->{name} = $name;
-	my $v = $rv->{address} ||= 'public-inbox@example.com';
-	my $p = $rv->{-primary_address} = ref($v) eq 'ARRAY' ? $v->[0] : $v;
-	$rv->{domain} = ($p =~ /\@(\S+)\z/) ? $1 : 'localhost';
 	$rv = PublicInbox::Inbox->new($rv);
+	my $v = $rv->{address};
 	if (ref($v) eq 'ARRAY') {
 		$self->{-by_addr}->{lc($_)} = $rv foreach @$v;
 	} else {
diff --git a/lib/PublicInbox/Inbox.pm b/lib/PublicInbox/Inbox.pm
index faab03c..3f1b733 100644
--- a/lib/PublicInbox/Inbox.pm
+++ b/lib/PublicInbox/Inbox.pm
@@ -11,6 +11,9 @@ use PublicInbox::MID qw(mid2path);
 
 sub new {
 	my ($class, $opts) = @_;
+	my $v = $opts->{address} ||= 'public-inbox@example.com';
+	my $p = $opts->{-primary_address} = ref($v) eq 'ARRAY' ? $v->[0] : $v;
+	$opts->{domain} = ($p =~ /\@(\S+)\z/) ? $1 : 'localhost';
 	bless $opts, $class;
 }
 
diff --git a/t/feed.t b/t/feed.t
index 5dd869a..19a9ba0 100644
--- a/t/feed.t
+++ b/t/feed.t
@@ -43,7 +43,6 @@ my $tmpdir = tempdir('pi-feed-XXXXXX', TMPDIR => 1, CLEANUP => 1);
 my $git_dir = "$tmpdir/gittest";
 my $ibx = PublicInbox::Inbox->new({
 	address => 'test@example',
-	-primary_address => 'test@example',
 	name => 'testbox',
 	mainrepo => $git_dir,
 	url => 'http://example.com/test',
diff --git a/t/html_index.t b/t/html_index.t
index 32d7b8d..100d21a 100644
--- a/t/html_index.t
+++ b/t/html_index.t
@@ -13,7 +13,6 @@ my $tmpdir = tempdir('pi-http-XXXXXX', TMPDIR => 1, CLEANUP => 1);
 my $git_dir = "$tmpdir/gittest";
 my $ibx = PublicInbox::Inbox->new({
 	address => 'test@example',
-	-primary_address => 'test@example',
 	name => 'tester',
 	mainrepo => $git_dir,
 	url => 'http://example.com/test',

^ permalink raw reply related	[relevance 7%]

* [PATCH 0/7] www: various feed/streaming related cleanups
@ 2016-06-20  0:57  6% Eric Wong
  2016-06-20  0:57  7% ` [PATCH 7/7] inbox: move field population logic to initializer Eric Wong
  0 siblings, 1 reply; 2+ results
From: Eric Wong @ 2016-06-20  0:57 UTC (permalink / raw)
  To: meta

Yet more progress towards converting our PSGI streaming
interfaces over to getline/close so it can be pull-based.

Eric Wong (7):
      MANIFEST: update with recent changes
      feed: avoid needless method dispatches on 404
      feed: remove dependence on fh->write for streaming
      mbox: remove feed dependency
      mbox: avoid write dependency for streaming
      feed: various object-orientation cleanups
      inbox: move field population logic to initializer

 .gitignore                    |  1 +
 MANIFEST                      |  2 +
 Makefile.PL                   |  5 ++-
 lib/PublicInbox/Config.pm     |  4 +-
 lib/PublicInbox/Feed.pm       | 99 ++++++++++++++++++-------------------------
 lib/PublicInbox/Inbox.pm      | 15 +++++++
 lib/PublicInbox/Mbox.pm       | 68 ++++++++++-------------------
 lib/PublicInbox/NNTP.pm       |  6 +--
 lib/PublicInbox/SearchView.pm |  3 +-
 lib/PublicInbox/View.pm       |  7 +--
 lib/PublicInbox/WWW.pm        |  4 +-
 lib/PublicInbox/WwwAttach.pm  |  5 +--
 t/feed.t                      | 44 ++++++-------------
 t/html_index.t                | 11 ++++-
 14 files changed, 119 insertions(+), 155 deletions(-)


^ permalink raw reply	[relevance 6%]

Results 1-2 of 2 | reverse | options above
-- pct% links below jump to the message on this page, permalinks otherwise --
2016-06-20  0:57  6% [PATCH 0/7] www: various feed/streaming related cleanups Eric Wong
2016-06-20  0:57  7% ` [PATCH 7/7] inbox: move field population logic to initializer Eric Wong

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).