Module: Flappy::Parser::Common

Included in:
Apk
Defined in:
lib/flappy/util/parser/common.rb

Instance Method Summary collapse

Instance Method Details

#generate_tmp_icon(data, type) ⇒ Object

when type is ipa, the icon data is a png file. when type is apk, the icon data is a binary data.



9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/flappy/util/parser/common.rb', line 9

def generate_tmp_icon data, type
  tmp_icon_path = "#{Dir.tmpdir}/icon-#{SecureRandom.hex[4..9]}.png"

  if type == :ipa
    FileUtils.cp(data, tmp_icon_path)
  elsif type == :apk
    File.open(tmp_icon_path, 'w+') { |f| f << data }
  else
    return
  end

  tmp_icon_path
end