aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Homebrew/dev-cmd
diff options
context:
space:
mode:
authorXu Cheng2015-09-13 01:03:38 +0800
committerXu Cheng2015-09-13 01:03:38 +0800
commite6f260de278b55940a300a3b1536ff45b4a5755f (patch)
treebbd43208e76371ed0374f917c2c31cedf49d3a1d /Library/Homebrew/dev-cmd
parent71f6d2d1659a54d9197c8a6eb19c0d337ca752ff (diff)
downloadbrew-e6f260de278b55940a300a3b1536ff45b4a5755f.tar.bz2
aspell-dictionaries: move to dev-cmd
Diffstat (limited to 'Library/Homebrew/dev-cmd')
-rw-r--r--Library/Homebrew/dev-cmd/aspell-dictionaries.rb42
1 files changed, 42 insertions, 0 deletions
diff --git a/Library/Homebrew/dev-cmd/aspell-dictionaries.rb b/Library/Homebrew/dev-cmd/aspell-dictionaries.rb
new file mode 100644
index 000000000..754b6614e
--- /dev/null
+++ b/Library/Homebrew/dev-cmd/aspell-dictionaries.rb
@@ -0,0 +1,42 @@
+require "open-uri"
+require "resource"
+require "formula"
+
+module Homebrew
+ def aspell_dictionaries
+ dict_url = "http://ftpmirror.gnu.org/aspell/dict"
+ dict_mirror = "https://ftp.gnu.org/gnu/aspell/dict"
+ languages = {}
+
+ open("#{dict_url}/0index.html") do |content|
+ content.each_line do |line|
+ break if %r{^</table} === line
+ next unless /^<tr><td><a/ === line
+
+ fields = line.split('"')
+ lang = fields[1]
+ path = fields[3]
+ lang.tr!("-", "_")
+ languages[lang] = path
+ end
+ end
+
+ languages.inject([]) do |resources, (lang, path)|
+ r = Resource.new(lang)
+ r.owner = Formulary.factory("aspell")
+ r.url "#{dict_url}/#{path}"
+ r.mirror "#{dict_mirror}/#{path}"
+ resources << r
+ end.each(&:fetch).each do |r|
+ puts <<-EOS
+ option "with-lang-#{r.name}", "Install #{r.name} dictionary"
+ resource "#{r.name}" do
+ url "#{r.url}"
+ mirror "#{r.mirrors.first}"
+ sha256 "#{r.cached_download.sha256}"
+ end
+
+ EOS
+ end
+ end
+end