Spec-Zone.ru › Homebrew

Module: Cask::Metadata Private

Extended by:
T::Helpers
Includes:
Utils::Output::Mixin
Included in:
Cask
Defined in:
cask/metadata.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 reading and writing cask metadata.

Constant Summary collapse

METADATA_SUBDIR =

This constant is part of a private API. This constant may only be used in the Homebrew/brew repository. Third parties should avoid using this constant if possible, as it may be removed or changed without warning.

".metadata"
TIMESTAMP_FORMAT =

This constant is part of a private API. This constant may only be used in the Homebrew/brew repository. Third parties should avoid using this constant if possible, as it may be removed or changed without warning.

"%Y%m%d%H%M%S.%L"

Instance Method Summary collapse

  • #metadata_main_container_path(caskroom_path: self.caskroom_path) ⇒ Pathname private
  • #metadata_subdir(leaf, version: self.version, timestamp: :latest, create: false, caskroom_path: self.caskroom_path) ⇒ Pathname? private
  • #metadata_timestamped_path(version: self.version, timestamp: :latest, create: false, caskroom_path: self.caskroom_path) ⇒ Pathname? private
  • #metadata_versioned_path(version: self.version, caskroom_path: self.caskroom_path) ⇒ Pathname private

Methods included from Utils::Output::Mixin

#issue_reporting_message, #odebug, #odeprecated, #odie, #odisabled, #ofail, #oh1, #oh1_title, #ohai, #ohai_title, #onoe, #opoo, #opoo_outside_github_actions, #opoo_without_github_actions_annotation, #pretty_deprecated, #pretty_disabled, #pretty_duration, #pretty_install_status, #pretty_installed, #pretty_uninstalled, #pretty_upgradable, #pretty_warning

Instance Method Details

#metadata_main_container_path(caskroom_path: self.caskroom_path) ⇒ Pathname

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:

  • caskroom_path (Pathname) (defaults to: self.caskroom_path)

Returns:

  • (Pathname)


18
19
20
# File 'cask/metadata.rb', line 18

def metadata_main_container_path(caskroom_path: self.caskroom_path)
  caskroom_path.join(METADATA_SUBDIR)
end

#metadata_subdir(leaf, version: self.version, timestamp: :latest, create: false, caskroom_path: self.caskroom_path) ⇒ Pathname?

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:

  • leaf (String)
  • version (DSL::Version, String, nil) (defaults to: self.version)
  • timestamp (Symbol, String) (defaults to: :latest)
  • create (Boolean) (defaults to: false)
  • caskroom_path (Pathname) (defaults to: self.caskroom_path)

Returns:

  • (Pathname, nil)

Raises:

  • (CaskError)


71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
# File 'cask/metadata.rb', line 71

def metadata_subdir(leaf, version: self.version, timestamp: :latest, create: false,
                    caskroom_path: self.caskroom_path)
  raise CaskError, "Cannot create metadata subdir when timestamp is :latest." if create && timestamp == :latest
  raise CaskError, "Cannot create metadata subdir for empty leaf." if !leaf.respond_to?(:empty?) || leaf.empty?

  parent = metadata_timestamped_path(version:, timestamp:, create:,
                                     caskroom_path:)

  return if parent.nil?

  subdir = parent.join(leaf)

  if create && !subdir.directory?
    odebug "Creating metadata subdirectory: #{subdir}"
    subdir.mkpath
  end

  subdir
end

#metadata_timestamped_path(version: self.version, timestamp: :latest, create: false, caskroom_path: self.caskroom_path) ⇒ Pathname?

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:

  • version (DSL::Version, String, nil) (defaults to: self.version)
  • timestamp (Symbol, String) (defaults to: :latest)
  • create (Boolean) (defaults to: false)
  • caskroom_path (Pathname) (defaults to: self.caskroom_path)

Returns:

  • (Pathname, nil)


39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# File 'cask/metadata.rb', line 39

def metadata_timestamped_path(version: self.version, timestamp: :latest, create: false,
                              caskroom_path: self.caskroom_path)
  case timestamp
  when :latest
    raise CaskError, "Cannot create metadata path when timestamp is :latest." if create

    return Pathname.glob(metadata_versioned_path(version:, caskroom_path:).join("*")).max
  when :now
    timestamp = new_timestamp
  when Symbol
    raise CaskError, "Invalid timestamp symbol :#{timestamp}. Valid symbols are :latest and :now."
  end

  path = metadata_versioned_path(version:, caskroom_path:).join(timestamp)

  if create && !path.directory?
    odebug "Creating metadata directory: #{path}"
    path.mkpath
  end

  path
end

#metadata_versioned_path(version: self.version, caskroom_path: self.caskroom_path) ⇒ Pathname

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:

  • version (DSL::Version, String, nil) (defaults to: self.version)
  • caskroom_path (Pathname) (defaults to: self.caskroom_path)

Returns:

  • (Pathname)

Raises:

  • (CaskError)


23
24
25
26
27
28
29
# File 'cask/metadata.rb', line 23

def metadata_versioned_path(version: self.version, caskroom_path: self.caskroom_path)
  cask_version = (version || :unknown).to_s

  raise CaskError, "Cannot create metadata path with empty version." if cask_version.empty?

  metadata_main_container_path(caskroom_path:).join(cask_version)
end

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

Spec-Zone.ru

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