# typed: strict # frozen_string_literal: true module Minitest module Distributed module Filters class IncludeFilter extend T::Sig include FilterInterface sig { returns(T.any(String, Regexp)) } attr_reader :filter sig { params(filter: T.any(String, Regexp)).void } def initialize(filter) @filter = filter if filter.is_a?(String) && (match_info = filter.match(%r%/(.*)/%)) @filter = Regexp.new(T.must(match_info[1])) end end sig { override.params(enqueued_runnable: EnqueuedRunnable).returns(T::Array[EnqueuedRunnable]) } def call(enqueued_runnable) # rubocop:disable Style/CaseEquality if filter === enqueued_runnable.method_name || filter === enqueued_runnable.identifier [enqueued_runnable] else [] end # rubocop:enable Style/CaseEquality end end end end end