Pass deps collection to be expanded as a parameter
This commit is contained in:
parent
109e9dc58b
commit
677c78d77e
@ -75,8 +75,8 @@ class Dependency
|
|||||||
# the list.
|
# the list.
|
||||||
# The default filter, which is applied when a block is not given, omits
|
# The default filter, which is applied when a block is not given, omits
|
||||||
# optionals and recommendeds based on what the dependent has asked for.
|
# optionals and recommendeds based on what the dependent has asked for.
|
||||||
def expand(dependent, &block)
|
def expand(dependent, deps=dependent.deps, &block)
|
||||||
deps = dependent.deps.map do |dep|
|
expanded_deps = deps.map do |dep|
|
||||||
case action(dependent, dep, &block)
|
case action(dependent, dep, &block)
|
||||||
when :prune
|
when :prune
|
||||||
next []
|
next []
|
||||||
@ -89,7 +89,7 @@ class Dependency
|
|||||||
end
|
end
|
||||||
end.flatten
|
end.flatten
|
||||||
|
|
||||||
merge_repeats(deps)
|
merge_repeats(expanded_deps)
|
||||||
end
|
end
|
||||||
|
|
||||||
def action(dependent, dep, &block)
|
def action(dependent, dep, &block)
|
||||||
|
|||||||
@ -108,4 +108,9 @@ class DependencyExpansionTests < Test::Unit::TestCase
|
|||||||
|
|
||||||
assert_equal [@foo, @baz], deps
|
assert_equal [@foo, @baz], deps
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_deps_with_collection_argument
|
||||||
|
assert_equal [@foo, @bar, @baz, @qux], @f.deps
|
||||||
|
assert_equal [@bar, @baz], Dependency.expand(@f, [@bar, @baz])
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user