Class: Pod::Command::OemConfig

Inherits:
Pod::Command show all
Defined in:
lib/cocoapods-hooks/command/oem_config.rb

Constant Summary collapse

VERSION =
File.read(gem_version_path).match(/VERSION = "(.*)"/)[1]

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(argv) ⇒ OemConfig

Returns a new instance of OemConfig.



18
19
20
21
22
# File 'lib/cocoapods-hooks/command/oem_config.rb', line 18

def initialize(argv)
  @tenantid = argv.option('tenantid')
  @version = argv.option('version')
  super
end

Class Method Details

.optionsObject



11
12
13
14
15
16
# File 'lib/cocoapods-hooks/command/oem_config.rb', line 11

def self.options
  [
    ['--tenantid=TENANTID', 'Specify the tenant ID'],
    ['--version=Version', 'Specify the sdk version for git clone']
  ].concat(super)
end

Instance Method Details

#runObject



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/cocoapods-hooks/command/oem_config.rb', line 30

def run
  UI.puts "Downloading OEM configuration for tenant #{@tenantid}"
  # 执行你的业务逻辑
  if @tenantid.nil? || @tenantid.empty?
      UI.puts "没有传入 tenantid, 直接退出程序"
      exit 1
  end
  # 执行你的业务逻辑
  if @version.nil? || @version.empty?
      UI.puts "没有传入指定版本,直接退出程序"
      exit 1
  end
  # 1. 根据 tenant_id 下载相关的配置文件
  result = system("pod git-clone --tenantid=#{@tenantid} --version=#{@version}")
  unless result
      puts "pod git-clone command execution failed. Exiting..."
      exit 1
  end
  # 2. 修改图片的主题色
  result = system("pod change-color")
  unless result
      puts "pod change-color command execution failed. Exiting..."
      exit 1
  end
  # 3. 修改工程配置, 进行签名
  result = system("pod fastlane-sign")
  unless result
      puts "pod fastlane-sign command execution failed. Exiting..."
      exit 1
  end
end

#validate!Object



24
25
26
27
28
# File 'lib/cocoapods-hooks/command/oem_config.rb', line 24

def validate!
  super
  help! 'A tenant ID is required.' unless @tenantid
  help! 'A sdk version is required.' unless @version
end