mirror of
https://github.com/Homebrew/brew.git
synced 2025-07-14 16:09:03 +08:00
Merge pull request #10407 from SeekingMeaning/version-public-api
version: mark methods as public
This commit is contained in:
commit
acdb05dbcf
@ -93,46 +93,68 @@ module Cask
|
|||||||
to_s == "latest"
|
to_s == "latest"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# @api public
|
||||||
|
sig { returns(T.self_type) }
|
||||||
def major
|
def major
|
||||||
version { slice(MAJOR_MINOR_PATCH_REGEX, 1) }
|
version { slice(MAJOR_MINOR_PATCH_REGEX, 1) }
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# @api public
|
||||||
|
sig { returns(T.self_type) }
|
||||||
def minor
|
def minor
|
||||||
version { slice(MAJOR_MINOR_PATCH_REGEX, 2) }
|
version { slice(MAJOR_MINOR_PATCH_REGEX, 2) }
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# @api public
|
||||||
|
sig { returns(T.self_type) }
|
||||||
def patch
|
def patch
|
||||||
version { slice(MAJOR_MINOR_PATCH_REGEX, 3) }
|
version { slice(MAJOR_MINOR_PATCH_REGEX, 3) }
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# @api public
|
||||||
|
sig { returns(T.self_type) }
|
||||||
def major_minor
|
def major_minor
|
||||||
version { [major, minor].reject(&:empty?).join(".") }
|
version { [major, minor].reject(&:empty?).join(".") }
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# @api public
|
||||||
|
sig { returns(T.self_type) }
|
||||||
def major_minor_patch
|
def major_minor_patch
|
||||||
version { [major, minor, patch].reject(&:empty?).join(".") }
|
version { [major, minor, patch].reject(&:empty?).join(".") }
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# @api public
|
||||||
|
sig { returns(T.self_type) }
|
||||||
def minor_patch
|
def minor_patch
|
||||||
version { [minor, patch].reject(&:empty?).join(".") }
|
version { [minor, patch].reject(&:empty?).join(".") }
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# @api public
|
||||||
|
sig { returns(T.self_type) }
|
||||||
def before_comma
|
def before_comma
|
||||||
version { split(",", 2).first }
|
version { split(",", 2).first }
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# @api public
|
||||||
|
sig { returns(T.self_type) }
|
||||||
def after_comma
|
def after_comma
|
||||||
version { split(",", 2).second }
|
version { split(",", 2).second }
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# @api public
|
||||||
|
sig { returns(T.self_type) }
|
||||||
def before_colon
|
def before_colon
|
||||||
version { split(":", 2).first }
|
version { split(":", 2).first }
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# @api public
|
||||||
|
sig { returns(T.self_type) }
|
||||||
def after_colon
|
def after_colon
|
||||||
version { split(":", 2).second }
|
version { split(":", 2).second }
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# @api public
|
||||||
|
sig { returns(T.self_type) }
|
||||||
def no_dividers
|
def no_dividers
|
||||||
version { gsub(DIVIDER_REGEX, "") }
|
version { gsub(DIVIDER_REGEX, "") }
|
||||||
end
|
end
|
||||||
|
@ -555,26 +555,31 @@ class Version
|
|||||||
end
|
end
|
||||||
alias eql? ==
|
alias eql? ==
|
||||||
|
|
||||||
|
# @api public
|
||||||
sig { returns(T.nilable(Token)) }
|
sig { returns(T.nilable(Token)) }
|
||||||
def major
|
def major
|
||||||
tokens.first
|
tokens.first
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# @api public
|
||||||
sig { returns(T.nilable(Token)) }
|
sig { returns(T.nilable(Token)) }
|
||||||
def minor
|
def minor
|
||||||
tokens.second
|
tokens.second
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# @api public
|
||||||
sig { returns(T.nilable(Token)) }
|
sig { returns(T.nilable(Token)) }
|
||||||
def patch
|
def patch
|
||||||
tokens.third
|
tokens.third
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# @api public
|
||||||
sig { returns(Version) }
|
sig { returns(Version) }
|
||||||
def major_minor
|
def major_minor
|
||||||
Version.new([major, minor].compact.join("."))
|
Version.new([major, minor].compact.join("."))
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# @api public
|
||||||
sig { returns(Version) }
|
sig { returns(Version) }
|
||||||
def major_minor_patch
|
def major_minor_patch
|
||||||
Version.new([major, minor, patch].compact.join("."))
|
Version.new([major, minor, patch].compact.join("."))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user