Class: AppInfo::HAPP

Inherits:
HarmonyOS show all
Defined in:
lib/app_info/happ.rb

Overview

parser for HarmonyOS .APP file

Constant Summary

Constants included from AppInfo::Helper::HumanFileSize

AppInfo::Helper::HumanFileSize::FILE_SIZE_UNITS

Instance Attribute Summary

Attributes inherited from File

#file, #logger

Instance Method Summary collapse

Methods inherited from HarmonyOS

#contents, #device, #info_path, #manufacturer, #pack_info, #platform, #size

Methods included from AppInfo::Helper::Archive

#tempdir, #unarchive

Methods included from AppInfo::Helper::HumanFileSize

#file_to_human_size, #number_to_human_size

Methods inherited from File

#device, #format, #initialize, #manufacturer, #not_implemented_error!, #platform, #size

Constructor Details

This class inherits a constructor from AppInfo::File

Instance Method Details

#clear!Object



31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/app_info/happ.rb', line 31

def clear!
  return unless @contents

  FileUtils.rm_rf(@contents)

  @pack_info = nil
  @info_path = nil
  @contents = nil

  @default_entry_name = nil
  @default_entry&.clear!

  @default_entry = nil
end

#default_entryHAP

Returns:



8
9
10
11
# File 'lib/app_info/happ.rb', line 8

def default_entry
  hap_path = ::File.join(contents, "#{default_entry_name}.hap")
  @default_entry ||= HAP.new(hap_path)
end

#default_entry_nameString

Returns:

  • (String)


14
15
16
17
18
19
20
21
22
23
24
# File 'lib/app_info/happ.rb', line 14

def default_entry_name
  return @default_entry_name if @default_entry_name

  pack_info.packages.each do |package|
    if package['moduleType'] == 'entry' && package['deliveryWithInstall']
      @default_entry_name ||= package['name']
      break
    end
  end
  @default_entry_name
end

#nameString

Returns:

  • (String)


27
28
29
# File 'lib/app_info/happ.rb', line 27

def name
  default_entry.name
end