class Fastlane::Helper::FileCategory
文件类型
Constants
- EXECUTABLE
- FRAMEWORKS
- PLUGINS
- UNKNOWN
- UNKNOWN_FILES
Attributes
file_infos[RW]
format_size[RW]
name[RW]
size[RW]
Public Class Methods
categories(type, infos, options = {})
click to toggle source
@param type: 文件类型: FileInfo::FileInfoUnknownDir, FileInfo::FileInfoUnknownFile, FileInfo::FileInfoUnknown @param infos: 文件数组: [#<FileInfo:0x01>, #<FileInfo:0x02>, … #<FileInfo:0x0N>]
# File lib/fastlane/plugin/analyze_ios_ipa/helper/file_category.rb, line 33 def self.categories(type, infos, options = {}) executable_name = options[:executable] block = { FileInfoUnknownDir: lambda do |infos| # 主要是将如下两个目录, 继续递归遍历解析 # - 1) PlugIns 类型 # - 2) Frameworks 类型 # - 3) Unknown 类型 infos.map { |e| fc = FileCategory.new if e.name == PLUGINS fc.name = PLUGINS fc.merge(FileHelper.glob_files('*', e.path).map { |f| FileInfo.new(f) }) elsif e.name == FRAMEWORKS fc = FileCategory.new fc.name = FRAMEWORKS fc.merge(FileHelper.glob_files('*', e.path).map { |f| FileInfo.new(f) }) else fc.name = UNKNOWN fc.push(e) end fc.finish fc } end, FileInfoUnknownFile: lambda do |infos| # - 1) executable infos.map { |e| fc = FileCategory.new if e.name == executable_name fc.name = EXECUTABLE fc.push(FileInfo.new(e.path)) else fc.name = UNKNOWN fc.push(e) end fc.finish fc } end }[type] if block # puts "[1] type: #{type} -- #{infos.count}" block.call(infos) else # puts "[2] type: #{type} -- #{infos.count}" # # Plugins/、Frameworks/、app mach-o , 三者之外的其他类型的文件 fc = FileCategory.new fc.name = type fc.merge(infos) fc.finish fc end end
new()
click to toggle source
# File lib/fastlane/plugin/analyze_ios_ipa/helper/file_category.rb, line 99 def initialize @file_infos = [] end
Public Instance Methods
finish()
click to toggle source
# File lib/fastlane/plugin/analyze_ios_ipa/helper/file_category.rb, line 111 def finish @size = @file_infos.map(&:size).inject(0, :+) @format_size = FileHelper.format_size(@size) end
merge(infos)
click to toggle source
# File lib/fastlane/plugin/analyze_ios_ipa/helper/file_category.rb, line 107 def merge(infos) @file_infos += infos end
push(info)
click to toggle source
# File lib/fastlane/plugin/analyze_ios_ipa/helper/file_category.rb, line 103 def push(info) @file_infos << info end
to_hash()
click to toggle source
# File lib/fastlane/plugin/analyze_ios_ipa/helper/file_category.rb, line 20 def to_hash { name: @name, size: @size, format_size: @format_size, files: @file_infos.map(&:to_hash) } end