-
-
Notifications
You must be signed in to change notification settings - Fork 12.5k
/
aspell-dictionaries.rb
executable file
·59 lines (48 loc) · 1.48 KB
/
aspell-dictionaries.rb
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
# typed: strict
# frozen_string_literal: true
require "abstract_command"
require "resource"
require "formula"
module Homebrew
module Cmd
class AspellDictionariesCmd < AbstractCommand
cmd_args do
usage_banner <<~EOS
`aspell-dictionaries`
Generates the new dictionaries for the `aspell` formula.
EOS
end
sig { override.void }
def run
dictionary_url = "https://ftp.gnu.org/gnu/aspell/dict"
dictionary_mirror = "https://ftpmirror.gnu.org/aspell/dict"
languages = {}
index_output, = Utils::Curl.curl_output("#{dictionary_url}/0index.html")
index_output.split("<tr><td>").each do |line|
next unless line.start_with?("<a ")
_, language, _, path, = line.split('"')
language.tr!("-", "_")
languages[language] = path
end
resources = languages.map do |language, path|
r = Resource.new(language)
r.owner = Formula["aspell"]
r.url "#{dictionary_url}/#{path}"
r.mirror "#{dictionary_mirror}/#{path}"
r
end
output = resources.map do |resource|
resource.fetch(verify_download_integrity: false)
<<-EOS
resource "#{resource.name}" do
url "#{resource.url}"
mirror "#{resource.mirrors.first}"
sha256 "#{resource.cached_download.sha256}"
end
EOS
end
puts output
end
end
end
end