Class: Confuse::Hunter
- Inherits:
-
Object
- Object
- Confuse::Hunter
- Defined in:
- lib/cocoapods-privacy/confuse/ConfuseHunter.rb
Instance Method Summary collapse
-
#initialize(version) ⇒ Hunter
constructor
类变量,用于缓存版本号.
- #insert_encrypted_apis_to_confuse_header(apis_define_map, confuse_header_path, flag = "") ⇒ Object
- #insert_encrypted_apis_to_confuse_swift(swift_extension_funcBody_map, swift_confuse_file_path, flag = "") ⇒ Object
- #search_need_confuse_apis(source_folders, exclude_folders = []) ⇒ Object
Constructor Details
#initialize(version) ⇒ Hunter
类变量,用于缓存版本号
14 15 16 |
# File 'lib/cocoapods-privacy/confuse/ConfuseHunter.rb', line 14 def initialize(version) @version = version end |
Instance Method Details
#insert_encrypted_apis_to_confuse_header(apis_define_map, confuse_header_path, flag = "") ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/cocoapods-privacy/confuse/ConfuseHunter.rb', line 23 def insert_encrypted_apis_to_confuse_header(apis_define_map,confuse_header_path,flag = "") # 存储已生成的随机字符串以确保唯一性 generated_strings = {} # 生成 #define 语句 defines = apis_define_map.map { |key, value| " #define #{key} #{value}" }.join("\n") confuse_header_content = ConfuseUtils.confuse_content(defines,File.basename(confuse_header_path)) puts "混淆(宏):\n 文件:#{confuse_header_path}\n 内容👇:\n#{confuse_header_content}" # 保存文件 File.write(confuse_header_path, confuse_header_content) end |
#insert_encrypted_apis_to_confuse_swift(swift_extension_funcBody_map, swift_confuse_file_path, flag = "") ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/cocoapods-privacy/confuse/ConfuseHunter.rb', line 39 def insert_encrypted_apis_to_confuse_swift(swift_extension_funcBody_map,swift_confuse_file_path,flag = "") # 存储已生成的随机字符串以确保唯一性 generated_strings = {} # 生成 #define 语句 funcs = swift_extension_funcBody_map.map { |key, values| func = "public extension #{key} {\n" + values.map { |value| value.split("\n").map { |line| " #{line}" }.join("\n") # 每行前加四个空格 }.join("\n\n") + "\n}" }.join("\n\n") confuse_func_content = funcs puts "混淆(扩展):\n 文件:#{swift_confuse_file_path}\n 内容👇:\n#{confuse_func_content}" # # 保存文件 File.write(swift_confuse_file_path, confuse_func_content) end |
#search_need_confuse_apis(source_folders, exclude_folders = []) ⇒ Object
18 19 20 21 |
# File 'lib/cocoapods-privacy/confuse/ConfuseHunter.rb', line 18 def search_need_confuse_apis(source_folders,exclude_folders=[]) apis_define_map, swift_extension_funcBody_map = search_files(source_folders, exclude_folders) return apis_define_map, swift_extension_funcBody_map end |