Method: Pod::Source#search_by_name

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

#search_by_name(query, full_text_search = false) ⇒ Array<Set>

TODO:

Rename to #search

Note:

full text search requires to load the specification for each pod, hence is considerably slower.

Returns The list of the sets that contain the search term.

Parameters:

  • query (String)

    the search term. Can be a regular expression.

  • full_text_search (Boolean) (defaults to: false)

    whether the search should be limited to the name of the Pod or should include also the author, the summary, and the description.

Returns:

  • (Array<Set>)

    The list of the sets that contain the search term.

[View source]

302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
# File 'lib/cocoapods-core/source.rb', line 302

def search_by_name(query, full_text_search = false)
  regexp_query = /#{query}/i
  if full_text_search
    pod_sets.reject do |set|
      texts = []
      begin
        s = set.specification
        texts << s.name
        texts += s.authors.keys
        texts << s.summary
        texts << s.description
      rescue
        CoreUI.warn "Skipping `#{set.name}` because the podspec " \
          'contains errors.'
      end
      texts.grep(regexp_query).empty?
    end
  else
    names = pods.grep(regexp_query)
    names.map { |pod_name| set(pod_name) }
  end
end