Class: Dependabot::Nuget::Requirement

Inherits:
Requirement
  • Object
show all
Extended by:
T::Sig
Defined in:
lib/dependabot/nuget/requirement.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(*requirements) ⇒ Requirement

Returns a new instance of Requirement.



40
41
42
43
44
45
46
# File 'lib/dependabot/nuget/requirement.rb', line 40

def initialize(*requirements)
  requirements = requirements.flatten.flat_map do |req_string|
    convert_dotnet_constraint_to_ruby_constraint(req_string)
  end

  super(requirements)
end

Class Method Details

.parse(obj) ⇒ Object



18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/dependabot/nuget/requirement.rb', line 18

def self.parse(obj)
  return ["=", Nuget::Version.new(obj.to_s)] if obj.is_a?(Gem::Version)

  unless (matches = PATTERN.match(obj.to_s))
    msg = "Illformed requirement [#{obj.inspect}]"
    raise BadRequirementError, msg
  end

  return DefaultRequirement if matches[1] == ">=" && matches[2] == "0"

  [matches[1] || "=", Nuget::Version.new(T.must(matches[2]))]
end

.requirements_array(requirement_string) ⇒ Object



35
36
37
# File 'lib/dependabot/nuget/requirement.rb', line 35

def self.requirements_array(requirement_string)
  [new(requirement_string)]
end

Instance Method Details

#satisfied_by?(version) ⇒ Boolean

Returns:

  • (Boolean)


49
50
51
52
# File 'lib/dependabot/nuget/requirement.rb', line 49

def satisfied_by?(version)
  version = Nuget::Version.new(version.to_s)
  super
end