Document Resource.
This commit is contained in:
parent
a9c271ddba
commit
7e7e4c179b
@ -8,6 +8,8 @@ require "mktemp"
|
|||||||
# Resource is the fundamental representation of an external resource. The
|
# Resource is the fundamental representation of an external resource. The
|
||||||
# primary formula download, along with other declared resources, are instances
|
# primary formula download, along with other declared resources, are instances
|
||||||
# of this class.
|
# of this class.
|
||||||
|
#
|
||||||
|
# @api private
|
||||||
class Resource
|
class Resource
|
||||||
include Context
|
include Context
|
||||||
include FileUtils
|
include FileUtils
|
||||||
@ -69,9 +71,11 @@ class Resource
|
|||||||
end
|
end
|
||||||
|
|
||||||
# Verifies download and unpacks it.
|
# Verifies download and unpacks it.
|
||||||
# The block may call `|resource,staging| staging.retain!` to retain the staging
|
# The block may call `|resource, staging| staging.retain!` to retain the staging
|
||||||
# directory. Subclasses that override stage should implement the tmp
|
# directory. Subclasses that override stage should implement the tmp
|
||||||
# dir using {Mktemp} so that works with all subtypes.
|
# dir using {Mktemp} so that works with all subtypes.
|
||||||
|
#
|
||||||
|
# @api public
|
||||||
def stage(target = nil, &block)
|
def stage(target = nil, &block)
|
||||||
raise ArgumentError, "target directory or block is required" if !target && block.blank?
|
raise ArgumentError, "target directory or block is required" if !target && block.blank?
|
||||||
|
|
||||||
@ -211,12 +215,14 @@ class Resource
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# A resource containing a Go package.
|
||||||
class Go < Resource
|
class Go < Resource
|
||||||
def stage(target)
|
def stage(target)
|
||||||
super(target/name)
|
super(target/name)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# A resource containing a patch.
|
||||||
class PatchResource < Resource
|
class PatchResource < Resource
|
||||||
attr_reader :patch_files
|
attr_reader :patch_files
|
||||||
|
|
||||||
@ -243,6 +249,8 @@ end
|
|||||||
# The context in which a {Resource.stage} occurs. Supports access to both
|
# The context in which a {Resource.stage} occurs. Supports access to both
|
||||||
# the {Resource} and associated {Mktemp} in a single block argument. The interface
|
# the {Resource} and associated {Mktemp} in a single block argument. The interface
|
||||||
# is back-compatible with {Resource} itself as used in that context.
|
# is back-compatible with {Resource} itself as used in that context.
|
||||||
|
#
|
||||||
|
# @api private
|
||||||
class ResourceStageContext
|
class ResourceStageContext
|
||||||
extend Forwardable
|
extend Forwardable
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user