Class: Dependabot::Gradle::Version
- Inherits:
-
Version
- Object
- Version
- Dependabot::Gradle::Version
- Defined in:
- lib/dependabot/gradle/version.rb
Constant Summary collapse
- NULL_VALUES =
%w(0 final ga).freeze
- PREFIXED_TOKEN_HIERARCHY =
{ "." => { qualifier: 1, number: 4 }, "-" => { qualifier: 2, number: 3 }, "_" => { qualifier: 2, number: 3 } }.freeze
- NAMED_QUALIFIERS_HIERARCHY =
{ "a" => 1, "alpha" => 1, "b" => 2, "beta" => 2, "m" => 3, "milestone" => 3, "rc" => 4, "cr" => 4, "pr" => 4, "pre" => 4, "snapshot" => 5, "dev" => 5, "ga" => 6, "" => 6, "final" => 6, "sp" => 7 }.freeze
- VERSION_PATTERN =
"[0-9a-zA-Z]+" \ '(?>\.[0-9a-zA-Z]*)*' \ '([_\-\+][0-9A-Za-z_-]*(\.[0-9A-Za-z_-]*)*)?'
- ANCHORED_VERSION_PATTERN =
/\A\s*(#{VERSION_PATTERN})?\s*\z/
Class Method Summary collapse
Instance Method Summary collapse
- #<=>(other) ⇒ Object
-
#initialize(version) ⇒ Version
constructor
A new instance of Version.
- #prerelease? ⇒ Boolean
- #to_s ⇒ Object
Constructor Details
#initialize(version) ⇒ Version
Returns a new instance of Version.
42 43 44 45 |
# File 'lib/dependabot/gradle/version.rb', line 42 def initialize(version) @version_string = version.to_s super(version.to_s.tr("_", "-")) end |
Class Method Details
.correct?(version) ⇒ Boolean
36 37 38 39 40 |
# File 'lib/dependabot/gradle/version.rb', line 36 def self.correct?(version) return false if version.nil? version.to_s.match?(ANCHORED_VERSION_PATTERN) end |
Instance Method Details
#<=>(other) ⇒ Object
60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 |
# File 'lib/dependabot/gradle/version.rb', line 60 def <=>(other) version = stringify_version(@version_string) version = fill_tokens(version) version = trim_version(version) other_version = stringify_version(other) other_version = fill_tokens(other_version) other_version = trim_version(other_version) version, other_version = convert_dates(version, other_version) prefixed_tokens = split_into_prefixed_tokens(version) other_prefixed_tokens = split_into_prefixed_tokens(other_version) prefixed_tokens, other_prefixed_tokens = pad_for_comparison(prefixed_tokens, other_prefixed_tokens) prefixed_tokens.count.times.each do |index| comp = compare_prefixed_token( prefix: prefixed_tokens[index][0], token: prefixed_tokens[index][1..-1] || "", other_prefix: other_prefixed_tokens[index][0], other_token: other_prefixed_tokens[index][1..-1] || "" ) return comp unless comp.zero? end 0 end |
#prerelease? ⇒ Boolean
51 52 53 54 55 56 57 58 |
# File 'lib/dependabot/gradle/version.rb', line 51 def prerelease? tokens.any? do |token| next true if token == "eap" next false unless NAMED_QUALIFIERS_HIERARCHY[token] NAMED_QUALIFIERS_HIERARCHY[token] < 6 end end |
#to_s ⇒ Object
47 48 49 |
# File 'lib/dependabot/gradle/version.rb', line 47 def to_s @version_string end |