Method: Pod::Source#search

Defined in:
lib/cocoapods-core/source.rb

#search(query) ⇒ Set

TODO:

Rename to #load_set

Note:

This method is optimized for fast lookups by name, i.e. it does not require iterating through #pod_sets

Returns a set for a given dependency. The set is identified by the name of the dependency and takes into account subspecs.

Returns:

  • (Set)

    a set for a given dependency. The set is identified by the name of the dependency and takes into account subspecs.

[View source]

263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
# File 'lib/cocoapods-core/source.rb', line 263

def search(query)
  unless specs_dir
    raise Informative, "Unable to find a source named: `#{name}`"
  end
  if query.is_a?(Dependency)
    query = query.root_name
  end

  if (versions = @versions_by_name[query]) && !versions.empty?
    set = set(query)
    return set if set.specification_name == query
  end

  found = []
  Pathname.glob(pod_path(query)) do |path|
    next unless Dir.foreach(path).any? { |child| child != '.' && child != '..' }
    found << path.basename.to_s
  end

  if [query] == found
    set = set(query)
    set if set.specification_name == query
  end
end