Class: Pod::ExternalSources::PodspecSource

Inherits:
AbstractExternalSource show all
Defined in:
lib/cocoapods/external_sources/podspec_source.rb

Overview

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

Instance Attribute Summary

Attributes inherited from AbstractExternalSource

#can_cache, #name, #params, #podfile_path

Helpers collapse

Instance Method Summary collapse

Methods inherited from AbstractExternalSource

#==, #download_request, #initialize, #pre_download, #store_podspec, #validate_podspec, #validator_for_podspec

Constructor Details

This class inherits a constructor from Pod::ExternalSources::AbstractExternalSource

Instance Method Details

#descriptionObject


30
31
32
# File 'lib/cocoapods/external_sources/podspec_source.rb', line 30

def description
  "from `#{params[:podspec]}`"
end

#fetch(sandbox) ⇒ Object


9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# 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
        open(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

#podspec_uriString (private)

Note:

If the declared path is expanded only if the represents a path relative to the file system.

Returns The uri of the podspec appending the name of the file and expanding it if necessary.

Returns:

  • (String)

    The uri of the podspec appending the name of the file and expanding it if necessary.


44
45
46
47
48
49
50
51
# 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