Spec-Zone.ru › Homebrew

Module: Context Private

Extended by:
MonitorMixin
Included in:
AbstractDownloadStrategy, Cask::CaskLoader, Cask::Download, Cleaner, Downloadable, Formula, FormulaVersions, Formulary, Formulary::FormulaLoader, GitHubPackages, GitHubReleases, Homebrew, Homebrew::Assertions, Migrator, ObserverPathnameExtension, SystemCommand, SystemCommand::Result, Utils::Analytics
Defined in:
context.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.

Module for querying the current execution context.

Defined Under Namespace

Classes: ContextStruct

Class Method Summary collapse

  • .current ⇒ ContextStruct private
  • .current=(context) ⇒ void private

Instance Method Summary collapse

  • #debug? ⇒ Boolean private
  • #quiet? ⇒ Boolean private
  • #verbose? ⇒ Boolean private
  • #with_context(debug: debug?, , quiet: quiet?, , verbose: verbose?, , &_block) ⇒ T.untyped private

Class Method Details

.current ⇒ ContextStruct

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:

  • (ContextStruct)


45
46
47
48
49
50
51
52
53
54
55
# File 'context.rb', line 45

def self.current
  current_context = T.cast(Thread.current[:context], T.nilable(ContextStruct))
  return current_context if current_context

  synchronize do
    current = T.let(@current, T.nilable(ContextStruct))
    current ||= ContextStruct.new
    @current = current
    current
  end
end

.current=(context) ⇒ void

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.

This method returns an undefined value.

Parameters:

  • context (ContextStruct)


38
39
40
41
42
# File 'context.rb', line 38

def self.current=(context)
  synchronize do
    @current = context
  end
end

Instance Method Details

#debug? ⇒ 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)


58
59
60
# File 'context.rb', line 58

def debug?
  Context.current.debug?
end

#quiet? ⇒ 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)


63
64
65
# File 'context.rb', line 63

def quiet?
  Context.current.quiet?
end

#verbose? ⇒ 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)


68
69
70
# File 'context.rb', line 68

def verbose?
  Context.current.verbose?
end

#with_context(debug: debug?, , quiet: quiet?, , verbose: verbose?, , &_block) ⇒ T.untyped

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.

Parameters:

  • debug (Boolean, nil) (defaults to: debug?, )
  • quiet (Boolean, nil) (defaults to: quiet?, )
  • verbose (Boolean, nil) (defaults to: verbose?, )
  • _block (T.proc.void)

Returns:

  • (T.untyped)


76
77
78
79
80
81
82
83
84
85
# File 'context.rb', line 76

def with_context(debug: debug?, quiet: quiet?, verbose: verbose?, &_block)
  old_context = Context.current
  Thread.current[:context] = ContextStruct.new(debug:, quiet:, verbose:)

  begin
    yield
  ensure
    Thread.current[:context] = old_context
  end
end

© 2009–present Homebrew contributors
Licensed under the BSD 2-Clause License.
https://docs.brew.sh/rubydoc/Context.html

Spec-Zone.ru

Настройки Оффлайн Что нового Помощь О нас
Spec-Zone .ru
спецификации, руководства, описания, API