Class: IosAssetExtractor::Extractor

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(file_path) ⇒ Extractor

Returns a new instance of Extractor.



7
8
9
10
# File 'lib/ios_asset_extractor.rb', line 7

def initialize(file_path)
  @file_path = file_path
  @command_path = File.expand_path "../../bin/iOSAssetExtractor", __FILE__
end

Instance Attribute Details

#file_pathObject (readonly)

Returns the value of attribute file_path.



6
7
8
# File 'lib/ios_asset_extractor.rb', line 6

def file_path
  @file_path
end

Instance Method Details

#extract_to(dir_path) ⇒ Object



26
27
28
# File 'lib/ios_asset_extractor.rb', line 26

def extract_to(dir_path)
  system "#{@command_path} -i #{@file_path} -o #{dir_path} > /dev/null 2>&1"
end

#file_with_size_hashObject



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

def file_with_size_hash
  Dir.mktmpdir do |dir_path|
    system "#{@command_path} -i #{@file_path} -o #{dir_path} > /dev/null 2>&1 "
    Dir.entries(dir_path).select do |entry|
      not File.directory?("#{dir_path}/#{entry}")
    end.map do |entry|
    {
        name: entry,
        size: File.size("#{dir_path}/#{entry}")
      }
    end
  end
end