Module: Pindo::Options::BundleIdSelector
- Defined in:
- lib/pindo/options/helpers/bundleid_selector.rb
Class Method Summary collapse
-
.load_deploy_bundleids ⇒ Object
加载发布环境的 Bundle ID 列表.
-
.load_dev_bundleids ⇒ Object
加载开发环境的 Bundle ID 列表.
-
.pindo_env_configdir ⇒ Object
获取 pindo 环境配置目录.
-
.select_bundleid(build_type) ⇒ String?
选择开发环境的 Bundle ID.
-
.select_deploy_bundleid ⇒ String
选择发布环境的 Bundle ID.
-
.select_dev_bundleid ⇒ String
选择开发环境的 Bundle ID.
-
.select_from_list(bundleid_list, env_name) ⇒ Object
从列表中选择 Bundle ID.
Class Method Details
.load_deploy_bundleids ⇒ Object
加载发布环境的 Bundle ID 列表
77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 |
# File 'lib/pindo/options/helpers/bundleid_selector.rb', line 77 def self.load_deploy_bundleids bundleids = [] # 从配置文件加载 config_file = File.join(pindo_env_configdir, 'bundleid_config.json') if File.exist?(config_file) begin config = JSON.parse(File.read(config_file)) bundleids |= config['all_release_bundleid'] if config['all_release_bundleid'] rescue => e puts "加载 bundleid_config.json 失败: #{e.}" end end bundleids end |
.load_dev_bundleids ⇒ Object
加载开发环境的 Bundle ID 列表
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
# File 'lib/pindo/options/helpers/bundleid_selector.rb', line 58 def self.load_dev_bundleids bundleids = [] # 从配置文件加载 config_file = File.join(pindo_env_configdir, 'bundleid_config.json') if File.exist?(config_file) begin config = JSON.parse(File.read(config_file)) bundleids |= config['all_dev_bundleid'] if config['all_dev_bundleid'] bundleids |= config['all_tool_bundleid'] if config['all_tool_bundleid'] rescue => e puts "加载 bundleid_config.json 失败: #{e.}" end end bundleids end |
.pindo_env_configdir ⇒ Object
获取 pindo 环境配置目录
95 96 97 98 99 100 |
# File 'lib/pindo/options/helpers/bundleid_selector.rb', line 95 def self.pindo_env_configdir require_relative '../../config/pindoconfig' Pindoconfig.instance.pindo_env_configdir rescue File.join(Dir.home, '.pindo', 'config') end |
.select_bundleid(build_type) ⇒ String?
选择开发环境的 Bundle ID
9 10 11 12 13 14 15 16 |
# File 'lib/pindo/options/helpers/bundleid_selector.rb', line 9 def self.select_bundleid(build_type) case build_type when 'adhoc', 'release' select_deploy_bundleid else select_dev_bundleid end end |
.select_deploy_bundleid ⇒ String
选择发布环境的 Bundle ID
29 30 31 32 33 34 |
# File 'lib/pindo/options/helpers/bundleid_selector.rb', line 29 def self.select_deploy_bundleid all_bundleid = load_deploy_bundleids return nil if all_bundleid.empty? select_from_list(all_bundleid, "发布环境") end |
.select_dev_bundleid ⇒ String
选择开发环境的 Bundle ID
20 21 22 23 24 25 |
# File 'lib/pindo/options/helpers/bundleid_selector.rb', line 20 def self.select_dev_bundleid all_bundleid = load_dev_bundleids return nil if all_bundleid.empty? select_from_list(all_bundleid, "开发环境") end |
.select_from_list(bundleid_list, env_name) ⇒ Object
从列表中选择 Bundle ID
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/pindo/options/helpers/bundleid_selector.rb', line 39 def self.select_from_list(bundleid_list, env_name) cli = HighLine.new puts puts "可用的Bundle Id如下::" bundleid_list.each_with_index do |bundleid, index| puts "#{index + 1}. #{bundleid}" end choice = cli.ask("请选择使用的Bundle Id,请输入选项(1/2/3...):", Integer) do |q| q.in = 1..bundleid_list.size end selected = bundleid_list[choice - 1] puts "已选择 #{env_name} Bundle ID: #{selected}\n" selected end |