Class: Dependabot::Maven::VersionParser
- Inherits:
-
Object
- Object
- Dependabot::Maven::VersionParser
- Extended by:
- T::Helpers, T::Sig
- Defined in:
- lib/dependabot/maven/version_parser.rb
Constant Summary collapse
- ALPHA =
-5
- BETA =
-4
- MILESTONE =
-3
- RC =
-2
- SNAPSHOT =
-1
- SP =
"sp"
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(version) ⇒ VersionParser
constructor
A new instance of VersionParser.
- #parse ⇒ Object
Constructor Details
#initialize(version) ⇒ VersionParser
Returns a new instance of VersionParser.
32 33 34 35 36 37 |
# File 'lib/dependabot/maven/version_parser.rb', line 32 def initialize(version) @version = version @token_bucket = T.let(TokenBucket.new(tokens: []), T.nilable(TokenBucket)) @parse_result = T.let(@token_bucket, T.nilable(TokenBucket)) @scanner = T.let(StringScanner.new(version.downcase), StringScanner) end |
Class Method Details
.parse(version) ⇒ Object
24 25 26 27 28 29 |
# File 'lib/dependabot/maven/version_parser.rb', line 24 def self.parse(version) raise BadRequirementError, "Malformed version string - string is nil" if version.nil? raise BadRequirementError, "Malformed version string - string is empty" if version.empty? new(version).parse end |
Instance Method Details
#parse ⇒ Object
40 41 42 43 44 45 46 47 |
# File 'lib/dependabot/maven/version_parser.rb', line 40 def parse parse_version(false) # no tokens: version is just one of the tokens we split on e.g '.' or '-' raise BadRequirementError, "Malformed version string - #{version}" if parse_result.to_a.empty? T.must(parse_result) end |