Class: Pod::Command::Gd

Inherits:
Pod::Command show all
Defined in:
lib/pod/command/gd.rb,
lib/cocoapods-gd/pod_utils.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(argv) ⇒ Gd



21
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
50
51
52
53
54
55
56
57
58
59
60
# File 'lib/pod/command/gd.rb', line 21

def initialize(argv)
  @gd_type = :static_framework
  @name = argv.shift_argument
  @source = argv.shift_argument

  @config = argv.option('configuration', 'Release')

  @source_dir = Dir.pwd
  @is_spec_from_path = false
  @spec = spec_with_path(@name)
  @is_spec_from_path = true if @spec
  @spec ||= spec_with_name(@name)
#       source源
  @spec_sources = argv.option('spec-sources', 'https://gitlab.gaodun.com/iOSLibs/CocoaPods.git').split(',')
  # 'https://github.com/CocoaPods/Specs.git'
  @spec_sources.push('https://gitlab.gaodun.com/iOSLibs/Specs.git')

#       是否上传
  @upload = argv.flag?('upload')

#       上传二进制源仓库名称
  @upload_spec_name = argv.option('upload-spec-name')

#       上传二进制源仓库地址
  @upload_git_sources = argv.option('upload-git-sources')

#       二进制源本地仓库地址
  @upload_local_path = argv.option('upload-local-path')

  if @upload_spec_name.nil?
    @upload_spec_name = "lizuba-frameworks-specs"
  end
  if @upload_git_sources.nil?
    @upload_git_sources = "https://gitlab.gaodun.com/iOSLibs/Frameworks/raw/master"
  end
  if @upload_local_path.nil?
    @upload_local_path = "/Users/lizuba/Desktop/Framework/Frameworks"
  end
  super
end

Class Method Details

.optionsObject



11
12
13
14
15
16
17
18
19
# File 'lib/pod/command/gd.rb', line 11

def self.options
  [
    ['--spec-sources=private,https://github.com/CocoaPods/Specs.git', '指定source源'],
    ['--upload', '是否上传,默认不上传'],  
    ['--upload-spec-name', '上传仓库必要参数,二进制源对应的spec版本仓库名称'],
    ['--upload-git-sources', '上传仓库必要参数,二进制源对应的git源码仓库名称'],
    ['--upload-local-path', '上传仓库必要参数,git源码仓库映射的本地路径'],
  ]
end

Instance Method Details

#runObject



66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
# File 'lib/pod/command/gd.rb', line 66

def run
  if @name == "install"
    # pod install走这里
    Pod::InstallFramework.new.install()
    return
  end
  if @spec.nil?
    help! "Unable to find a podspec with path or name `#{@name}`."
    return
  end
  target_dir, work_dir = create_working_directory
  return if target_dir.nil?
  build_gd

  build_path="#{Dir.pwd}/build"
  if File.exist?("#{build_path}")
    FileUtils.rm_rf('build/')
  end
  podspec_path="#{Dir.pwd}/replaced.podspec"
  if File.exist?("#{podspec_path}")
    FileUtils.rm_rf("#{podspec_path}")
  end
  json_path="#{Dir.pwd}/replaced.podspec.json"
  if File.exist?("#{json_path}")
    FileUtils.rm_rf("#{json_path}")
  end
  `mv "#{work_dir}" "#{target_dir}"`
  Dir.chdir(@source_dir)

  if @upload == true
    uploader = GDUploader.new(@spec, @upload_spec_name, @upload_local_path, @spec_sources)
  end
end

#validate!Object



62
63
64
# File 'lib/pod/command/gd.rb', line 62

def validate!
  super
end