logo

news_parse_ex

commit: 312a3999820947792d3fa15ce0c3a4d10188bbff
parent 646e307e4866d984df43fb1a490ff0b1be4d0b7a
Author: Haelwenn (lanodan) Monnier <contact@hacktivis.me>
Date:   Tue, 27 Dec 2022 12:22:30 +0100

Put extraction functions as private

Diffstat:

Mlib/news_parse_ex.ex12++++++------
1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/lib/news_parse_ex.ex b/lib/news_parse_ex.ex @@ -34,18 +34,18 @@ defmodule NewsParseEx do {:error, "XML root isn't <feed> but <#{root_name}>"} end - def get_feed_title(doc, :atom), do: XML.string_from_xpath(~s[/feed/title/text()], doc) - def get_feed_title(doc, :rss2_0), do: XML.string_from_xpath(~s[/rss/channel/title/text()], doc) + defp get_feed_title(doc, :atom), do: XML.string_from_xpath(~s[/feed/title/text()], doc) + defp get_feed_title(doc, :rss2_0), do: XML.string_from_xpath(~s[/rss/channel/title/text()], doc) - def get_feed_id(doc, :atom), do: XML.string_from_xpath(~s[/feed/id/text()], doc) - def get_feed_id(doc, :rss2_0), do: XML.string_from_xpath(~s[/rss/channel/link/text()], doc) + defp get_feed_id(doc, :atom), do: XML.string_from_xpath(~s[/feed/id/text()], doc) + defp get_feed_id(doc, :rss2_0), do: XML.string_from_xpath(~s[/rss/channel/link/text()], doc) - def get_feed_last_update(doc, :atom) do + defp get_feed_last_update(doc, :atom) do {:ok, updated} = XML.string_from_xpath(~s[/feed/updated/text()], doc) DateTime.from_iso8601(updated) end - def get_feed_last_update(_doc, :rss2_0), do: {:ok, nil, nil} + defp get_feed_last_update(_doc, :rss2_0), do: {:ok, nil, nil} def parse(str) when is_bitstring(str) do with {_, {:ok, doc}} <- {:parse, XML.parse_document(str)},