Commit fc06882c authored by Micaël Bergeron's avatar Micaël Bergeron

remove BisectEnumerable

parent d1c3d4b5
......@@ -105,7 +105,7 @@ module Gitlab
module Report
def report(results)
success, failures = Gitlab::Utils::BisectEnumerable.bisect(results, &:success?)
success, failures = results.partition(&:success?)
Rails.logger.info header(success, failures)
Rails.logger.warn failures(failures)
......
module Gitlab
module Utils
include BisectEnumerable
extend self
# Run system command without outputting to stdout.
......
module Gitlab
module Utils
module BisectEnumerable
extend self
# Bisect an enumerable by using &block as pivot.
# Return two arrays, depending on the result of the pivot.
# [e] -> [[e]: pivot(e) == true, [e]: pivot(e) == false]
#
# Example: odd, even = bisect((1..10), &:odd?)
def bisect(enumerable, &block)
return [[], []] unless enumerable.any?
bisect = enumerable.group_by(&block)
[bisect.fetch(true, []), bisect.fetch(false, [])]
end
end
end
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment