Module: Pod::ExternalSources

Defined in:
lib/cocoapods/external_sources.rb

Overview

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

Defined Under Namespace

Classes: AbstractExternalSource, GitSource, MercurialSource, PathSource, PodspecSource, SvnSource

Class Method Summary collapse

Class Method Details

.from_dependency(dependency, podfile_path) ⇒ AbstractExternalSource

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

Returns:

  • (AbstractExternalSource)

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



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/cocoapods/external_sources.rb', line 12

def self.from_dependency(dependency, podfile_path)
  name   = dependency.root_name
  params = dependency.external_source

  klass  =  if params.key?(:git)          then GitSource
            elsif params.key?(:svn)       then SvnSource
            elsif params.key?(:hg)        then MercurialSource
            elsif params.key?(:podspec)   then PodspecSource
            elsif params.key?(:path)      then PathSource
            end

  if params.key?(:local)
    klass = PathSource
    UI.warn "The `:local` option of the Podfile has been renamed to `:path` and is deprecated." \
  end

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