Class: Pod::DeployDownloader

Inherits:
Object
  • Object
show all
Defined in:
lib/cocoapods-deploy/deploy_downloader.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(dependency) ⇒ DeployDownloader

Returns a new instance of DeployDownloader.



6
7
8
# File 'lib/cocoapods-deploy/deploy_downloader.rb', line 6

def initialize(dependency)
  @dependency = dependency
end

Instance Attribute Details

#dependencyObject

Returns the value of attribute dependency.



4
5
6
# File 'lib/cocoapods-deploy/deploy_downloader.rb', line 4

def dependency
  @dependency
end

Instance Method Details

#dependencies_for_sources(config) ⇒ Object



42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/cocoapods-deploy/deploy_downloader.rb', line 42

def dependencies_for_sources(config)
  podfile_sources(config).map do |source|
    filename = File.basename(source, ".*")
    raw_url = File.join( File.dirname(source), filename )
    root_urls = [
      "#{raw_url}/raw/master/Specs",
      "#{raw_url}/raw/master"
    ]

    root_urls.map do |url|
      source = @dependency.external_source[:podspec].gsub('{root-url}', url)
      dependencies_for_url(source)
    end
  end.flatten
end

#dependencies_for_url(url) ⇒ Object



58
59
60
61
62
63
# File 'lib/cocoapods-deploy/deploy_downloader.rb', line 58

def dependencies_for_url(url)
  [
    Dependency.new(@dependency.name, {:podspec => "#{url}.podspec"}),
    Dependency.new(@dependency.name, {:podspec => "#{url}.podspec.json"})
  ]
end

#download(config) ⇒ Object



10
11
12
13
14
15
16
# File 'lib/cocoapods-deploy/deploy_downloader.rb', line 10

def download(config)
  if @dependency.external_source.key?(:podspec)
    download_podspec(config)
  else
    download_source(config)
  end
end

#download_podspec(config) ⇒ Object

Raises:

  • (Informative)


23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/cocoapods-deploy/deploy_downloader.rb', line 23

def download_podspec(config)
  dependencies_for_sources(config).each do |dep|
    source = ExternalSources.from_dependency(dep, config.podfile.defined_in_file)

    begin
      return source.fetch(config.sandbox)
    rescue Exception
      puts "Not Found"
    end
  end

  raise Informative, "Failed to deploy podspec for `#{@dependency.name}`."
end

#download_source(config) ⇒ Object



18
19
20
21
# File 'lib/cocoapods-deploy/deploy_downloader.rb', line 18

def download_source(config)
  source = ExternalSources.from_dependency(dependency, config.podfile.defined_in_file)
  source.fetch(config.sandbox)
end

#podfile_sources(config) ⇒ Object



37
38
39
40
# File 'lib/cocoapods-deploy/deploy_downloader.rb', line 37

def podfile_sources(config)
  return ["https://github.com/CocoaPods/Specs.git"] if config.podfile.sources.empty?
  return config.podfile.sources
end