Class: Dependabot::Bundler::Requirement

Inherits:
Gem::Requirement
  • Object
show all
Defined in:
lib/dependabot/bundler/requirement.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(*requirements) ⇒ Requirement

Patches Gem::Requirement to make it accept requirement strings like “~> 4.2.5, >= 4.2.5.1” without first needing to split them.


17
18
19
20
21
22
23
# File 'lib/dependabot/bundler/requirement.rb', line 17

def initialize(*requirements)
  requirements = requirements.flatten.flat_map do |req_string|
    req_string.split(",")
  end

  super(requirements)
end

Class Method Details

.requirements_array(requirement_string) ⇒ Object

For consistency with other langauges, we define a requirements array. Ruby doesn't have an `OR` separator for requirements, so it always contains a single element.


11
12
13
# File 'lib/dependabot/bundler/requirement.rb', line 11

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