Aggregator::Simpleにaggregator.parseフェーズを実装するパッチ 修正版

さりげなくaggregator.parseフェーズの結果がcustomfeed.handleに伝わってなかった、正確にはaggregator.parseフェーズでfeedが作られようが作られまいがaggregateメソッドが真を返していたのでそれを修正。

=== lib/Plagger/Plugin/Aggregator/Simple.pm
==================================================================
--- lib/Plagger/Plugin/Aggregator/Simple.pm (revision 52)

+++ lib/Plagger/Plugin/Aggregator/Simple.pm (local)

@@ -15,7 +15,7 @@

     my($self, $context) = @_;
     $context->register_hook(
         $self,
-        'customfeed.handle'  => \&aggregate,
+        'customfeed.handle'  => $self->can('aggregate'),
     );
 }

@@ -38,7 +38,7 @@

         $res = $self->fetch_content($feed_url) or return;
         $self->handle_feed($feed_url, \$res->content, $args->{feed});
     } else {
-        return;
+        return if ( ! $self->handle_content($url, $res, $args->{feed}) );
     }

     return 1;
@@ -215,6 +215,19 @@

     $str;
 }

+sub handle_content {
+    my ($self, $url, $res, $feed) = @\_;
+
+    my $context = Plagger->context;
+    my $args    = {
+        url      => $url,
+        response => $res,
+        feed     => $feed,
+    };
+
+    return $context->run_hook_once('aggregator.parse', $args);
+\}
+
 1;

 __END__

ちなみにaggregtor.parseフェーズの挙動としては、

  1. データソースをaggregator.filter.'formatName'で修正
  2. データソースをパース
    • 成功した場合 Plagger::Feedを生成$context->update->add( $feed )して真を返す
    • 失敗した場合 戻り値として偽を返す

こんな感じ。

: Software 虚像幻影(nowa)からインポート

Aggregator::AsyncとAggregator::Gunghoをaggregator.parseフェーズに対応させるパッチ

Aggregator::Async

=== lib/Plagger/Plugin/Aggregator/Async.pm
==================================================================
--- lib/Plagger/Plugin/Aggregator/Async.pm  (revision 52)

+++ lib/Plagger/Plugin/Aggregator/Async.pm  (local)

@@ -76,7 +76,7 @@

         my $new_id = $self->async->add( $self->prep_req($context, $feed_url ) );
         $self->{_id2feed}->\{$new_id} = $feed;
     } else {
-        return;
+        return if ( ! $self->handle_content($url, $ufr, $feed) );
     }

     $self->cache->set(

Aggregator::Gungho

=== lib/Plagger/Plugin/Aggregator/Gungho.pm
==================================================================
--- lib/Plagger/Plugin/Aggregator/Gungho.pm (revision 52)

+++ lib/Plagger/Plugin/Aggregator/Gungho.pm (local)

@@ -51,7 +51,7 @@

         $clone->uri($feed_url);
         $plugin->gungho->send_request($clone);
     } else {
-        return;
+        return if ( ! $plugin->handle_content($url, $ufr, $req->notes('feed')) );
     }
 }

Aggregator::Xangoについては見ただけではよく分からない部分があったので、改造できなかった。

あとこの二つのパッチは Aggregator::Simpleにaggregator.parseフェーズを実装するパッチ 修正版が適用されたAggregator::Simpleが必要。

: Software 虚像幻影(nowa)からインポート

パッチあてたAggregator系のプラグインをリネーム

とりあえず、今まで書いたパッチをあてたのを

Aggregator::Simple => Aggregator::Simple::Parse
Aggregator::Async  => Aggregator::Async::Parse
Aggregator::Gungho => Aggregator::Gungho::Parse

と言う感じでリネームして設定用のリポジトリに突っ込んだ。

本当は本家用のプラグインの開発リポジトリに入れようかと思ったんだけど、プラグイン開発するとき競合しそうなのでやめた。あとフェーズ改造した私家版のプラグインを本家用のプラグイン開発するためのリポジトリに突っ込むのもどうかと思ったし。

とりあえず、これでアンテナの問題はなんとかなりそうな気がする。

つーか今まで書いたプラグインのテスト書かなきゃ。

: Software 虚像幻影(nowa)からインポート