Module: Flappy::IOSEnvConfig

Included in:
Util::ClassMethods
Defined in:
lib/flappy/util/iOS_env_config.rb

Instance Method Summary collapse

Instance Method Details

#check_and_find_plist_fileObject



35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/flappy/util/iOS_env_config.rb', line 35

def check_and_find_plist_file
  plist_path = ''

  Dir.glob("#{@work_dir}/**/SCCURLConfigFormat.plist").each do |name|
    unless File.directory?(name)
      plist_path = name
    end
  end

  if plist_path.blank?
    log_iOS('No Plist Found')
  else
    log_iOS("Found PlistPath: #{plist_path}")
  end

  plist_path
end

#writeEnvToPlist(args, options) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/flappy/util/iOS_env_config.rb', line 6

def writeEnvToPlist(args, options)
  plist_path = check_and_find_plist_file

  unless plist_path.blank?
    https = options[:https]
    env = options[:env]
    env_port = options[:port]
    pay_env = options[:'pay-env']
    load_env_from_plist = 'N'

    if !https.blank? || !env.blank? || !env_port.blank? || !pay_env.blank?
      load_env_from_plist = 'Y'
    end


    log_iOS('更新配置文件前')
    log_iOS(`/usr/libexec/PlistBuddy -c 'Print' \"#{plist_path}\"`)

    system("/usr/libexec/PlistBuddy -c 'Set :LoadConfigFromPlist #{load_env_from_plist}' \"#{plist_path}\"") unless load_env_from_plist.blank?
    system("/usr/libexec/PlistBuddy -c 'Set :HTTPS #{https}' \"#{plist_path}\"") unless https.blank?
    system("/usr/libexec/PlistBuddy -c 'Set :SCC_ENV:env #{env}' \"#{plist_path}\"") unless env.blank?
    system("/usr/libexec/PlistBuddy -c 'Set :SCC_ENV:port #{env_port}' \"#{plist_path}\"") unless env_port.blank?
    system("/usr/libexec/PlistBuddy -c 'Set :SCC_PAY_ENV:payEnv #{pay_env}' \"#{plist_path}\"") unless pay_env.blank?

    log_iOS('更新配置文件后')
    log_iOS(`/usr/libexec/PlistBuddy -c \"Print\" \"#{plist_path}\"`)
  end
end