def compact
      sort_by(&:length).each_with_object([]) do |c, result|
        result << c unless result.any? { |r| c.start_with?(r) }
      end.compact
    end
def compact
      sort_by(&:length).each_with_object([]) do |c, result|
        result << c unless result.any? { |r| c.start_with?(r) }
      end.compact
    end
When the records are something like:
   ./spec/foo ./spec/foo/bar_spec.rb
 this returns just ./spec/foo