Class: CBin::Config
- Inherits:
-
Object
- Object
- CBin::Config
- Defined in:
- lib/cocoapods-mtxx-bin/config/config.rb,
lib/cocoapods-mtxx-bin/config/config_asker.rb,
lib/cocoapods-mtxx-bin/config/config_builder.rb
Defined Under Namespace
Instance Method Summary collapse
-
#binary_download_url_str ⇒ Object
下载二进制的url.
-
#binary_upload_url_str ⇒ Object
上传二进制的url.
-
#config_debug_iphoneos_file ⇒ Object
包含arm64 armv7架构,xcodebuild 是Debug模式.
-
#config_dev_file ⇒ Object
包含x86 arm64 armv7架构,xcodebuild 是Release模式.
- #config_file ⇒ Object
-
#config_file_exist? ⇒ Boolean
判断配置文件是否存在.
- #config_file_with_configuration_env(configuration_env) ⇒ Object
-
#config_release_iphoneos_file ⇒ Object
包含arm64 armv7架构,xcodebuild 是Release模式.
- #configuration_env ⇒ Object
-
#default_config ⇒ Object
def sync_config_code_repo_url_list(config) File.open(config_file_with_configuration_env_list(config), 'w+') do |f| f.write(config.to_yaml) end end.
- #set_configuration_env(env) ⇒ Object
-
#sync_config(config) ⇒ Object
配置信息写入文件.
- #template_hash ⇒ Object
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args, &block) ⇒ Object (private)
128 129 130 131 132 133 134 135 136 |
# File 'lib/cocoapods-mtxx-bin/config/config.rb', line 128 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_download_url_str ⇒ Object
下载二进制的url
55 56 57 |
# File 'lib/cocoapods-mtxx-bin/config/config.rb', line 55 def binary_download_url_str CBin.config.binary_download_url end |
#binary_upload_url_str ⇒ Object
上传二进制的url
50 51 52 |
# File 'lib/cocoapods-mtxx-bin/config/config.rb', line 50 def binary_upload_url_str CBin.config.binary_upload_url end |
#config_debug_iphoneos_file ⇒ Object
包含arm64 armv7架构,xcodebuild 是Debug模式
64 65 66 |
# File 'lib/cocoapods-mtxx-bin/config/config.rb', line 64 def config_debug_iphoneos_file ".bin_debug_iphoneos.yml" end |
#config_dev_file ⇒ Object
包含x86 arm64 armv7架构,xcodebuild 是Release模式
72 73 74 |
# File 'lib/cocoapods-mtxx-bin/config/config.rb', line 72 def config_dev_file ".bin_dev.yml" end |
#config_file ⇒ Object
8 9 10 |
# File 'lib/cocoapods-mtxx-bin/config/config.rb', line 8 def config_file config_file_with_configuration_env(configuration_env) end |
#config_file_exist? ⇒ Boolean
判断配置文件是否存在
141 142 143 |
# File 'lib/cocoapods-mtxx-bin/config/config.rb', line 141 def config_file_exist? raise Pod::Informative, "当前目录下没有配置文件,请先执行`pod bin init`" unless File.exist?(config_file) end |
#config_file_with_configuration_env(configuration_env) ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/cocoapods-mtxx-bin/config/config.rb', line 22 def config_file_with_configuration_env(configuration_env) file = config_dev_file if configuration_env == "release_iphoneos" file = config_release_iphoneos_file elsif configuration_env == "debug_iphoneos" file = config_debug_iphoneos_file elsif configuration_env == "dev" file = config_dev_file else raise "===== #{configuration_env} %w[dev debug_iphoneos release_iphoneos]====" end File.("#{Pod::Config.instance.project_root}/#{file}") end |
#config_release_iphoneos_file ⇒ Object
包含arm64 armv7架构,xcodebuild 是Release模式
68 69 70 |
# File 'lib/cocoapods-mtxx-bin/config/config.rb', line 68 def config_release_iphoneos_file ".bin_release_iphoneos.yml" end |
#configuration_env ⇒ Object
37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/cocoapods-mtxx-bin/config/config.rb', line 37 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 ⇒ Object
def sync_config_code_repo_url_list(config)
File.open(config_file_with_configuration_env_list(config['code_repo_url_list']), 'w+') do |f|
f.write(config.to_yaml)
end
end
89 90 91 |
# File 'lib/cocoapods-mtxx-bin/config/config.rb', line 89 def default_config @default_config ||= Hash[template_hash.map { |k, v| [k, v[:default]] }] end |
#set_configuration_env(env) ⇒ Object
59 60 61 |
# File 'lib/cocoapods-mtxx-bin/config/config.rb', line 59 def set_configuration_env(env) @configuration_env = env end |
#sync_config(config) ⇒ Object
配置信息写入文件
77 78 79 80 81 |
# File 'lib/cocoapods-mtxx-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_hash ⇒ Object
12 13 14 15 16 17 18 19 20 |
# File 'lib/cocoapods-mtxx-bin/config/config.rb', line 12 def template_hash { 'configuration_env' => { description: '编译环境', default: 'dev', selection: %w[dev debug_iphoneos release_iphoneos] }, 'binary_repo_url' => { description: '二进制podspec私有源地址', default: 'git@github.com:Zhangyanshen/example-private-spec-bin.git' }, 'binary_upload_url' => { description: '二进制文件上传地址', default: 'http://localhost:8080/frameworks' }, 'binary_download_url' => { description: '二进制文件下载地址,后面会依次传入Xcode版本、configuration、组件名称与组件版本', default: 'http://localhost:8080/frameworks' }, 'download_file_type' => { description: '二进制文件类型', default: 'zip', selection: %w[zip tgz tar tbz txz dmg] } } end |