Method: RSpec::Core::Formatters::Helpers.organize_ids

Defined in:
lib/rspec/core/formatters/helpers.rb

.organize_ids(ids) ⇒ void

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Given a list of example ids, organizes them into a compact, ordered list.

[View source]

102
103
104
105
106
107
108
109
110
111
112
113
114
# File 'lib/rspec/core/formatters/helpers.rb', line 102

def self.organize_ids(ids)
  grouped = ids.inject(Hash.new { |h, k| h[k] = [] }) do |hash, id|
    file, id = Example.parse_id(id)
    hash[file] << id
    hash
  end

  grouped.sort_by(&:first).map do |file, grouped_ids|
    grouped_ids = grouped_ids.sort_by { |id| id.split(':').map(&:to_i) }
    id = Metadata.id_from(:rerun_file_path => file, :scoped_id => grouped_ids.join(','))
    ShellEscape.conditionally_quote(id)
  end
end