class CBin::Config
Public Instance Methods
bin_upload_url()
click to toggle source
上传的url
# File lib/cocoapods-tdf-bin/config/config.rb, line 54 def bin_upload_url cut_string = "/%s/%s/zip" binary_upload_url[0,binary_upload_url.length - cut_string.length] end
config_debug_iphoneos_file()
click to toggle source
包含arm64 armv7架构,xcodebuild 是Debug模式
# File lib/cocoapods-tdf-bin/config/config.rb, line 64 def config_debug_iphoneos_file "bin_debug_iphoneos.yml" end
config_dev_file()
click to toggle source
包含x86 arm64 armv7架构,xcodebuild 是Release模式
# File lib/cocoapods-tdf-bin/config/config.rb, line 72 def config_dev_file "bin_dev.yml" end
config_file()
click to toggle source
# File lib/cocoapods-tdf-bin/config/config.rb, line 8 def config_file config_file_with_configuration_env(configuration_env) end
config_file_with_configuration_env(configuration_env)
click to toggle source
# File lib/cocoapods-tdf-bin/config/config.rb, line 24 def config_file_with_configuration_env(configuration_env) file = config_dev_file if configuration_env == "release_iphoneos" file = config_release_iphoneos_file puts "\n====== #{configuration_env} 环境 ========" elsif configuration_env == "debug_iphoneos" file = config_debug_iphoneos_file puts "\n====== #{configuration_env} 环境 ========" elsif configuration_env == "dev" puts "\n====== #{configuration_env} 环境 ========" else raise "\n===== #{configuration_env} 参数有误,请检查%w[dev debug_iphoneos release_iphoneos]====" end File.expand_path("#{Pod::Config.instance.home_dir}/#{file}") end
config_release_iphoneos_file()
click to toggle source
包含arm64 armv7架构,xcodebuild 是Release模式
# File lib/cocoapods-tdf-bin/config/config.rb, line 68 def config_release_iphoneos_file "bin_release_iphoneos.yml" end
configuration_env()
click to toggle source
# File lib/cocoapods-tdf-bin/config/config.rb, line 41 def configuration_env #如果是dev 再去 podfile的配置文件中获取,确保是正确的, pod update时会用到 if @configuration_env == "dev" || @configuration_env == nil if Pod::Config.instance.podfile configuration_env ||= Pod::Config.instance.podfile.configuration_env end configuration_env ||= "dev" @configuration_env = configuration_env end @configuration_env end
default_config()
click to toggle source
# File lib/cocoapods-tdf-bin/config/config.rb, line 82 def default_config @default_config ||= Hash[template_hash.map { |k, v| [k, v[:default]] }] end
set_configuration_env(env)
click to toggle source
# File lib/cocoapods-tdf-bin/config/config.rb, line 59 def set_configuration_env(env) @configuration_env = env end
sync_config(config)
click to toggle source
# File lib/cocoapods-tdf-bin/config/config.rb, line 76 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_hash()
click to toggle source
# File lib/cocoapods-tdf-bin/config/config.rb, line 12 def template_hash { 'configuration_env' => { description: '编译环境', default: 'dev', selection: %w[dev debug_iphoneos release_iphoneos] }, 'code_repo_url' => { description: '源码私有源 Git 地址', default: 'git@git.2dfire.net:ios/cocoapods-spec.git' }, 'binary_repo_url' => { description: '二进制私有源 Git 地址', default: 'git@git.2dfire.net:ios/cocoapods-spec-binary.git' }, 'binary_download_url' => { description: '二进制下载地址,内部会依次传入组件名称与版本,替换字符串中的 %s ', default: 'http://iosframeworkserver-shopkeeperclient.app.2dfire.com/download/%s/%s.zip' }, 'binary_upload_url' => { description: '二进制下载地址,内部会依次传入组件名称与版本,替换字符串中的 %s ', default: 'http://iosframeworkserver-shopkeeperclient.app.2dfire.com/upload/%s/%s.zip' }, # 'binary_type' => { description: '二进制打包类型', default: 'framework', selection: %w[framework library] }, 'download_file_type' => { description: '下载二进制文件类型', default: 'zip', selection: %w[zip tgz tar tbz txz dmg] } } end
Private Instance Methods
config()
click to toggle source
# File lib/cocoapods-tdf-bin/config/config.rb, line 96 def config @config ||= begin puts "====== cocoapods-tdf-bin #{CBin::VERSION} 版本 ======== \n" @config = OpenStruct.new load_config validate! @config end end
load_config()
click to toggle source
# File lib/cocoapods-tdf-bin/config/config.rb, line 88 def load_config if File.exist?(config_file) YAML.load_file(config_file) else default_config end end
method_missing(method, *args, &block)
click to toggle source
Calls superclass method
# File lib/cocoapods-tdf-bin/config/config.rb, line 122 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
respond_to_missing?(method, include_private = false)
click to toggle source
Calls superclass method
# File lib/cocoapods-tdf-bin/config/config.rb, line 118 def respond_to_missing?(method, include_private = false) config.respond_to?(method) || super end
validate!()
click to toggle source
# File lib/cocoapods-tdf-bin/config/config.rb, line 105 def validate! template_hash.each do |k, v| selection = v[:selection] next if !selection || selection.empty? config_value = @config.send(k) next unless config_value unless selection.include?(config_value) raise Pod::Informative, "#{k} 字段的值必须限定在可选值 [ #{selection.join(' / ')} ] 内".red end end end