Module: Readall Private

Defined in:
extend/os/linux/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

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.

Returns:

  • (Boolean)


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/"#{f.basename}.rb").exist?
      onoe "Formula duplicating alias: #{f}"
      failed = true
    end
  end
  !failed
end

.valid_casks?(casks) ⇒ 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.

Returns:

  • (Boolean)


6
7
8
# File 'extend/os/linux/readall.rb', line 6

def valid_casks?(*)
  true
end

.valid_formulae?(formulae) ⇒ 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.

Returns:

  • (Boolean)


42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'readall.rb', line 42

def valid_formulae?(formulae)
  success = T.let(true, T::Boolean)
  formulae.each do |file|
    Formulary.factory(file)
  rescue Interrupt
    raise
  rescue Exception => e # rubocop:disable Lint/RescueException
    onoe "Invalid formula: #{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.

Returns:

  • (Boolean)


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, options = {}) ⇒ 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.

Returns:

  • (Boolean)


70
71
72
73
74
75
76
77
78
79
80
# File 'readall.rb', line 70

def valid_tap?(tap, options = {})
  success = true
  if options[:aliases]
    valid_aliases = valid_aliases?(tap.alias_dir, tap.formula_dir)
    success = false unless valid_aliases
  end
  valid_formulae = valid_formulae?(tap.formula_files)
  valid_casks = valid_casks?(tap.cask_files)
  success = false if !valid_formulae || !valid_casks
  success
end