Class: LinkmapIos::LinkmapParser
- Inherits:
-
Object
- Object
- LinkmapIos::LinkmapParser
- Defined in:
- lib/linkmap_ios.rb
Instance Attribute Summary collapse
-
#id_map ⇒ Object
readonly
Returns the value of attribute id_map.
-
#library_map ⇒ Object
readonly
Returns the value of attribute library_map.
Instance Method Summary collapse
- #hash ⇒ Object
-
#initialize(file_path) ⇒ LinkmapParser
constructor
A new instance of LinkmapParser.
- #json ⇒ Object
- #report ⇒ Object
Constructor Details
#initialize(file_path) ⇒ LinkmapParser
Returns a new instance of LinkmapParser.
12 13 14 15 16 17 |
# File 'lib/linkmap_ios.rb', line 12 def initialize(file_path) @file_path = file_path @id_map = {} @library_map = {} @section_map = {} end |
Instance Attribute Details
#id_map ⇒ Object (readonly)
Returns the value of attribute id_map.
9 10 11 |
# File 'lib/linkmap_ios.rb', line 9 def id_map @id_map end |
#library_map ⇒ Object (readonly)
Returns the value of attribute library_map.
10 11 12 |
# File 'lib/linkmap_ios.rb', line 10 def library_map @library_map end |
Instance Method Details
#hash ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/linkmap_ios.rb', line 19 def hash # Cache return @result_hash if @result_hash parse total_size = @library_map.values.map(&:size).inject(:+) detail = @library_map.values.map { |lib| {:library => lib.name, :size => lib.size, :dead_symbol_size => lib.dead_symbol_size, :objects => lib.objects.map { |o| @id_map[o][:object] }}} total_dead_size = @library_map.values.map(&:dead_symbol_size).inject(:+) # puts total_size # puts detail @result_hash = {:total => total_size, :detail => detail, :total_dead => total_dead_size} @result_hash end |
#json ⇒ Object
36 37 38 |
# File 'lib/linkmap_ios.rb', line 36 def json JSON.pretty_generate(hash) end |
#report ⇒ Object
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/linkmap_ios.rb', line 40 def report result = hash report = "# Total size\n" report << "#{Filesize.from(result[:total].to_s + 'B').pretty}\n" report << "# Dead Size\n" report << "#{Filesize.from(result[:total_dead].to_s + 'B').pretty}\n" report << "\n# Library detail\n" result[:detail].sort_by { |h| h[:size] }.reverse.each do |lib| report << "#{lib[:library]} #{Filesize.from(lib[:size].to_s + 'B').pretty}\n" end report << "\n# Object detail\n" @id_map.each_value do |id_info| report << "#{id_info[:object]} #{Filesize.from(id_info[:size].to_s + 'B').pretty}\n" end report << "# Uncounted Section Detail" @section_map.select do |_, value| value[:residual_size] != 0 end .each do |seg_sec_name, value| report << "\n#{seg_sec_name}, start_address: #{value[:start_address]}, end_address: #{value[:end_address]}, residual_size: #{value[:residual_size]}" end report end |