summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJesse Luehrs <doy@tozt.net>2009-11-26 00:54:45 -0600
committerJesse Luehrs <doy@tozt.net>2009-11-26 00:54:45 -0600
commit7f590ed202074c7ca3fc7597d0f5848bc86fad79 (patch)
tree9bc9d223b794a115d8b7c968a056d04e2f7f20b5
parent0bad6682d0c6a747fd10e38465939c79930238d0 (diff)
downloadcrawlbot-7f590ed202074c7ca3fc7597d0f5848bc86fad79.tar.gz
crawlbot-7f590ed202074c7ca3fc7597d0f5848bc86fad79.zip
item -> issue
-rw-r--r--lib/Crawl/Bot.pm54
1 files changed, 27 insertions, 27 deletions
diff --git a/lib/Crawl/Bot.pm b/lib/Crawl/Bot.pm
index ccaa29e..c5f6dcc 100644
--- a/lib/Crawl/Bot.pm
+++ b/lib/Crawl/Bot.pm
@@ -28,44 +28,44 @@ has cache_file => (
default => 'cache',
);
-has items => (
+has issues => (
traits => ['Hash'],
isa => 'HashRef',
default => sub {
my $self = shift;
my $file = $self->cache_file;
- my $items = {};
+ my $issues = {};
if (-r $file) {
- warn "Updating seen item list from the cache...";
+ warn "Updating seen issue list from the cache...";
open my $fh, '<', $file;
while (<$fh>) {
chomp;
- $items->{$_} = 1;
- warn " got item $_";
+ $issues->{$_} = 1;
+ warn " got issue $_";
}
}
else {
- warn "Updating seen item list from a fresh copy of the feed...";
- $self->each_item(sub {
- my $item = shift;
- my $link = $item->identifier;
+ warn "Updating seen issue list from a fresh copy of the feed...";
+ $self->each_issue(sub {
+ my $issue = shift;
+ my $link = $issue->identifier;
(my $id = $link) =~ s/.*=(\d+)$/$1/;
- $items->{$id} = 1;
- warn " got item $id";
+ $issues->{$id} = 1;
+ warn " got issue $id";
});
}
- return $items;
+ return $issues;
},
handles => {
- has_item => 'exists',
- items => 'keys',
- _add_item => 'set',
+ has_issue => 'exists',
+ issues => 'keys',
+ _add_issue => 'set',
},
);
-sub add_item {
+sub add_issue {
my $self = shift;
- $self->_add_item($_[0], 1);
+ $self->_add_issue($_[0], 1);
}
sub BUILD {
@@ -73,12 +73,12 @@ sub BUILD {
$self->save_cache;
}
-sub each_item {
+sub each_issue {
my $self = shift;
my ($code) = @_;
my $rss = XML::RAI->parse_uri($self->rss_feed);
- for my $item (@{ $rss->items }) {
- $code->($item);
+ for my $issue (@{ $rss->items }) {
+ $code->($issue);
}
}
@@ -86,23 +86,23 @@ sub save_cache {
my $self = shift;
warn "Saving cache state to " . $self->cache_file;
open my $fh, '>', $self->cache_file;
- $fh->print("$_\n") for $self->items;
+ $fh->print("$_\n") for $self->issues;
}
sub tick {
my $self = shift;
warn "Checking for new issues...";
- $self->each_item(sub {
- my $item = shift;
- my $link = $item->identifier;
+ $self->each_issue(sub {
+ my $issue = shift;
+ my $link = $issue->identifier;
(my $id = $link) =~ s/.*=(\d+)$/$1/;
- return if $self->has_item($id);
+ return if $self->has_issue($id);
warn "New issue! ($id)";
$self->say(
channel => $_,
- body => $item->title . ' (' . $item->link . ')'
+ body => $issue->title . ' (' . $issue->link . ')'
) for $self->channels;
- $self->add_item($id);
+ $self->add_issue($id);
});
$self->save_cache;