Class: Cask::DSL::Version Private
- Defined in:
- Library/Homebrew/cask/dsl/version.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Class corresponding to the version
stanza.
Constant Summary collapse
- DIVIDERS =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
{ "." => :dots, "-" => :hyphens, "_" => :underscores, }.freeze
- DIVIDER_REGEX =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
/(#{DIVIDERS.keys.map { |v| Regexp.quote(v) }.join('|')})/.freeze
- MAJOR_MINOR_PATCH_REGEX =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
/^([^.,:]+)(?:.([^.,:]+)(?:.([^.,:]+))?)?/.freeze
- INVALID_CHARACTERS =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
/[^0-9a-zA-Z.,:\-_]/.freeze
Instance Attribute Summary collapse
- #raw_version ⇒ Object readonly private
Instance Method Summary collapse
- #after_colon ⇒ Object private
- #after_comma ⇒ Object private
- #before_colon ⇒ Object private
- #before_comma ⇒ Object private
-
#initialize(raw_version) ⇒ Version
constructor
private
A new instance of Version.
- #invalid_characters ⇒ Object private
- #latest? ⇒ Boolean private
- #major ⇒ Object private
- #major_minor ⇒ Object private
- #major_minor_patch ⇒ Object private
- #minor ⇒ Object private
- #minor_patch ⇒ Object private
- #no_dividers ⇒ Object private
- #patch ⇒ Object private
- #unstable? ⇒ Boolean private
Methods inherited from String
Constructor Details
#initialize(raw_version) ⇒ Version
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of Version.
65 66 67 68 |
# File 'Library/Homebrew/cask/dsl/version.rb', line 65 def initialize(raw_version) @raw_version = raw_version super(raw_version.to_s) end |
Instance Attribute Details
#raw_version ⇒ Object (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
63 64 65 |
# File 'Library/Homebrew/cask/dsl/version.rb', line 63 def raw_version @raw_version end |
Instance Method Details
#after_colon ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
127 128 129 |
# File 'Library/Homebrew/cask/dsl/version.rb', line 127 def after_colon version { split(":", 2).second } end |
#after_comma ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
119 120 121 |
# File 'Library/Homebrew/cask/dsl/version.rb', line 119 def after_comma version { split(",", 2).second } end |
#before_colon ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
123 124 125 |
# File 'Library/Homebrew/cask/dsl/version.rb', line 123 def before_colon version { split(":", 2).first } end |
#before_comma ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
115 116 117 |
# File 'Library/Homebrew/cask/dsl/version.rb', line 115 def before_comma version { split(",", 2).first } end |
#invalid_characters ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
70 71 72 73 74 |
# File 'Library/Homebrew/cask/dsl/version.rb', line 70 def invalid_characters return [] if latest? raw_version.scan(INVALID_CHARACTERS) end |
#latest? ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
87 88 89 |
# File 'Library/Homebrew/cask/dsl/version.rb', line 87 def latest? to_s == "latest" end |
#major ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
91 92 93 |
# File 'Library/Homebrew/cask/dsl/version.rb', line 91 def major version { slice(MAJOR_MINOR_PATCH_REGEX, 1) } end |
#major_minor ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
103 104 105 |
# File 'Library/Homebrew/cask/dsl/version.rb', line 103 def major_minor version { [major, minor].reject(&:empty?).join(".") } end |
#major_minor_patch ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
107 108 109 |
# File 'Library/Homebrew/cask/dsl/version.rb', line 107 def major_minor_patch version { [major, minor, patch].reject(&:empty?).join(".") } end |
#minor ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
95 96 97 |
# File 'Library/Homebrew/cask/dsl/version.rb', line 95 def minor version { slice(MAJOR_MINOR_PATCH_REGEX, 2) } end |
#minor_patch ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
111 112 113 |
# File 'Library/Homebrew/cask/dsl/version.rb', line 111 def minor_patch version { [minor, patch].reject(&:empty?).join(".") } end |
#no_dividers ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
131 132 133 |
# File 'Library/Homebrew/cask/dsl/version.rb', line 131 def no_dividers version { gsub(DIVIDER_REGEX, "") } end |
#patch ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
99 100 101 |
# File 'Library/Homebrew/cask/dsl/version.rb', line 99 def patch version { slice(MAJOR_MINOR_PATCH_REGEX, 3) } end |
#unstable? ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
76 77 78 79 80 81 82 83 84 85 |
# File 'Library/Homebrew/cask/dsl/version.rb', line 76 def unstable? return false if latest? s = downcase.delete(".").gsub(/[^a-z\d]+/, "-") return true if s.match?(/(\d+|\b)(alpha|beta|preview|rc|dev|canary|snapshot)(\d+|\b)/i) return true if s.match?(/\A[a-z\d]+(-\d+)*-?(a|b|pre)(\d+|\b)/i) false end |