class Pod::ExternalSources::PodspecSource

Provides support for fetching a specification file from an URL. Can be http, file, etc.

Public Instance Methods

description() click to toggle source

@see AbstractExternalSource#description

# File lib/cocoapods/external_sources/podspec_source.rb, line 30
def description
  "from `#{params[:podspec]}`"
end
fetch(sandbox) click to toggle source

@see AbstractExternalSource#fetch

# File lib/cocoapods/external_sources/podspec_source.rb, line 9
def fetch(sandbox)
  title = "Fetching podspec for `#{name}` #{description}"
  UI.titled_section(title,  :verbose_prefix => '-> ') do
    podspec_path = Pathname(podspec_uri)
    is_json = podspec_path.extname == '.json'
    if podspec_path.exist?
      store_podspec(sandbox, podspec_path, is_json)
    else
      require 'cocoapods/open-uri'
      begin
        OpenURI.open_uri(podspec_uri) { |io| store_podspec(sandbox, io.read, is_json) }
      rescue OpenURI::HTTPError => e
        status = e.io.status.join(' ')
        raise Informative, "Failed to fetch podspec for `#{name}` at `#{podspec_uri}`.\n Error: #{status}"
      end
    end
  end
end

Private Instance Methods

podspec_uri() click to toggle source

@return [String] The uri of the podspec appending the name of the file

and expanding it if necessary.

@note If the declared path is expanded only if the represents a path

relative to the file system.
# File lib/cocoapods/external_sources/podspec_source.rb, line 44
def podspec_uri
  declared_path = params[:podspec].to_s
  if declared_path =~ %r{^.+://}
    declared_path
  else
    normalized_podspec_path(declared_path)
  end
end