Class: Dependabot::Vcpkg::Version
- Inherits:
-
Dependabot::Version
- Object
- Dependabot::Version
- Dependabot::Vcpkg::Version
- Extended by:
- T::Sig
- Defined in:
- lib/dependabot/vcpkg/version.rb
Constant Summary collapse
- VERSION_PATTERN =
/\A([0-9]+(?:\.[0-9]+)*(?:-[0-9A-Za-z\-\.]+)?(?:\+[0-9A-Za-z\-\.]+)?)(?:\#([0-9]+))?\z/
Instance Attribute Summary collapse
-
#port_version ⇒ Object
readonly
Returns the value of attribute port_version.
Instance Method Summary collapse
- #<=>(other) ⇒ Object
-
#initialize(version) ⇒ Version
constructor
A new instance of Version.
- #to_s ⇒ Object
Constructor Details
#initialize(version) ⇒ Version
Returns a new instance of Version.
17 18 19 20 21 22 |
# File 'lib/dependabot/vcpkg/version.rb', line 17 def initialize(version) @version_string = T.let(version.to_s, String) parsed_version = parse_version(@version_string) super(T.cast(parsed_version[:base_version], String)) @port_version = T.let(parsed_version[:port_version], T.nilable(Integer)) end |
Instance Attribute Details
#port_version ⇒ Object (readonly)
Returns the value of attribute port_version.
25 26 27 |
# File 'lib/dependabot/vcpkg/version.rb', line 25 def port_version @port_version end |
Instance Method Details
#<=>(other) ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/dependabot/vcpkg/version.rb', line 33 def <=>(other) case other when Version # Compare with another vcpkg version base_comparison = super return base_comparison if base_comparison.nil? || !base_comparison.zero? # If base versions are equal, compare port versions (port_version || 0) <=> (other.port_version || 0) when String # Compare with a string by creating a version object from it begin self <=> self.class.new(other) rescue ArgumentError # If the string isn't a valid version, try comparing as base version only super(Gem::Version.new(other)) end when Gem::Version, Dependabot::Version # Compare with a regular Gem::Version by comparing just the base version super end end |
#to_s ⇒ Object
28 29 30 |
# File 'lib/dependabot/vcpkg/version.rb', line 28 def to_s port_version ? "#{super}##{port_version}" : super end |