class HBHConfig::Config
Public Class Methods
new()
click to toggle source
# File lib/cocoapods-hbh/config/config.rb, line 66 def initialize end
Public Instance Methods
config()
click to toggle source
# File lib/cocoapods-hbh/config/config.rb, line 80 def config @config ||= begin puts "====== cocoapods-hbh #{CocoapodsHbh::VERSION} 版本 ======== \n" @config = OpenStruct.new load_config @config end end
config_file()
click to toggle source
# File lib/cocoapods-hbh/config/config.rb, line 7 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-hbh/config/config.rb, line 37 def config_file_with_configuration_env(configuration_env) file = config_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_path = "#{Pod::Config.instance.installation_root}/#{file}" if file_path.blank? file_path = "#{Pod::Config.instance.home_dir}/#{file}" end File.expand_path(file_path) end
configuration_env()
click to toggle source
# File lib/cocoapods-hbh/config/config.rb, line 17 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
load_config()
click to toggle source
# File lib/cocoapods-hbh/config/config.rb, line 58 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-hbh/config/config.rb, line 70 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
set_configuration_env(env)
click to toggle source
# File lib/cocoapods-hbh/config/config.rb, line 33 def set_configuration_env(env) @configuration_env = env end
template_hash()
click to toggle source
# File lib/cocoapods-hbh/config/config.rb, line 11 def template_hash { 'configuration_env' => { description: '编译环境', default: 'dev', selection: %w[dev debug_iphoneos release_iphoneos] }, } end