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
/^v?\d+(?:\.\d+)*(?:-[0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*)?(?:\+[0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*)?$/
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.
25 26 27 28 29 30 31 32 33 |
# File 'lib/dependabot/julia/version.rb', line 25 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
18 19 20 21 22 |
# File 'lib/dependabot/julia/version.rb', line 18 def self.correct?(version) return false if version.nil? VERSION_PATTERN.match?(version.to_s.strip) end |
.gem_compatible_version_string(version_string) ⇒ Object
50 51 52 53 54 55 |
# File 'lib/dependabot/julia/version.rb', line 50 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
40 41 42 |
# File 'lib/dependabot/julia/version.rb', line 40 def self.new(version) T.cast(super, Dependabot::Julia::Version) end |
Instance Method Details
#to_s ⇒ Object
58 59 60 |
# File 'lib/dependabot/julia/version.rb', line 58 def to_s @version_string end |
#to_semver ⇒ Object
63 64 65 |
# File 'lib/dependabot/julia/version.rb', line 63 def to_semver @version_string end |