Class: Dependabot::Maven::Requirement

Inherits:
Shared::SharedRequirement show all
Extended by:
T::Sig
Defined in:
lib/dependabot/maven/requirement.rb

Constant Summary collapse

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

Like PATTERN, but the leading operator is required

T.let(/\A\s*(#{quoted})\s*(#{Maven::Version::VERSION_PATTERN})\s*\z/, Regexp)

Constants inherited from Shared::SharedRequirement

Shared::SharedRequirement::OR_SYNTAX

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Shared::SharedRequirement

#initialize

Constructor Details

This class inherits a constructor from Dependabot::Maven::Shared::SharedRequirement

Class Method Details

.parse(obj) ⇒ Object



33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/dependabot/maven/requirement.rb', line 33

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

.patternObject



23
24
25
# File 'lib/dependabot/maven/requirement.rb', line 23

def self.pattern
  PATTERN
end

.requirements_array(requirement_string) ⇒ Object



47
48
49
50
51
# File 'lib/dependabot/maven/requirement.rb', line 47

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

.ruby_style_patternObject



28
29
30
# File 'lib/dependabot/maven/requirement.rb', line 28

def self.ruby_style_pattern
  RUBY_STYLE_PATTERN
end

Instance Method Details

#satisfied_by?(version) ⇒ Boolean

Returns:

  • (Boolean)


54
55
56
57
# File 'lib/dependabot/maven/requirement.rb', line 54

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