forked from sjackman/linuxbrew-core
-
Notifications
You must be signed in to change notification settings - Fork 0
/
aspell-dictionaries.rb
executable file
·59 lines (46 loc) · 1.34 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
# frozen_string_literal: true
require "cli/parser"
require "resource"
require "formula"
module Homebrew
module_function
def aspell_dictionaries_args
Homebrew::CLI::Parser.new do
usage_banner <<~EOS
`aspell-dictionaries`
Generates the new dictionaries for the `aspell` formula.
EOS
end
end
def aspell_dictionaries
aspell_dictionaries_args.parse
dictionary_url = "https://ftp.gnu.org/gnu/aspell/dict"
dictionary_mirror = "https://ftpmirror.gnu.org/aspell/dict"
languages = {}
index_output, = 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