Class: Pod::Downloader::Http

Inherits:
Object
  • Object
show all
Includes:
ArchThin_util, Config::Mixin
Defined in:
lib/cocoapods-archthin/downloader_arch.rb

Overview

Concreted Downloader class that provides support for specifications with arch

Constant Summary

Constants included from ArchThin_util

ArchThin_util::ARCH_FILE_PATH, ArchThin_util::JFROG_API, ArchThin_util::JFROG_HOST

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from ArchThin_util

arch_api_file_url, arch_file_name, arch_file_url, has_arch_in_jfrog

Instance Attribute Details

#urlObject

Returns the value of attribute url.


15
16
17
# File 'lib/cocoapods-archthin/downloader_arch.rb', line 15

def url
  @url
end

Instance Method Details

#debug_log(str) ⇒ Object

[View source]

71
72
73
74
75
# File 'lib/cocoapods-archthin/downloader_arch.rb', line 71

def debug_log(str)
  if config.verbose?
    puts str
  end
end

#download_file(full_filename) ⇒ Object

[View source]

47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# File 'lib/cocoapods-archthin/downloader_arch.rb', line 47

def download_file(full_filename)
	arch = ENV['arch'] ? ENV['arch'] : ENV['ARCH']
	arch = arch.to_s

  

	if arch.empty?
    	orig_download(full_filename)
  else
  	arch = arch.downcase
  	if arch != 'arm64' &&  arch != 'armv7' &&  arch != 'i386' &&  arch != 'x86_64' && arch != '64'
  		UI.puts "\narch=#{arch} 设置无效,目前只支持arch=arm64、arch=armv7、arch=x86_64、arch=i386、arch=64\n".yellow
  		orig_download(full_filename)
  	# elsif url.include?('jfrog.cloud.qiyi.domain') && !url.end_with?(".zip") && has_arch(arch)
  	elsif ArchThin_util::has_arch_in_jfrog(arch, url)
  		download_with_arch(full_filename,arch)
  	else
      UI.puts "【Arch-thin】没有找到对应 #{arch} 架构包".yellow
  		orig_download(full_filename)
		end

	end
end

#download_with_arch(full_filename, arch) ⇒ Object

[View source]

18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/cocoapods-archthin/downloader_arch.rb', line 18

def download_with_arch(full_filename,arch)
  UI.puts "【Arch-thin】下载 #{arch} 架构包"#.green
	debug_log("目标arch: #{arch}")
	debug_log("原始url: #{url}")

	arch_file_url = ArchThin_util::arch_file_url(arch, url)
	debug_log("arch file: #{arch_file_url}")
  #base_url = url.chomp('.git').chomp('/')
  #ref = options[:commit] || options[:tag] || options[:branch] || 'master'
  #download_url = "#{base_url}/archive/#{ref.to_s}.tar.gz"
 
  # parameters = ['-f', '-L', '-o', full_filename, arch_file_url, '--create-dirs', '--netrc-optional', '--retry', '2']
  # parameters << user_agent_argument if headers.nil? ||
  #     headers.none? { |header| header.casecmp(USER_AGENT_HEADER).zero? }

  # headers.each do |h|
  #   parameters << '-H'
  #   parameters << h
  # end unless headers.nil?
  # curl! parameters

  @url = arch_file_url
  orig_download(full_filename)


end

#orig_downloadObject

[View source]

45
# File 'lib/cocoapods-archthin/downloader_arch.rb', line 45

alias_method :orig_download, :download_file