Maintenance Ruby 3.3 gets fixes, but no new features. Switch to Ruby 4.0 →
instance method
Gem::Specification#traverse
traverse(trail = [], visited = {}, &block)
lib/rubygems/specification.rb
View on GitHub ↗
# File tmp/rubies/ruby-3.3.0/lib/rubygems/specification.rb, line 2614
def traverse(trail = [], visited = {}, &block)
trail.push(self)
begin
runtime_dependencies.each do |dep|
dep.matching_specs(true).each do |dep_spec|
next if visited.key?(dep_spec)
visited[dep_spec] = true
trail.push(dep_spec)
begin
result = block[self, dep, dep_spec, trail]
ensure
trail.pop
end
next if result == :next
spec_name = dep_spec.name
dep_spec.traverse(trail, visited, &block) unless
trail.any? {|s| s.name == spec_name }
end
end
ensure
trail.pop
end
end
Recursively walk dependencies of this spec, executing the block for each hop.
See also
#to_spec
#validate
#to_ruby_for_cache
#validate_dependencies
also in
4.1 · 4.0 · 3.4 · 3.2 · 3.1 · 3.0