Class: Flappy::IpaInfo::Ipa
Instance Method Summary collapse
- #app ⇒ Object
- #app_path ⇒ Object
- #cleanup ⇒ Object
-
#contents ⇒ Object
contents为ipa解压路径.
- #has_metadata? ⇒ Boolean
-
#initialize(path) ⇒ Ipa
constructor
include Parser::Common.
-
#is_stored ⇒ Object
是否是appstore包.
- #metadata ⇒ Object
- #metadata_path ⇒ Object
Constructor Details
#initialize(path) ⇒ Ipa
include Parser::Common
8 9 10 |
# File 'lib/flappy/util/ipa_info.rb', line 8 def initialize(path) @path = path # ipa包的路径 end |
Instance Method Details
#app ⇒ Object
34 35 36 |
# File 'lib/flappy/util/ipa_info.rb', line 34 def app @app ||= App.new(app_path, is_stored) end |
#app_path ⇒ Object
30 31 32 |
# File 'lib/flappy/util/ipa_info.rb', line 30 def app_path @app_path ||= Dir.glob(File.join(contents, 'Payload', '*.app')).first end |
#cleanup ⇒ Object
38 39 40 41 42 |
# File 'lib/flappy/util/ipa_info.rb', line 38 def cleanup return unless @contents FileUtils.rm_rf(@contents) @contents = nil end |
#contents ⇒ Object
contents为ipa解压路径
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/flappy/util/ipa_info.rb', line 12 def contents # contents为ipa解压路径 return @contents if @contents @contents = "#{Dir.tmpdir}/#{Time.now.strftime('%Y%m%d%H%M%S')}_ipa_files" Zip::File.open(@path) do |zip_file| # zip_file为待解压的文件路径 # puts "zipfile: #{zip_file}" zip_file.each do |f| # f为解压出来的文件 # puts "file: #{f}" f_path = File.join(@contents, f.name) # f_path为解压出来的文件路径 # puts "path: #{f_path}" # FileUtils.mkdir_p(File.dirname(f_path)) # File.dirname(f_path)为所有的文件夹、资源束文件;这里建立压缩包里面的每个文件夹,这一步可以省略的 # puts "dir: #{File.dirname(f_path)}" zip_file.extract(f, f_path) unless File.exist?(f_path) # 解压文件到相应位置 end end @contents end |
#has_metadata? ⇒ Boolean
53 54 55 |
# File 'lib/flappy/util/ipa_info.rb', line 53 def File.file?() end |
#is_stored ⇒ Object
是否是appstore包
61 62 63 |
# File 'lib/flappy/util/ipa_info.rb', line 61 def is_stored # 是否是appstore包 ? true : false end |
#metadata ⇒ Object
44 45 46 47 48 49 50 51 |
# File 'lib/flappy/util/ipa_info.rb', line 44 def return unless begin @metadata ||= CFPropertyList.native_types(CFPropertyList::List.new(file: ).value) rescue CFFormatError @metadata = {} end end |