Closed mdom closed 6 years ago
It's a bit like a combination of the path
and url
attributes I had in the first version of Mojo::Feed
, isn't it? Reopening the possibility for going back to a self-parsing Mojo::Feed...
I'm merging this, since you've added the feature with doc and test.
Yeah, you're right. I think of this two of readonly, but it would be possible to add a parse routine to Mojo::Feed that creates a Reader to parse itself (uhm). We would just need to delete the underlying hash to reset the lazy attributes. Do you prefer two seperate attributes path and url instead of source?
I'd consider having all three, probably with source being a readonly method:
sub source { return $_[0]->url || $_[0]->path || undef };
I also wonder how useful a file source
is outside your specific application. A url
is also a tricky identifier for a feed, because of redirects. But that's what we've got, and it beats having nothing :frowning_face:
I don't actually need a file source, i just added that to cover all cases. Having source as readonly with url and path as attributes makes sense.
With url
i can see both sides, for some users it might be more useful to get the redirected url. We could keep a reference to the feeds Mojo::Transaction::HTTP
object to get all redirects. Or url
could return an array ref with all urls. What do you think?
I needed to track the original source of the feed for podite. I first just implemented a hash to save this information, but maybe this would be a helpful addition to Mojo::Feed?