parent
42dc662c79
commit
39fa3f80a6
Binary file not shown.
@ -1,5 +1,22 @@
|
||||
defmodule FeedParser.Parser do
|
||||
@callback accepts(data :: String.t(), content_type :: String.t()) :: {true, any()} | false
|
||||
@callback parse_feed(data :: any()) ::
|
||||
@moduledoc """
|
||||
This behaviour defines the functions required to implement a feed parser.
|
||||
"""
|
||||
|
||||
@doc """
|
||||
Determines whether this Parser supports parsing a feed from the given data and MIME type.
|
||||
|
||||
If this parser can handle the data, it should return a tuple of `true` and the any object (usually the parsed form of the data). The returned object will then be passed to the `parse_feed` function.
|
||||
Otherwise, it should return `false`.
|
||||
"""
|
||||
@callback accepts(data :: String.t(), content_type :: String.t()) ::
|
||||
{true, parsed_data :: any()} | false
|
||||
|
||||
@doc """
|
||||
Creates a `FeedParser.Feed` from the parsed data returned by the accepts function.
|
||||
|
||||
Returns either a tuple of `:ok` and the parsed Feed or `:error` and the reason for the error.
|
||||
"""
|
||||
@callback parse_feed(parsed_data :: any()) ::
|
||||
{:ok, feed :: FeedParser.Feed.t()} | {:error, reason :: String.t()}
|
||||
end
|
||||
|
@ -1,4 +1,8 @@
|
||||
defmodule FeedParser.Atom.Parser do
|
||||
defmodule FeedParser.Parser.Atom do
|
||||
@moduledoc """
|
||||
A `FeedParser.Parser` that handles [Atom feeds](https://validator.w3.org/feed/docs/atom.html).
|
||||
"""
|
||||
|
||||
alias FeedParser.XML
|
||||
require XML
|
||||
|
@ -1,4 +1,8 @@
|
||||
defmodule FeedParser.JSONFeed.Parser do
|
||||
defmodule FeedParser.Parser.JSONFeed do
|
||||
@moduledoc """
|
||||
A `FeedParser.Parser` that handles [JSON Feeds](https://jsonfeed.org/version/1).
|
||||
"""
|
||||
|
||||
@behaviour FeedParser.Parser
|
||||
|
||||
@impl FeedParser.Parser
|
@ -1,4 +1,8 @@
|
||||
defmodule FeedParser.RSS2.Parser do
|
||||
defmodule FeedParser.Parser.RSS2 do
|
||||
@moduledoc """
|
||||
A `FeedParser.Parser` that handles [RSS 2.0 feeds](https://cyber.harvard.edu/rss/rss.html).
|
||||
"""
|
||||
|
||||
alias FeedParser.XML
|
||||
require XML
|
||||
|
@ -1,4 +1,8 @@
|
||||
defmodule FeedParser.RSSInJSON.Parser do
|
||||
defmodule FeedParser.Parser.RSSInJSON do
|
||||
@moduledoc """
|
||||
A `FeedParser.Parser` that handles [RSS-in-JSON feeds](https://github.com/scripting/Scripting-News/blob/2347bb8751d94dc76d25074997db4fde682585f9/rss-in-json/README.md).
|
||||
"""
|
||||
|
||||
@behaviour FeedParser.Parser
|
||||
|
||||
@impl FeedParser.Parser
|
Loading…
Reference in new issue