Class: EasyAI::ConfigManager
- Inherits:
-
Object
- Object
- EasyAI::ConfigManager
- Defined in:
- lib/easyai/config/config.rb
Overview
ConfigManager 类负责业务配置逻辑和用户认证
Instance Attribute Summary collapse
-
#platform ⇒ Object
readonly
Returns the value of attribute platform.
-
#tool_type ⇒ Object
readonly
Returns the value of attribute tool_type.
-
#verbose ⇒ Object
readonly
Returns the value of attribute verbose.
Class Method Summary collapse
Instance Method Summary collapse
-
#download_user_config(user_name = nil) ⇒ Object
主要接口:下载用户配置.
-
#initialize(options = {}) ⇒ ConfigManager
constructor
A new instance of ConfigManager.
Constructor Details
#initialize(options = {}) ⇒ ConfigManager
Returns a new instance of ConfigManager.
11 12 13 14 15 16 |
# File 'lib/easyai/config/config.rb', line 11 def initialize( = {}) @verbose = [:verbose] || false @tool_type = [:tool_type] @platform = [:platform] @platform_flag = [:platform_flag] || false end |
Instance Attribute Details
#platform ⇒ Object (readonly)
Returns the value of attribute platform.
9 10 11 |
# File 'lib/easyai/config/config.rb', line 9 def platform @platform end |
#tool_type ⇒ Object (readonly)
Returns the value of attribute tool_type.
9 10 11 |
# File 'lib/easyai/config/config.rb', line 9 def tool_type @tool_type end |
#verbose ⇒ Object (readonly)
Returns the value of attribute verbose.
9 10 11 |
# File 'lib/easyai/config/config.rb', line 9 def verbose @verbose end |
Class Method Details
.download_user_config(user_name = nil, options = {}) ⇒ Object
类方法兼容接口
19 20 21 22 |
# File 'lib/easyai/config/config.rb', line 19 def self.download_user_config(user_name = nil, = {}) manager = new() manager.download_user_config(user_name) end |
Instance Method Details
#download_user_config(user_name = nil) ⇒ Object
主要接口:下载用户配置
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/easyai/config/config.rb', line 25 def download_user_config(user_name = nil) puts "正在加载配置..." if @verbose log_config_info if @verbose # 确保配置仓库就绪 EasyAIConfig.initialize(verbose: @verbose) # 获取 index 配置 users = get_index_config return nil unless users return nil if users_empty?(users) # 获取用户名 selected_user = user_name || get_username_from_jps return handle_user_result(selected_user) unless selected_user.is_a?(String) # 处理平台选择 if @platform_flag && @tool_type == "claude" @platform = select_platform_for_user(users, selected_user.strip) return nil unless @platform end # 查找并加载配置 config_filename = find_user_config(users, selected_user.strip) return nil unless config_filename puts "✓ 正在为 #{selected_user} 加载配置" if @verbose get_user_config_content(config_filename) end |