Class: Resource::Patch Private

Inherits:
Resource
  • Object
show all
Defined in:
resource.rb

Overview

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

A resource containing a patch.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(&block) ⇒ 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.

Parameters:



488
489
490
491
492
493
494
495
# File 'resource.rb', line 488

def initialize(&block)
  @patch_files = T.let([], T::Array[T.any(String, Pathname)])
  @directory = T.let(nil, T.nilable(T.any(String, Pathname)))
  @file = T.let(nil, T.nilable(T.any(String, Pathname)))
  @resolves = T.let([], T::Array[String])
  @type = T.let(nil, T.nilable(Symbol))
  super "patch", &block
end

Instance Attribute Details

#patch_filesArray<String, Pathname> (readonly)

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:



485
486
487
# File 'resource.rb', line 485

def patch_files
  @patch_files
end

Instance Method Details

#apply(*paths) ⇒ 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:



498
499
500
501
# File 'resource.rb', line 498

def apply(*paths)
  @patch_files.concat(paths.flatten)
  @patch_files.uniq!
end

#directory(val = nil) ⇒ String, ...

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:

Returns:



522
523
524
525
526
# File 'resource.rb', line 522

def directory(val = nil)
  return @directory if val.nil?

  @directory = val
end

#download_queue_nameString

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:



544
545
546
547
548
549
550
# File 'resource.rb', line 544

def download_queue_name
  if (last_url_component = url.to_s.split("/").last)
    return last_url_component
  end

  super
end

#download_queue_typeString

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:



541
# File 'resource.rb', line 541

def download_queue_type = "Patch"

#file(val = nil) ⇒ String, ...

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:

Returns:



529
530
531
532
533
534
535
536
537
538
# File 'resource.rb', line 529

def file(val = nil)
  return @file if val.nil?

  path_string = val.to_s
  unless LocalPatch.valid_path?(path_string)
    raise ArgumentError, "Patch file must be a relative path within the repository."
  end

  @file = val
end

#resolves(*cves) ⇒ Array<String>

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:

Returns:



504
505
506
507
508
509
# File 'resource.rb', line 504

def resolves(*cves)
  return @resolves if cves.empty?

  @resolves.concat(cves).uniq!
  @resolves
end

#type(val = nil) ⇒ Symbol?

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:

  • val (Symbol, nil) (defaults to: nil)

Returns:



512
513
514
515
516
517
518
519
# File 'resource.rb', line 512

def type(val = nil)
  return @type if val.nil?
  unless ::Patch::TYPES.key?(val)
    raise ArgumentError, "Patch type must be one of: #{::Patch::TYPES.keys.map(&:inspect).join(", ")}"
  end

  @type = val
end