Class: CBin::Config

Inherits:
Object
  • Object
show all
Defined in:
lib/cocoapods-fy-bin/config/config.rb,
lib/cocoapods-fy-bin/config/config_asker.rb,
lib/cocoapods-fy-bin/config/config_builder.rb

Defined Under Namespace

Classes: Asker, Builder

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method, *args, &block) ⇒ Object (private)



123
124
125
126
127
128
129
130
131
# File 'lib/cocoapods-fy-bin/config/config.rb', line 123

def method_missing(method, *args, &block)
  if config.respond_to?(method)
    config.send(method, *args)
  elsif template_hash.keys.include?(method.to_s)
    raise Pod::Informative, "#{method} 字段必须在配置文件 #{config_file} 中设置, 请执行 init 命令配置或手动修改配置文件".red
  else
    super
  end
end

Instance Method Details

#binary_upload_urlObject

上传的url



60
61
62
# File 'lib/cocoapods-fy-bin/config/config.rb', line 60

def binary_upload_url
  binary_download_url
end

#config_debug_iphoneos_fileObject

包含arm64 armv7架构,xcodebuild 是Debug模式



69
70
71
# File 'lib/cocoapods-fy-bin/config/config.rb', line 69

def config_debug_iphoneos_file
  "bin_debug.yml"
end

#config_fileObject



9
10
11
# File 'lib/cocoapods-fy-bin/config/config.rb', line 9

def config_file
  config_file_with_configuration_env(configuration_env)
end

#config_file_with_configuration_env(configuration_env) ⇒ Object



25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/cocoapods-fy-bin/config/config.rb', line 25

def config_file_with_configuration_env(configuration_env)
  file = config_debug_iphoneos_file
  if configuration_env == "release"
    file = config_release_iphoneos_file
    puts "\n======  #{configuration_env} 环境 ========"
  elsif configuration_env == "debug"
    file = config_debug_iphoneos_file
    puts "\n======  #{configuration_env} 环境 ========"
  else
    raise "\n=====  #{configuration_env} 参数有误,请检查%w[debug release]===="
  end

  File.expand_path("#{Pod::Config.instance.home_dir}/#{file}")
end

#config_release_iphoneos_fileObject

包含arm64 armv7架构,xcodebuild 是Release模式



73
74
75
# File 'lib/cocoapods-fy-bin/config/config.rb', line 73

def config_release_iphoneos_file
  "bin_release.yml"
end

#configuration_envObject



40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'lib/cocoapods-fy-bin/config/config.rb', line 40

def configuration_env
  #如果是debug 再去 podfile的配置文件中获取,确保是正确的, pod update时会用到
  # if @configuration_env == "release" || @configuration_env == nil
  #   if Pod::Config.instance.podfile
  #     configuration_env ||= Pod::Config.instance.podfile.configuration_env
  #   end
  #   configuration_env ||= "release"
  #   @configuration_env = configuration_env
  # end
  if @configuration_env == nil
      if Pod::Config.instance.podfile
        configuration_env ||= Pod::Config.instance.podfile.configuration_env
      end
      configuration_env ||= "release"
      @configuration_env = configuration_env
  end
  @configuration_env
end

#default_configObject



83
84
85
# File 'lib/cocoapods-fy-bin/config/config.rb', line 83

def default_config
  @default_config ||= Hash[template_hash.map { |k, v| [k, v[:default]] }]
end

#set_configuration_env(env) ⇒ Object



64
65
66
# File 'lib/cocoapods-fy-bin/config/config.rb', line 64

def set_configuration_env(env)
  @configuration_env = env
end

#sync_config(config) ⇒ Object



77
78
79
80
81
# File 'lib/cocoapods-fy-bin/config/config.rb', line 77

def sync_config(config)
  File.open(config_file_with_configuration_env(config['configuration_env']), 'w+') do |f|
    f.write(config.to_yaml)
  end
end

#template_hashObject



13
14
15
16
17
18
19
20
21
22
23
# File 'lib/cocoapods-fy-bin/config/config.rb', line 13

def template_hash
  {
      'configuration_env' => { description: '编译环境', default: 'release', selection: %w[debug release] },
      'code_repo_url' => { description: '源码私有源 Git 地址', default: 'https://gitlab.fuyoukache.com/app/iosThird/FYSpecs.git' },
      'binary_repo_url' => { description: '二进制私有源 Git 地址', default: 'https://gitlab.fuyoukache.com/app/iosThird/FYBinarySpecs.git' },
      'binary_download_url' => { description: '二进制下载主机地址,内部会依次传入组件名称、版本、打包模式', default: 'https://mobilepods.fuyoukache.com' },
      # 'binary_type' => { description: '二进制打包类型', default: 'framework', selection: %w[framework library] },
      'download_file_type' => { description: '下载二进制文件类型', default: 'zip', selection: %w[zip tgz tar tbz txz dmg] },
      'clean_white_list' =>  { description: 'framework清空白名单, 二进制切换到源码会删除framework,避免这些库被删除重新下载', default: 'Bugly,LookinServer'}
  }
end