Class: Dependabot::Julia::Version
- Inherits:
-
Version
- Object
- Version
- Dependabot::Julia::Version
- Defined in:
- lib/dependabot/julia/version.rb
Constant Summary collapse
- VERSION_PATTERN =
Julia follows semantic versioning, including prerelease tags and build metadata. Build metadata is significant in Julia: JLL packages register versions like "1.6.10+0", "1.6.10+1" where the build number orders new builds of the same upstream version. See: https://docs.julialang.org/en/v1/stdlib/Pkg/#Version-specifier-format
T.let( /^v?\d+(?:\.\d+)*(?:-[0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*)?(?:\+[0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*)?$/, Regexp )
Class Method Summary collapse
- .correct?(version) ⇒ Boolean
- .gem_compatible_version_string(version_string) ⇒ Object
- .new(version) ⇒ Object
Instance Method Summary collapse
-
#initialize(version) ⇒ Version
constructor
A new instance of Version.
- #to_s ⇒ Object
- #to_semver ⇒ Object
Constructor Details
#initialize(version) ⇒ Version
Returns a new instance of Version.
27 28 29 30 31 32 33 34 35 |
# File 'lib/dependabot/julia/version.rb', line 27 def initialize(version) version_string = version.to_s.strip # Remove 'v' prefix if present (common in Julia) version_string = version_string.sub(/^v/, "") if version_string.match?(/^v\d/) @version_string = T.let(version_string, String) super(self.class.gem_compatible_version_string(version_string)) end |
Class Method Details
.correct?(version) ⇒ Boolean
20 21 22 23 24 |
# File 'lib/dependabot/julia/version.rb', line 20 def self.correct?(version) return false if version.nil? VERSION_PATTERN.match?(version.to_s.strip) end |
.gem_compatible_version_string(version_string) ⇒ Object
52 53 54 55 56 57 |
# File 'lib/dependabot/julia/version.rb', line 52 def self.gem_compatible_version_string(version_string) base, build = version_string.split("+", 2) return version_string unless build build.match?(/\A\d+\z/) ? "#{base}.#{build}" : T.must(base) end |
.new(version) ⇒ Object
42 43 44 |
# File 'lib/dependabot/julia/version.rb', line 42 def self.new(version) T.cast(super, Dependabot::Julia::Version) end |
Instance Method Details
#to_s ⇒ Object
60 61 62 |
# File 'lib/dependabot/julia/version.rb', line 60 def to_s @version_string end |
#to_semver ⇒ Object
65 66 67 |
# File 'lib/dependabot/julia/version.rb', line 65 def to_semver @version_string end |