Class: Appx::File

Inherits:
Object
  • Object
show all
Defined in:
lib/appx/file.rb

Constant Summary collapse

MANIFEST =
'AppxManifest.xml'

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path) ⇒ File

Returns a new instance of File.



10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/appx/file.rb', line 10

def initialize(path)
  @path = path

  raise Appx::FileNotFoundError, path unless ::File.exist?(path)

  begin
    @zip_file = Zip::File.open(@path)
  rescue Zip::Error => e
    raise Appx::InvalidAppxError, e.message
  end

  manifest_data = @zip_file.read(@zip_file.find_entry(MANIFEST))
  @manifest = Appx::Manifest.new(manifest_data)
end

Instance Attribute Details

#manifestObject (readonly)

Returns the value of attribute manifest.



8
9
10
# File 'lib/appx/file.rb', line 8

def manifest
  @manifest
end

#pathObject (readonly)

Returns the value of attribute path.



7
8
9
# File 'lib/appx/file.rb', line 7

def path
  @path
end