Current section

2 Versions

Jump to

Compare versions

5 files changed
+64 additions
-49 deletions
  @@ -1,6 +1,6 @@
1 1 {<<"links">>,[{<<"github">>,<<"https://github.com/manuel-rubio/sitemap">>}]}.
2 2 {<<"name">>,<<"sitemaps">>}.
3 - {<<"version">>,<<"0.1.0">>}.
3 + {<<"version">>,<<"0.1.1">>}.
4 4 {<<"description">>,<<"Generating sitemap files">>}.
5 5 {<<"elixir">>,<<">= 1.17.0">>}.
6 6 {<<"app">>,<<"sitemaps">>}.
  @@ -12,8 +12,8 @@
12 12 {<<"requirement">>,<<">= 0.0.0">>},
13 13 {<<"repository">>,<<"hexpm">>}]]}.
14 14 {<<"files">>,
15 - [<<"lib">>,<<"lib/sitemap.ex">>,<<"lib/sitemaps">>,
16 - <<"lib/sitemaps/builders">>,<<"lib/sitemaps/builders/index_url.ex">>,
15 + [<<"lib">>,<<"lib/sitemaps">>,<<"lib/sitemaps/builders">>,
16 + <<"lib/sitemaps/builders/index_url.ex">>,
17 17 <<"lib/sitemaps/builders/index_file.ex">>,
18 18 <<"lib/sitemaps/builders/url.ex">>,<<"lib/sitemaps/builders/file.ex">>,
19 19 <<"lib/sitemaps/consts.ex">>,<<"lib/sitemaps/dsl.ex">>,
  @@ -21,5 +21,6 @@
21 21 <<"lib/sitemaps/state.ex">>,<<"lib/sitemaps/location.ex">>,
22 22 <<"lib/sitemaps/file.ex">>,<<"lib/sitemaps/generator.ex">>,
23 23 <<"lib/sitemaps/exceptions.ex">>,<<"lib/sitemaps/namer.ex">>,
24 - <<".formatter.exs">>,<<"mix.exs">>,<<"README.md">>,<<"LICENSE">>]}.
24 + <<"lib/sitemaps.ex">>,<<".formatter.exs">>,<<"mix.exs">>,<<"README.md">>,
25 + <<"LICENSE">>]}.
25 26 {<<"build_tools">>,[<<"mix">>]}.
  @@ -1,42 +0,0 @@
1 - defmodule Sitemaps do
2 - @moduledoc """
3 - Sitemap application is in charge of running the supervisor and the following
4 - processes under it:
5 -
6 - - `Sitemaps.Config`
7 - - `Sitemaps.Builders.File`
8 - - `Sitemaps.Builders.IndexFile`
9 - - `Sitemaps.Namer`
10 - - `:namer_index_file`
11 - - `:namer_file`
12 - """
13 - use Application
14 -
15 - @doc false
16 - @impl true
17 - def start(_type, _args) do
18 - children = [
19 - Sitemaps.Config,
20 - Sitemaps.Builders.File,
21 - Sitemaps.Builders.IndexFile,
22 - %{
23 - id: :namer_index_file,
24 - start: {Sitemaps.Namer, :start_link, [:index_file]}
25 - },
26 - %{
27 - id: :namer_file,
28 - start: {Sitemaps.Namer, :start_link, [:file, [zero: 1, start: 2]]}
29 - }
30 - ]
31 -
32 - opts = [strategy: :one_for_all, name: Sitemaps.Supervisor]
33 - Supervisor.start_link(children, opts)
34 - end
35 -
36 - @doc false
37 - defmacro __using__(opts) do
38 - quote do
39 - use Sitemaps.DSL, unquote(opts)
40 - end
41 - end
42 - end
  @@ -0,0 +1,42 @@
1 + defmodule Sitemaps do
2 + @moduledoc """
3 + Sitemap application is in charge of running the supervisor and the following
4 + processes under it:
5 +
6 + - `Sitemaps.Config`
7 + - `Sitemaps.Builders.File`
8 + - `Sitemaps.Builders.IndexFile`
9 + - `Sitemaps.Namer`
10 + - `:namer_index_file`
11 + - `:namer_file`
12 + """
13 + use Application
14 +
15 + @doc false
16 + @impl true
17 + def start(_type, _args) do
18 + children = [
19 + Sitemaps.Config,
20 + Sitemaps.Builders.File,
21 + Sitemaps.Builders.IndexFile,
22 + %{
23 + id: :namer_index_file,
24 + start: {Sitemaps.Namer, :start_link, [:index_file]}
25 + },
26 + %{
27 + id: :namer_file,
28 + start: {Sitemaps.Namer, :start_link, [:file, [zero: 1, start: 2]]}
29 + }
30 + ]
31 +
32 + opts = [strategy: :one_for_all, name: Sitemaps.Supervisor]
33 + Supervisor.start_link(children, opts)
34 + end
35 +
36 + @doc false
37 + defmacro __using__(opts) do
38 + quote do
39 + use Sitemaps.DSL, unquote(opts)
40 + end
41 + end
42 + end
  @@ -41,6 +41,20 @@ defmodule Sitemaps.Config do
41 41 create_index: boolean()
42 42 }
43 43
44 + @type keys() ::
45 + :max_sitemap_files
46 + | :max_sitemap_links
47 + | :max_sitemap_news
48 + | :max_sitemap_images
49 + | :max_sitemap_file_size
50 + | :host
51 + | :filename
52 + | :public_path
53 + | :files_path
54 + | :verbose
55 + | :compress
56 + | :create_index
57 +
44 58 defstruct [
45 59 :max_sitemap_files,
46 60 :max_sitemap_links,
  @@ -127,7 +141,7 @@ defmodule Sitemaps.Config do
127 141 @doc """
128 142 Set the configuration inside of the agent.
129 143 """
130 - @spec set(String.t(), any()) :: :ok
144 + @spec set(keys(), any()) :: :ok
131 145 def set(key, value) do
132 146 Agent.update(__MODULE__, fn config ->
133 147 Map.update!(config, key, fn _ -> value end)
  @@ -138,7 +152,7 @@ defmodule Sitemaps.Config do
138 152 Passing as first parameter a list of tuples, we use `set/2` for setting
139 153 each pair of key-value data from the `overwrite` parameter.
140 154 """
141 - @spec update([{String.t(), any()}]) :: :ok
155 + @spec update([{keys(), any()}]) :: :ok
142 156 def update(overwrite) do
143 157 Enum.each(overwrite, fn {key, value} ->
144 158 set(key, value)
  @@ -5,7 +5,7 @@ defmodule Sitemaps.Mixfile do
5 5 [
6 6 app: :sitemaps,
7 7 name: "Sitemaps",
8 - version: "0.1.0",
8 + version: "0.1.1",
9 9 elixir: ">= 1.17.0",
10 10 description: "Generating sitemap files",
11 11 build_embedded: Mix.env() == :prod,