Module: Readall Private

Defined in:
Library/Homebrew/readall.rb,
Library/Homebrew/extend/os/linux/readall.rb

Overview

This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.

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. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (Boolean)

20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'Library/Homebrew/readall.rb', line 20

def valid_aliases?(alias_dir, formula_dir)
  return true unless alias_dir.directory?

  failed = false
  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?Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (Boolean)

55
56
57
58
59
60
61
62
63
64
65
66
67
# File 'Library/Homebrew/readall.rb', line 55

def valid_casks?(casks)
  success = true
  casks.each do |file|
    Cask::CaskLoader.load(file)
  rescue Interrupt
    raise
  rescue Exception => e # rubocop:disable Lint/RescueException
    onoe "Invalid cask: #{file}"
    $stderr.puts e
    success = false
  end
  success
end

.valid_formulae?(formulae) ⇒ Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (Boolean)

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

def valid_formulae?(formulae)
  success = true
  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. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (Boolean)

11
12
13
14
15
16
17
18
# File 'Library/Homebrew/readall.rb', line 11

def valid_ruby_syntax?(ruby_files)
  failed = false
  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. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (Boolean)

69
70
71
72
73
74
75
76
77
78
79
# File 'Library/Homebrew/readall.rb', line 69

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