Method: Gem::Dependency#=~

Defined in:
lib/rubygems/dependency.rb

#=~(other) ⇒ Object Also known as: ===

Uses this dependency as a pattern to compare to other. This dependency will match if the name matches the other’s name, and other has only an equal version requirement that satisfies this dependency.



188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
# File 'lib/rubygems/dependency.rb', line 188

def =~(other)
  unless Gem::Dependency === other
    return unless other.respond_to?(:name) && other.respond_to?(:version)
    other = Gem::Dependency.new other.name, other.version
  end

  return false unless name === other.name

  reqs = other.requirement.requirements

  return false unless reqs.length == 1
  return false unless reqs.first.first == "="

  version = reqs.first.last

  requirement.satisfied_by? version
end