mirror of
https://github.com/wavetermdev/homebrew-cask.git
synced 2026-08-05 13:43:24 -07:00
developer/bin/find-appcast: fix RuboCop style.
See https://github.com/Homebrew/brew/pull/7867.
This commit is contained in:
+28
-25
@@ -1,11 +1,11 @@
|
||||
#!/usr/bin/env ruby
|
||||
|
||||
require 'open3'
|
||||
require 'pathname'
|
||||
require 'yaml'
|
||||
require "open3"
|
||||
require "pathname"
|
||||
require "yaml"
|
||||
|
||||
require 'net/http'
|
||||
require 'uri'
|
||||
require "net/http"
|
||||
require "uri"
|
||||
|
||||
def verify_appcast(appcast_type, *urls)
|
||||
print "Looking for #{appcast_type} appcast… "
|
||||
@@ -13,46 +13,46 @@ def verify_appcast(appcast_type, *urls)
|
||||
urls.each do |url|
|
||||
next unless url_exist?(url)
|
||||
|
||||
puts 'Found!'
|
||||
puts "Found!"
|
||||
puts " #{url}"
|
||||
return true
|
||||
end
|
||||
|
||||
puts 'Not found.'
|
||||
puts "Not found."
|
||||
false
|
||||
end
|
||||
|
||||
def url_exist?(url)
|
||||
return false unless url
|
||||
|
||||
system('curl', '--silent', '--location', '--fail', url, out: File::NULL)
|
||||
system("curl", "--silent", "--location", "--fail", url, out: File::NULL)
|
||||
end
|
||||
|
||||
def find_sparkle(app)
|
||||
plist = app.join('Contents/Info.plist')
|
||||
url = Open3.capture3('defaults', 'read', plist.to_path, 'SUFeedURL').first.strip
|
||||
plist = app.join("Contents/Info.plist")
|
||||
url = Open3.capture3("defaults", "read", plist.to_path, "SUFeedURL").first.strip
|
||||
|
||||
verify_appcast('Sparkle', url)
|
||||
verify_appcast("Sparkle", url)
|
||||
end
|
||||
|
||||
def find_electron_builder(app)
|
||||
appcast_file = app.join('Contents/Resources/app-update.yml')
|
||||
appcast_file = app.join("Contents/Resources/app-update.yml")
|
||||
|
||||
unless appcast_file.exist?
|
||||
verify_appcast('electron-builder', false)
|
||||
verify_appcast("electron-builder", false)
|
||||
return false
|
||||
end
|
||||
|
||||
data = YAML.load_file(appcast_file)
|
||||
bucket = data['bucket']
|
||||
channel = data['channel']
|
||||
endpoint = data['endpoint']
|
||||
name = data['name']
|
||||
owner = data['owner']
|
||||
path = data['path']
|
||||
region = data['region']
|
||||
repo = data['repo']
|
||||
url = data['url']
|
||||
bucket = data["bucket"]
|
||||
channel = data["channel"]
|
||||
endpoint = data["endpoint"]
|
||||
name = data["name"]
|
||||
owner = data["owner"]
|
||||
path = data["path"]
|
||||
region = data["region"]
|
||||
repo = data["repo"]
|
||||
url = data["url"]
|
||||
|
||||
possible_appcasts = [
|
||||
"#{url}/latest-mac.yml",
|
||||
@@ -66,9 +66,12 @@ def find_electron_builder(app)
|
||||
"https://#{name}.#{region}.digitaloceanspaces.com/latest-mac.yml",
|
||||
"https://#{name}.#{region}.digitaloceanspaces.com/#{path}/latest-mac.yml",
|
||||
"#{endpoint}/#{bucket}/#{path}/latest-mac.yml",
|
||||
].map { |appcast| appcast.gsub(%r{(?<!:)/{2,}}, '/') } # Collapse groups of two or more forward slahses into one, except when preceded by a colon
|
||||
].map do |appcast|
|
||||
# Collapse groups of two or more forward slashes into one, except when preceded by a colon
|
||||
appcast.gsub(%r{(?<!:)/{2,}}, "/")
|
||||
end
|
||||
|
||||
unless verify_appcast('electron-builder', *possible_appcasts)
|
||||
unless verify_appcast("electron-builder", *possible_appcasts)
|
||||
warn <<~MESSAGE
|
||||
|
||||
An "app-update.yml" file was found, but we could not parse it.
|
||||
@@ -81,7 +84,7 @@ def find_electron_builder(app)
|
||||
end
|
||||
end
|
||||
|
||||
App = Pathname(ARGV[0])
|
||||
App = Pathname(ARGV[0]).freeze
|
||||
|
||||
find_sparkle(App)
|
||||
find_electron_builder(App)
|
||||
|
||||
Reference in New Issue
Block a user