-
Notifications
You must be signed in to change notification settings - Fork 91
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added
url_filter
option to allow crawl restrictions
- Loading branch information
Showing
10 changed files
with
100 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
defmodule Crawler.Fetcher.UrlFilter do | ||
@moduledoc """ | ||
A placeholder module that let all URLs pass through. | ||
""" | ||
|
||
@behaviour __MODULE__.Spec | ||
|
||
@doc """ | ||
Whether to pass through a given URL. | ||
- `true` for letting the url through. | ||
- `false` for rejecting the url. | ||
""" | ||
def filter(_url), do: {:ok, true} | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
defmodule Crawler.Fetcher.UrlFilter.Spec do | ||
@moduledoc """ | ||
Spec for defining an url filter. | ||
""" | ||
|
||
@type url :: String.t | ||
|
||
@callback filter(url) :: {:ok, boolean} | {:error, term} | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
defmodule Crawler.Fetcher.PolicerTest do | ||
use Crawler.TestCase, async: true | ||
|
||
alias Crawler.Fetcher.Policer | ||
alias Crawler.Fetcher.{Policer, UrlFilter} | ||
|
||
doctest Policer | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
defmodule Crawler.Fetcher.UrlFilterTest do | ||
use Crawler.TestCase, async: true | ||
|
||
alias Crawler.Fetcher.UrlFilter | ||
|
||
doctest UrlFilter | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters