Class: Dependabot::Maven::NewVersion
- Inherits:
-
Object
- Object
- Dependabot::Maven::NewVersion
- Extended by:
- T::Helpers, T::Sig
- Defined in:
- lib/dependabot/maven/new_version.rb
Constant Summary collapse
- PRERELEASE_QUALIFIERS =
T.let([ Dependabot::Maven::VersionParser::ALPHA, Dependabot::Maven::VersionParser::BETA, Dependabot::Maven::VersionParser::MILESTONE, Dependabot::Maven::VersionParser::RC, Dependabot::Maven::VersionParser::SNAPSHOT ].freeze, T::Array[Integer])
Instance Attribute Summary collapse
-
#token_bucket ⇒ Object
Returns the value of attribute token_bucket.
Class Method Summary collapse
Instance Method Summary collapse
- #<=>(other) ⇒ Object
-
#initialize(version) ⇒ NewVersion
constructor
A new instance of NewVersion.
- #inspect ⇒ Object
- #prerelease? ⇒ Boolean
- #to_s ⇒ Object
Constructor Details
#initialize(version) ⇒ NewVersion
Returns a new instance of NewVersion.
38 39 40 41 |
# File 'lib/dependabot/maven/new_version.rb', line 38 def initialize(version) @version_string = T.let(version, String) @token_bucket = T.let(Dependabot::Maven::VersionParser.parse(version), Dependabot::Maven::TokenBucket) end |
Instance Attribute Details
#token_bucket ⇒ Object
Returns the value of attribute token_bucket.
25 26 27 |
# File 'lib/dependabot/maven/new_version.rb', line 25 def token_bucket @token_bucket end |
Class Method Details
.correct?(version) ⇒ Boolean
28 29 30 31 32 33 34 35 |
# File 'lib/dependabot/maven/new_version.rb', line 28 def self.correct?(version) return false if version.empty? Dependabot::Maven::VersionParser.parse(version.to_s).to_a.any? rescue Dependabot::BadRequirementError Dependabot.logger.info("Malformed version string - #{version}") false end |
Instance Method Details
#<=>(other) ⇒ Object
61 62 63 |
# File 'lib/dependabot/maven/new_version.rb', line 61 def <=>(other) T.must(token_bucket <=> other.token_bucket) end |
#inspect ⇒ Object
44 45 46 |
# File 'lib/dependabot/maven/new_version.rb', line 44 def inspect "#<#{self.class} #{version_string}>" end |
#prerelease? ⇒ Boolean
54 55 56 57 58 |
# File 'lib/dependabot/maven/new_version.rb', line 54 def prerelease? token_bucket.to_a.flatten.any? do |token| token.is_a?(Integer) && token.negative? end end |
#to_s ⇒ Object
49 50 51 |
# File 'lib/dependabot/maven/new_version.rb', line 49 def to_s version_string end |