support elixir 1.5.1

This commit is contained in:
keepcosmos 2017-08-23 14:38:08 +09:00
parent aca14e3aef
commit e2c5a4beed
4 changed files with 15 additions and 11 deletions

View File

@ -4,3 +4,4 @@ elixir:
- 1.2.6
- 1.3.4
- 1.4.1
- 1.5.0

View File

@ -58,13 +58,15 @@ defmodule Readability.ArticleBuilder do
defp find_article(candidates, html_tree) do
best_candidate = CandidateFinder.find_best_candidate(candidates)
unless best_candidate do
best_candidate = case html_tree |> Floki.find("body") do
article_trees = if best_candidate do
find_article_trees(best_candidate, candidates)
else
fallback_candidate = case html_tree |> Floki.find("body") do
[tree|_] -> %Candidate{html_tree: tree}
_ -> %Candidate{html_tree: {}}
end
find_article_trees(fallback_candidate, candidates)
end
article_trees = find_article_trees(best_candidate, candidates)
{"div", [], article_trees}
end
@ -73,11 +75,12 @@ defmodule Readability.ArticleBuilder do
candidates
|> Enum.filter(&(&1.tree_depth == best_candidate.tree_depth))
|> Enum.filter_map(fn(candidate) ->
|> Enum.filter(fn(candidate) ->
candidate == best_candidate
|| candidate.score >= score_threshold
|| append?(candidate)
end, &(to_article_tag(&1.html_tree)))
end)
|> Enum.map(&(to_article_tag(&1.html_tree)))
end
defp append?(%Candidate{html_tree: html_tree}) when elem(html_tree, 0) == "p" do

View File

@ -40,7 +40,7 @@ defmodule Readability.Mixfile do
#
# Type "mix help deps" for more examples and options
defp deps do
[{:floki, "~> 0.18.0"},
[{:floki, "~> 0.14.0"},
{:httpoison, "~> 0.13.0"},
{:ex_doc, "~> 0.14", only: :dev},
{:credo, "~> 0.6.1", only: [:dev, :test]},

View File

@ -4,7 +4,7 @@
"dialyxir": {:hex, :dialyxir, "0.5.1", "b331b091720fd93e878137add264bac4f644e1ddae07a70bf7062c7862c4b952", [:mix], []},
"earmark": {:hex, :earmark, "1.2.3", "206eb2e2ac1a794aa5256f3982de7a76bf4579ff91cb28d0e17ea2c9491e46a4", [:mix], []},
"ex_doc": {:hex, :ex_doc, "0.16.3", "cd2a4cfe5d26e37502d3ec776702c72efa1adfa24ed9ce723bb565f4c30bd31a", [:mix], [{:earmark, "~> 1.1", [hex: :earmark, optional: false]}]},
"floki": {:hex, :floki, "0.18.0", "643d5e4bb325905328d250760ea622faebac4f7e1521f770d35fbb43d8dd4f5f", [:mix], [{:mochiweb, "~> 2.15", [hex: :mochiweb, optional: false]}]},
"floki": {:hex, :floki, "0.14.0", "91a6be57349e10a63cf52d7890479a19012cef9185fa93c305d4fe42e6a50dee", [:mix], [{:mochiweb, "~> 2.15", [hex: :mochiweb, optional: false]}]},
"hackney": {:hex, :hackney, "1.9.0", "51c506afc0a365868469dcfc79a9d0b94d896ec741cfd5bd338f49a5ec515bfe", [:rebar3], [{:certifi, "2.0.0", [hex: :certifi, optional: false]}, {:idna, "5.1.0", [hex: :idna, optional: false]}, {:metrics, "1.0.1", [hex: :metrics, optional: false]}, {:mimerl, "1.0.2", [hex: :mimerl, optional: false]}, {:ssl_verify_fun, "1.1.1", [hex: :ssl_verify_fun, optional: false]}]},
"httpoison": {:hex, :httpoison, "0.13.0", "bfaf44d9f133a6599886720f3937a7699466d23bb0cd7a88b6ba011f53c6f562", [:mix], [{:hackney, "~> 1.8", [hex: :hackney, optional: false]}]},
"idna": {:hex, :idna, "5.1.0", "d72b4effeb324ad5da3cab1767cb16b17939004e789d8c0ad5b70f3cea20c89a", [:rebar3], [{:unicode_util_compat, "0.3.1", [hex: :unicode_util_compat, optional: false]}]},