Module: Readall Private
- Defined in:
- extend/os/mac/readall.rb,
readall.rb
Overview
This module is part of a private API. This module may only be used in the Homebrew/brew repository. Third parties should avoid using this module if possible, as it may be removed or changed without warning.
Helper module for validating syntax in taps.
Class Method Summary collapse
-
.valid_aliases?(alias_dir, formula_dir) ⇒ Boolean
private
-
.valid_casks?(_casks, os_name: nil, arch: nil) ⇒ Boolean
private
-
.valid_formulae?(formulae, bottle_tag: nil) ⇒ Boolean
private
-
.valid_ruby_syntax?(ruby_files) ⇒ Boolean
private
-
.valid_tap?(tap, aliases: false, no_simulate: false, os_arch_combinations: OnSystem::ALL_OS_ARCH_COMBINATIONS) ⇒ Boolean
private
Class Method Details
.valid_aliases?(alias_dir, formula_dir) ⇒ Boolean
This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'readall.rb', line 21 def valid_aliases?(alias_dir, formula_dir) return true unless alias_dir.directory? failed = T.let(false, T::Boolean) alias_dir.each_child do |f| if !f.symlink? onoe "Non-symlink alias: #{f}" failed = true elsif !f.file? onoe "Non-file alias: #{f}" failed = true end if formula_dir.glob("**/#{f.basename}.rb").any?(&:exist?) onoe "Formula duplicating alias: #{f}" failed = true end end !failed end |
.valid_casks?(_casks, os_name: nil, arch: nil) ⇒ Boolean
This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.
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 |
# File 'extend/os/mac/readall.rb', line 6 def valid_casks?(casks, os_name: nil, arch: Hardware::CPU.type) return true if os_name == :linux current_macos_version = if os_name.is_a?(Symbol) MacOSVersion.from_symbol(os_name) else MacOS.version end success = T.let(true, T::Boolean) casks.each do |file| cask = Cask::CaskLoader.load(file) # Fine to have missing URLs for unsupported macOS macos_req = cask.depends_on.macos next if macos_req&.version && Array(macos_req.version).none? do |macos_version| current_macos_version.compare(macos_req.comparator, macos_version) end raise "Missing URL" if cask.url.nil? rescue Interrupt raise rescue Exception => e # rubocop:disable Lint/RescueException os_and_arch = "macOS #{current_macos_version} on #{arch}" onoe "Invalid cask (#{os_and_arch}): #{file}" $stderr.puts e success = false end success end |
.valid_formulae?(formulae, bottle_tag: nil) ⇒ Boolean
This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'readall.rb', line 42 def valid_formulae?(formulae, bottle_tag: nil) success = T.let(true, T::Boolean) formulae.each do |file| base = Formulary.factory(file) next if bottle_tag.blank? || !base.path.exist? || !base.class.on_system_blocks_exist? formula_contents = base.path.read readall_namespace = Formulary.class_s("Readall#{bottle_tag.to_sym.capitalize}") readall_formula_class = Formulary.load_formula(base.name, base.path, formula_contents, readall_namespace, flags: base.class.build_flags, ignore_errors: true) readall_formula_class.new(base.name, base.path, :stable, alias_path: base.alias_path, force_bottle: base.force_bottle) rescue Interrupt raise rescue Exception => e # rubocop:disable Lint/RescueException onoe "Invalid formula (#{bottle_tag}): #{file}" $stderr.puts e success = false end success end |
.valid_ruby_syntax?(ruby_files) ⇒ Boolean
This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.
12 13 14 15 16 17 18 19 |
# File 'readall.rb', line 12 def valid_ruby_syntax?(ruby_files) failed = T.let(false, T::Boolean) ruby_files.each do |ruby_file| # As a side effect, print syntax errors/warnings to `$stderr`. failed = true if syntax_errors_or_warnings?(ruby_file) end !failed end |
.valid_tap?(tap, aliases: false, no_simulate: false, os_arch_combinations: OnSystem::ALL_OS_ARCH_COMBINATIONS) ⇒ Boolean
This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.
69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 |
# File 'readall.rb', line 69 def valid_tap?(tap, aliases: false, no_simulate: false, os_arch_combinations: OnSystem::ALL_OS_ARCH_COMBINATIONS) success = true if aliases valid_aliases = valid_aliases?(tap.alias_dir, tap.formula_dir) success = false unless valid_aliases end if no_simulate success = false unless valid_formulae?(tap.formula_files) success = false unless valid_casks?(tap.cask_files) else os_arch_combinations.each do |os, arch| bottle_tag = Utils::Bottles::Tag.new(system: os, arch: arch) next unless bottle_tag.valid_combination? Homebrew::SimulateSystem.with os: os, arch: arch do success = false unless valid_formulae?(tap.formula_files, bottle_tag: bottle_tag) success = false unless valid_casks?(tap.cask_files, os_name: os, arch: arch) end end end success end |