Class: Dependabot::Gradle::Requirement

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

Constant Summary collapse

PATTERN_RAW =
T.let("\\s*(#{quoted})?\\s*(#{Gradle::Version::VERSION_PATTERN})\\s*".freeze, String)
PATTERN =
/\A#{PATTERN_RAW}\z/

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(*requirements) ⇒ Requirement

Returns a new instance of Requirement.



42
43
44
45
46
47
48
# File 'lib/dependabot/gradle/requirement.rb', line 42

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

  super(requirements)
end

Class Method Details

.parse(obj) ⇒ Object



21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/dependabot/gradle/requirement.rb', line 21

def self.parse(obj)
  return ["=", Gradle::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] || "=", Gradle::Version.new(T.must(matches[2]))]
end

.requirements_array(requirement_string) ⇒ Object



35
36
37
38
39
# File 'lib/dependabot/gradle/requirement.rb', line 35

def self.requirements_array(requirement_string)
  split_java_requirement(requirement_string).map do |str|
    new(str)
  end
end

Instance Method Details

#satisfied_by?(version) ⇒ Boolean

Returns:

  • (Boolean)


51
52
53
54
# File 'lib/dependabot/gradle/requirement.rb', line 51

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