Class: Dependabot::Version
- Inherits:
-
Gem::Version
- Object
- Gem::Version
- Dependabot::Version
- Extended by:
- T::Helpers, T::Sig
- Defined in:
- lib/dependabot/version.rb
Constant Summary collapse
- VersionParameter =
T.type_alias { T.nilable(T.any(String, Integer, Gem::Version)) }
Class Method Summary collapse
Instance Method Summary collapse
- #ignored_major_versions ⇒ Object
- #ignored_minor_versions ⇒ Object
- #ignored_patch_versions ⇒ Object
-
#initialize(version) ⇒ Version
constructor
A new instance of Version.
- #lowest_prerelease_suffix ⇒ Object
- #to_semver ⇒ Object
Constructor Details
#initialize(version) ⇒ Version
Returns a new instance of Version.
16 17 18 19 20 |
# File 'lib/dependabot/version.rb', line 16 def initialize(version) @original_version = T.let(version.to_s, String) super end |
Class Method Details
.correct?(version) ⇒ Boolean
29 30 31 32 33 |
# File 'lib/dependabot/version.rb', line 29 def self.correct?(version) return false if version.nil? version.to_s.match?(ANCHORED_VERSION_PATTERN) end |
.new(version) ⇒ Object
23 24 25 |
# File 'lib/dependabot/version.rb', line 23 def self.new(version) T.cast(super, Dependabot::Version) end |
Instance Method Details
#ignored_major_versions ⇒ Object
64 65 66 67 68 69 70 |
# File 'lib/dependabot/version.rb', line 64 def ignored_major_versions version_parts = to_semver.split(".") lower_parts = [version_parts[0].to_i + 1] + [lowest_prerelease_suffix] lower_bound = ">= #{lower_parts.join('.')}" [lower_bound] end |
#ignored_minor_versions ⇒ Object
52 53 54 55 56 57 58 59 60 61 |
# File 'lib/dependabot/version.rb', line 52 def ignored_minor_versions parts = to_semver.split(".") version_parts = parts.fill("0", parts.length...2) lower_parts = version_parts.first(1) + [version_parts[1].to_i + 1] + [lowest_prerelease_suffix] upper_parts = version_parts.first(0) + [version_parts[0].to_i + 1] lower_bound = ">= #{lower_parts.join('.')}" upper_bound = "< #{upper_parts.join('.')}" ["#{lower_bound}, #{upper_bound}"] end |
#ignored_patch_versions ⇒ Object
41 42 43 44 45 46 47 48 49 |
# File 'lib/dependabot/version.rb', line 41 def ignored_patch_versions parts = to_semver.split(".") version_parts = parts.fill("0", parts.length...2) upper_parts = version_parts.first(1) + [version_parts[1].to_i + 1] lower_bound = "> #{to_semver}" upper_bound = "< #{upper_parts.join('.')}" ["#{lower_bound}, #{upper_bound}"] end |
#lowest_prerelease_suffix ⇒ Object
73 74 75 |
# File 'lib/dependabot/version.rb', line 73 def lowest_prerelease_suffix "a" end |
#to_semver ⇒ Object
36 37 38 |
# File 'lib/dependabot/version.rb', line 36 def to_semver @original_version end |