Class: CBin::Config

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

Defined Under Namespace

Classes: Asker

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

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



64
65
66
67
68
69
70
71
72
# File 'lib/cocoapods-pahealth-bin/config/config.rb', line 64

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_repo_urlObject



56
57
58
# File 'lib/cocoapods-pahealth-bin/config/config_asker.rb', line 56

def binary_repo_url
  # code here
end

#config_fileObject



5
6
7
# File 'lib/cocoapods-pahealth-bin/config/config.rb', line 5

def config_file
  File.expand_path("#{Pod::Config.instance.home_dir}/bin.yml")
end

#default_configObject



25
26
27
# File 'lib/cocoapods-pahealth-bin/config/config.rb', line 25

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

#sync_config(config) ⇒ Object



19
20
21
22
23
# File 'lib/cocoapods-pahealth-bin/config/config.rb', line 19

def sync_config(config)
  File.open(config_file, 'w+') do |f|
    f.write(config.to_yaml)
  end
end

#template_hashObject



9
10
11
12
13
14
15
16
17
# File 'lib/cocoapods-pahealth-bin/config/config.rb', line 9

def template_hash
  {
      'code_repo_url' => { description: '私有源 Git 地址', default: 'http://domain/git/pahealth_private_repo.git' },
      #'binary_repo_url' => { description: '二进制私有源 Git 地址', default: '[email protected]:ios/cocoapods-spec-binary.git' },
      #'binary_download_url' => { description: '二进制下载地址,内部会依次传入组件名称与版本,替换字符串中的 %s ', default: 'http://iosframeworkserver-shopkeeperclient.app.2dfire.com/download/%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