Support audit for multilingual casks.
This commit is contained in:
parent
bc2d676b6f
commit
bc143bb470
@ -1,6 +1,24 @@
|
|||||||
module Hbc
|
module Hbc
|
||||||
class Auditor
|
class Auditor
|
||||||
def self.audit(cask, audit_download: false, check_token_conflicts: false)
|
def self.audit(cask, audit_download: false, check_token_conflicts: false)
|
||||||
|
saved_languages = MacOS.instance_variable_get(:@languages)
|
||||||
|
|
||||||
|
if languages_blocks = cask.instance_variable_get(:@dsl).instance_variable_get(:@language_blocks)
|
||||||
|
languages_blocks.keys.map(&:first).each do |language|
|
||||||
|
ohai "Auditing language #{language.to_s}"
|
||||||
|
language = "en-US" if language == :default
|
||||||
|
MacOS.instance_variable_set(:@languages, [language])
|
||||||
|
audit_cask_instance(Hbc.load(cask.sourcefile_path), audit_download, check_token_conflicts)
|
||||||
|
CLI::Cleanup.run(cask.token) if audit_download
|
||||||
|
end
|
||||||
|
else
|
||||||
|
audit_cask_instance(cask, audit_download, check_token_conflicts)
|
||||||
|
end
|
||||||
|
ensure
|
||||||
|
MacOS.instance_variable_set(:@languages, saved_languages)
|
||||||
|
end
|
||||||
|
|
||||||
|
def self.audit_cask_instance(cask, audit_download, check_token_conflicts)
|
||||||
download = audit_download && Download.new(cask)
|
download = audit_download && Download.new(cask)
|
||||||
audit = Audit.new(cask, download: download,
|
audit = Audit.new(cask, download: download,
|
||||||
check_token_conflicts: check_token_conflicts)
|
check_token_conflicts: check_token_conflicts)
|
||||||
|
|||||||
@ -122,8 +122,13 @@ module Hbc
|
|||||||
regexes_or_strings = regexes_or_strings - [:default] + [%r{^en}]
|
regexes_or_strings = regexes_or_strings - [:default] + [%r{^en}]
|
||||||
end
|
end
|
||||||
|
|
||||||
case language
|
regexes_or_strings.each do |regex_or_string|
|
||||||
when *regexes_or_strings
|
if regex_or_string.class == language.class
|
||||||
|
next unless regex_or_string == language
|
||||||
|
else
|
||||||
|
next unless regex_or_string =~ language
|
||||||
|
end
|
||||||
|
|
||||||
@language = block.call
|
@language = block.call
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user