forked from seomoz/publicsuffix-elixir
-
Notifications
You must be signed in to change notification settings - Fork 8
/
mix.exs
107 lines (93 loc) · 2.31 KB
/
mix.exs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
defmodule PublicSuffix.Mixfile do
use Mix.Project
def project do
[
app: :public_suffix,
version: "0.6.0",
elixir: "~> 1.14",
build_embedded: Mix.env() == :prod,
start_permanent: Mix.env() == :prod,
aliases: aliases(),
description: description(),
package: package(),
deps: deps()
]
end
def application do
[
extra_applications: [
:logger,
:inets,
:ssl
]
]
end
defp deps do
[
{:idna, ">= 1.2.0 and < 7.0.0", runtime: false},
# ex_doc and earmark are necessary to publish docs to hexdocs.pm.
{:ex_doc, ">= 0.0.0", only: :dev},
{:earmark, ">= 0.0.0", only: :dev}
]
end
defp description do
"""
Operate on domain names using the public suffix rules provided by https://publicsuffix.org/.
"""
end
defp package do
[
licenses: ["MIT"],
maintainers: ["Myron Marston", "Ben Kirzhner"],
links: %{
"GitHub" => "https://github.com/seomoz/publicsuffix-elixir",
"Public Suffix List" => "https://publicsuffix.org/"
},
files: [
"lib",
"data/public_suffix_list.dat",
"mix.exs",
"README.md",
"LICENSE",
"CHANGELOG.md"
]
]
end
defp aliases do
[
"hex.publish": ["hex.publish", &tag_version/1]
]
end
defp tag_version(_args) do
version = Keyword.fetch!(project(), :version)
System.cmd("git", ["tag", "-a", "-m", "Version #{version}", "v#{version}"])
System.cmd("git", ["push", "origin"])
System.cmd("git", ["push", "origin", "--tags"])
end
end
defmodule Mix.Tasks.PublicSuffix.SyncFiles do
use Mix.Task
@shortdoc "Syncs the files from publicsuffix.org"
@data_dir Path.expand("data", __DIR__)
def run(_) do
File.mkdir_p!(@data_dir)
sync_file("https://publicsuffix.org/list/public_suffix_list.dat", "public_suffix_list.dat")
sync_file(
"https://raw.githubusercontent.com/publicsuffix/list/master/tests/tests.txt",
"tests.txt"
)
end
defp sync_file(remote_url, local_path) do
local_path = Path.join(@data_dir, local_path)
[
"curl",
"-s",
remote_url,
"--output",
local_path
]
|> Enum.join(" ")
|> Mix.shell().cmd
IO.puts("Synced #{remote_url} to #{local_path}")
end
end