Class: AppParser::Apk

Inherits:
Object
  • Object
show all
Includes:
AppIcon
Defined in:
lib/app_parser/apk.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from AppIcon

#icon, #largest_icon, #smallest_icon, #sorted_icons

Constructor Details

#initialize(file_name) ⇒ Apk

Returns a new instance of Apk.



9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/app_parser/apk.rb', line 9

def initialize(file_name)
  @apk = Android::Apk.new(file_name)

  @icons = @apk.icon.each_with_object([]) do |(name, data), obj|
    tempfile = Tempfile.new(File.basename(name))
    tempfile.binmode
    tempfile.write(data)
    tempfile.close # closeしないと画像サイズが取れない
    size = ImageSize.path(tempfile.path).size
    obj << { dimensions: size, file_name: name }
    tempfile.unlink
  end
end

Instance Attribute Details

#iconsObject (readonly)

Returns the value of attribute icons.



7
8
9
# File 'lib/app_parser/apk.rb', line 7

def icons
  @icons
end

Instance Method Details

#bundle_idObject



39
40
41
# File 'lib/app_parser/apk.rb', line 39

def bundle_id
  @apk.manifest.package_name
end

#display_nameObject



35
36
37
# File 'lib/app_parser/apk.rb', line 35

def display_name
  @apk.resource.find("@string/app_name")
end

#icon_data(file_name) ⇒ Object



51
52
53
# File 'lib/app_parser/apk.rb', line 51

def icon_data(file_name)
  @apk.icon.find { |name, _data| name == file_name }.try(:last)
end

#ipad_iconsObject



59
60
61
# File 'lib/app_parser/apk.rb', line 59

def ipad_icons
  []
end

#iphone_iconsObject



55
56
57
# File 'lib/app_parser/apk.rb', line 55

def iphone_icons
  []
end

#osObject



23
24
25
# File 'lib/app_parser/apk.rb', line 23

def os
  "android"
end

#provisioned_devicesObject



43
44
45
# File 'lib/app_parser/apk.rb', line 43

def provisioned_devices
  []
end

#provisions_all_devicesObject



47
48
49
# File 'lib/app_parser/apk.rb', line 47

def provisions_all_devices
  false
end

#versionObject



27
28
29
# File 'lib/app_parser/apk.rb', line 27

def version
  @apk.manifest.version_code.to_s
end

#version_stringObject



31
32
33
# File 'lib/app_parser/apk.rb', line 31

def version_string
  @apk.manifest.version_name
end