Module: Pod::ExternalSources

Defined in:
lib/cocoapods/external_sources.rb,
lib/cocoapods/external_sources/path_source.rb,
lib/cocoapods/external_sources/podspec_source.rb,
lib/cocoapods/external_sources/downloader_source.rb,
lib/cocoapods/external_sources/abstract_external_source.rb

Overview

Provides support for initializing the correct concrete class of an external source.

Defined Under Namespace

Classes: AbstractExternalSource, DownloaderSource, PathSource, PodspecSource

Class Method Summary collapse

Class Method Details

.concrete_class_from_params(params) ⇒ Class

Get the class to represent the defined source type of a dependency

Parameters:

  • params (Array<Symbol>)

    the source params of the dependency

Returns:

  • (Class)


44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/cocoapods/external_sources.rb', line 44

def self.concrete_class_from_params(params)
  if params.key?(:podspec)
    PodspecSource
  elsif params.key?(:path)
    PathSource
  elsif params.key?(:local)
    UI.warn 'The `:local` option of the Podfile has been ' \
      'renamed to `:path` and it is deprecated.'
    PathSource
  elsif Downloader.strategy_from_options(params)
    DownloaderSource
  end
end

.from_dependency(dependency, podfile_path) ⇒ AbstractExternalSource

Instantiate a matching AbstractExternalSource for a given dependency.

Parameters:

  • dependency (Dependency)

    the dependency

  • podfile_path (String)

    @see AbstractExternalSource#podfile_path

Returns:

  • (AbstractExternalSource)

    an initialized instance of the concrete external source class associated with the option specified in the hash.



23
24
25
# File 'lib/cocoapods/external_sources.rb', line 23

def self.from_dependency(dependency, podfile_path)
  from_params(dependency.external_source, dependency, podfile_path)
end

.from_params(params, dependency, podfile_path) ⇒ Object



27
28
29
30
31
32
33
34
35
# File 'lib/cocoapods/external_sources.rb', line 27

def self.from_params(params, dependency, podfile_path)
  name = dependency.root_name
  if klass = concrete_class_from_params(params)
    klass.new(name, params, podfile_path)
  else
    msg = "Unknown external source parameters for `#{name}`: `#{params}`"
    raise Informative, msg
  end
end