Class: CBin::Config_Hot_Key
  
  
  
  
  
    - Inherits:
 
    - 
      Object
      
        
          - Object
 
          
            - CBin::Config_Hot_Key
 
          
        
        show all
      
     
  
  
  
  
  
  
  
  
  
  
    - Defined in:
 
    - lib/cocoapods-bb-bin/config/config_hot_key.rb,
  lib/cocoapods-bb-bin/config/config_hot_key_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  
  
  
  
  
    
      
86
87
88
89
90
91
92
93
94 
     | 
    
      # File 'lib/cocoapods-bb-bin/config/config_hot_key.rb', line 86
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
    
      
  
  
    #config_file  ⇒ Object 
  
  
  
  
    
      
9
10
11 
     | 
    
      # File 'lib/cocoapods-bb-bin/config/config_hot_key.rb', line 9
def config_file
  config_file_with_hot_key_index(hot_key_index)
end 
     | 
  
 
    
      
  
  
    #config_file_whith_hot_key_index(hot_key_index)  ⇒ Object 
  
  
  
  
    
      
36
37
38 
     | 
    
      # File 'lib/cocoapods-bb-bin/config/config_hot_key.rb', line 36
def config_file_whith_hot_key_index(hot_key_index)
  "hot_key_#{hot_key_index}.yml"
end
     | 
  
 
    
      
  
  
    #config_file_with_hot_key_index(hot_key_index)  ⇒ Object 
  
  
  
  
    
      
21
22
23
24
25 
     | 
    
      # File 'lib/cocoapods-bb-bin/config/config_hot_key.rb', line 21
def config_file_with_hot_key_index(hot_key_index)
  file = config_file_whith_hot_key_index(hot_key_index)
  raise "\n=====  #{hot_key_index} 参数有误,请检查%w[1 2 3...]===" unless (hot_key_index.to_i).is_a?(Integer)
  File.expand_path("#{Pod::Config.instance.home_dir}/#{file}")
end
     | 
  
 
    
      
  
  
    #default_config  ⇒ Object 
  
  
  
  
    
      
46
47
48 
     | 
    
      # File 'lib/cocoapods-bb-bin/config/config_hot_key.rb', line 46
def default_config
  @default_config ||= Hash[template_hash.map { |k, v| [k, v[:default]] }]
end
     | 
  
 
    
      
  
  
    #hot_key_index  ⇒ Object 
  
  
  
  
    
      
27
28
29
30 
     | 
    
      # File 'lib/cocoapods-bb-bin/config/config_hot_key.rb', line 27
def hot_key_index
  @hot_key_index = 1 if @hot_key_index.is_a?(NilClass)
  @hot_key_index
end 
     | 
  
 
    
      
  
  
    #set_hot_key_index(hot_key_index)  ⇒ Object 
  
  
  
  
    
      
32
33
34 
     | 
    
      # File 'lib/cocoapods-bb-bin/config/config_hot_key.rb', line 32
def set_hot_key_index(hot_key_index)
  @hot_key_index = hot_key_index
end 
     | 
  
 
    
      
  
  
    #sync_config(config)  ⇒ Object 
  
  
  
  
    
      
40
41
42
43
44 
     | 
    
      # File 'lib/cocoapods-bb-bin/config/config_hot_key.rb', line 40
def sync_config(config)
  File.open(config_file_with_hot_key_index(config['hot_key_index']), 'w+') do |f|
    f.write(config.to_yaml)
  end
end
     | 
  
 
    
      
  
  
    #template_hash  ⇒ Object 
  
  
  
  
    
      
13
14
15
16
17
18
19 
     | 
    
      # File 'lib/cocoapods-bb-bin/config/config_hot_key.rb', line 13
def template_hash
  {
      'hot_key_index' => { description: '快捷键', default: '1', selection: %w[1 2 3...] },
      'hot_key_dir'   => { description: '快捷键执行目录', default: '' },
      'hot_key_cmd'   => { description: '快捷键执行命令', default: 'pod bin update --no-repo-update' }
  }
end
     |