Class: Pod::Source::Manager

Inherits:
Object
  • Object
show all
Defined in:
lib/cocoapods/sources_manager.rb

Updating Sources collapse

Instance Method Summary collapse

Instance Method Details

#find_or_create_source_with_url(url) ⇒ Source

Returns the source whose Source#url is equal to ‘url`, adding the repo in a manner similarly to `pod repo add` if it is not found.

Parameters:

  • url (String)

    The URL of the source.

Returns:

  • (Source)

    The source whose Source#url is equal to ‘url`,

Raises:

  • If no source with the given ‘url` could be created,



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/cocoapods/sources_manager.rb', line 17

def find_or_create_source_with_url(url)
  unless source = source_with_url(url)
    name = name_for_url(url)
    # Hack to ensure that `repo add` output is shown.
    previous_title_level = UI.title_level
    UI.title_level = 0
    begin
      if name =~ /^master(-\d+)?$/
        Command::Setup.parse([]).run
      else
        Command::Repo::Add.parse([name, url]).run
      end
    rescue Informative => e
      message = "Unable to add a source with url `#{url}` " \
        "named `#{name}`.\n"
      message << "(#{e})\n" if Config.instance.verbose?
      message << 'You can try adding it manually in ' \
        "`#{Config.instance.repos_dir}` or via `pod repo add`."
      raise Informative, message
    ensure
      UI.title_level = previous_title_level
    end
    source = source_with_url(url)
  end

  raise "Unable to create a source with URL #{url}" unless source

  source
end

#search_index_pathPathname

Returns The path where the search index should be stored.

Returns:

  • (Pathname)

    The path where the search index should be stored.



63
64
65
# File 'lib/cocoapods/sources_manager.rb', line 63

def search_index_path
  @search_index_path ||= Config.instance.search_index_file
end

#source_with_name_or_url(name_or_url) ⇒ Source

Returns the source whose Source#name or Source#url is equal to the given ‘name_or_url`.

Parameters:

  • name_or_url (String)

    The name or the URL of the source.

Returns:

  • (Source)

    The source whose Source#name or Source#url is equal to the given ‘name_or_url`.



56
57
58
59
# File 'lib/cocoapods/sources_manager.rb', line 56

def source_with_name_or_url(name_or_url)
  all.find { |s| s.name == name_or_url } ||
    find_or_create_source_with_url(name_or_url)
end

#update(source_name = nil, show_output = false) ⇒ void

This method returns an undefined value.

Updates the local clone of the spec-repo with the given name or of all the git repos if the name is omitted.

Parameters:

  • source_name (String) (defaults to: nil)
  • show_output (Bool) (defaults to: false)


78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
# File 'lib/cocoapods/sources_manager.rb', line 78

def update(source_name = nil, show_output = false)
  if source_name
    sources = [git_source_named(source_name)]
  else
    sources =  git_sources
  end

  changed_spec_paths = {}
  sources.each do |source|
    UI.section "Updating spec repo `#{source.name}`" do
      changed_source_paths = source.update(show_output)
      changed_spec_paths[source] = changed_source_paths if changed_source_paths.count > 0
      source.verify_compatibility!
    end
  end
  # Perform search index update operation in background.
  update_search_index_if_needed_in_background(changed_spec_paths)
end