Class: Dependabot::Nix::VersionedName
- Inherits:
-
Object
- Object
- Dependabot::Nix::VersionedName
- Extended by:
- T::Sig
- Defined in:
- lib/dependabot/nix/versioned_name.rb
Overview
Parses a NixOS-style versioned name (e.g. "nixos-26.05", "nixpkgs-24.11-darwin") into prefix, YY.MM version, and suffix, and compares names within a family.
Direct Known Subclasses
Constant Summary collapse
- VERSIONED_NAME_PATTERN =
prefix + YY.MM version + optional suffix, e.g. "nixpkgs-26.05-darwin".
/\A(?<prefix>.+[.\-_])(?<version>\d{2}\.\d{2})(?<suffix>-[a-zA-Z0-9]+)?\z/
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
-
#initialize(name) ⇒ VersionedName
constructor
A new instance of VersionedName.
- #newer_than?(other) ⇒ Boolean
- #prefix ⇒ Object
- #same_family?(other) ⇒ Boolean
- #suffix ⇒ Object
- #version ⇒ Object
- #version_string ⇒ Object
- #versioned? ⇒ Boolean
Constructor Details
#initialize(name) ⇒ VersionedName
Returns a new instance of VersionedName.
18 19 20 21 |
# File 'lib/dependabot/nix/versioned_name.rb', line 18 def initialize(name) @name = name @match = T.let(VERSIONED_NAME_PATTERN.match(name), T.nilable(MatchData)) end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
24 25 26 |
# File 'lib/dependabot/nix/versioned_name.rb', line 24 def name @name end |
Instance Method Details
#newer_than?(other) ⇒ Boolean
63 64 65 66 67 68 69 |
# File 'lib/dependabot/nix/versioned_name.rb', line 63 def newer_than?(other) this_version = version other_version = other.version return false unless this_version && other_version (this_version <=> other_version) == 1 end |
#prefix ⇒ Object
32 33 34 |
# File 'lib/dependabot/nix/versioned_name.rb', line 32 def prefix @match&.[](:prefix) end |
#same_family?(other) ⇒ Boolean
57 58 59 60 |
# File 'lib/dependabot/nix/versioned_name.rb', line 57 def same_family?(other) versioned? && other.versioned? && prefix == other.prefix && suffix == other.suffix end |
#suffix ⇒ Object
37 38 39 |
# File 'lib/dependabot/nix/versioned_name.rb', line 37 def suffix @match&.[](:suffix) end |
#version ⇒ Object
48 49 50 51 52 53 |
# File 'lib/dependabot/nix/versioned_name.rb', line 48 def version version_str = version_string return unless version_str parse_version(version_str) end |
#version_string ⇒ Object
42 43 44 |
# File 'lib/dependabot/nix/versioned_name.rb', line 42 def version_string @match&.[](:version) end |
#versioned? ⇒ Boolean
27 28 29 |
# File 'lib/dependabot/nix/versioned_name.rb', line 27 def versioned? !@match.nil? end |