cmd: cleanup commands.

Cleanup the code and remove some unused requires.

Needed for https://github.com/Homebrew/brew/pull/8556.
master
Mike McQuaid 2020-09-01 13:46:11 +01:00
parent 9bdc7288e6
commit 7e8631862d
2 changed files with 23 additions and 29 deletions

View File

@ -1,7 +1,6 @@
# frozen_string_literal: true # frozen_string_literal: true
require "cli/parser" require "cli/parser"
require "open-uri"
require "resource" require "resource"
require "formula" require "formula"
@ -21,43 +20,40 @@ module Homebrew
def aspell_dictionaries def aspell_dictionaries
aspell_dictionaries_args.parse aspell_dictionaries_args.parse
dict_url = "https://ftp.gnu.org/gnu/aspell/dict" dictionary_url = "https://ftp.gnu.org/gnu/aspell/dict"
dict_mirror = "https://ftpmirror.gnu.org/aspell/dict" dictionary_mirror = "https://ftpmirror.gnu.org/aspell/dict"
languages = {} languages = {}
URI.parse("#{dict_url}/0index.html").open do |content| index_output, = curl_output("#{dictionary_url}/0index.html")
content.each_line do |line| index_output.split("<tr><td>").each do |line|
break if line.start_with?("</table") next unless line.start_with?("<a ")
next unless line.start_with?("<tr><td><a/")
fields = line.split('"') _, language, _, path, = line.split('"')
lang = fields[1] language.tr!("-", "_")
path = fields[3] languages[language] = path
lang.tr!("-", "_")
languages[lang] = path
end
end end
resources = languages.map do |lang, path| resources = languages.map do |language, path|
r = Resource.new(lang) r = Resource.new(language)
r.owner = Formulary.factory("aspell") r.owner = Formula["aspell"]
r.url "#{dict_url}/#{path}" r.url "#{dictionary_url}/#{path}"
r.mirror "#{dict_mirror}/#{path}" r.mirror "#{dictionary_mirror}/#{path}"
r r
end end
resources.each { |r| r.fetch(verify_download_integrity: false) } output = resources.map do |resource|
resource.fetch(verify_download_integrity: false)
resources.each do |r| <<-EOS
puts <<-EOS resource "#{resource.name}" do
resource "#{r.name}" do url "#{resource.url}"
url "#{r.url}" mirror "#{resource.mirrors.first}"
mirror "#{r.mirrors.first}" sha256 "#{resource.cached_download.sha256}"
sha256 "#{r.cached_download.sha256}"
end end
EOS EOS
end end
puts output
end end
end end

View File

@ -1,8 +1,6 @@
# frozen_string_literal: true # frozen_string_literal: true
require "cli/parser" require "cli/parser"
require "open-uri"
require "resource"
require "formula" require "formula"
module Homebrew module Homebrew