Class: Pod::Command::Bin::Source::Add

Inherits:
Pod::Command::Bin::Source show all
Defined in:
lib/cocoapods-meitu-bin/command/bin/source/add.rb

Instance Method Summary collapse

Methods inherited from Pod::Command::Bin::Source

#source_dir, #target_path

Methods included from CBin::SpecFilesHelper

#binary_spec, #binary_spec_files, #binary_template_spec, #binary_template_spec_file, #binary_template_spec_files, #clear_binary_spec_file_if_needed, #code_spec, #code_spec_files, #create_binary_spec_file, #find_spec_file, #spec_files

Methods included from CBin::SourcesHelper

#binary_source, #code_source_list, #sources_manager, #sources_option, #valid_sources

Constructor Details

#initialize(argv) ⇒ Add

Returns a new instance of Add.



17
18
19
20
# File 'lib/cocoapods-meitu-bin/command/bin/source/add.rb', line 17

def initialize(argv)
  @names = argv.shift_argument
  super
end

Instance Method Details

#runObject

Raises:

  • (Informative)


22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/cocoapods-meitu-bin/command/bin/source/add.rb', line 22

def run
  raise Informative, "请输入要添加的Pod库名,多个库中间用逗号隔开" if @names.nil?
  # 依赖分析
  @results = analyse
  # 遍历下载
  @names.split(',').each do |name|
    # 查找二进制spec
    bin_spec = find_specification(name)
    if bin_spec.nil?
      UI.puts "未查找到`#{name}`的二进制spec".red
      next
    end
    # 只有版本号最后一位带`bin`的才有源码
    bin_version = bin_spec.version.to_s
    unless has_source?(bin_version)
      UI.puts "`#{name} (#{bin_version})`已经是源码或无法查看源码".red
      next
    end
    # 查找源码spec
    source_spec = find_source_specification(name, bin_version)
    if source_spec.nil?
      UI.puts "未查找到`#{name}`的源码spec".red
      next
    end
    # 下载源码
    download_source(source_spec)
  end
end