Module: IpaDiff

Defined in:
lib/ipa_diff.rb,
lib/ipa_diff/version.rb,
lib/ipa_diff/ipa_strings_comparison.rb

Defined Under Namespace

Classes: IpaStringsComparison

Constant Summary collapse

VERSION =
"0.1.0"

Class Method Summary collapse

Class Method Details

.compare(ipa_path1, ipa_path2, save_common_strings: false, verbose: false) ⇒ Object



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

def self.compare(ipa_path1, ipa_path2, save_common_strings: false, verbose: false)
  comparison = IpaStringsComparison.new(ipa_path1, ipa_path2, verbose: verbose)
  result = comparison.compare_ipa_strings(save_common_strings: save_common_strings)
  display_result(result, verbose: verbose)
end

.display_result(result, verbose: false) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/ipa_diff.rb', line 12

def self.display_result(result, verbose: false)
  common_strings = result[:common_strings]
  different_strings = result[:different_strings]

  all = common_strings.count + different_strings.count

  percent = common_strings.count * 100 / all

  puts
  puts "Number of common lines: #{common_strings.count}"
  puts "Number of different lines: #{different_strings.count}"
  puts "Percentage of common lines: #{percent}%"
  puts

  if verbose
    puts "Common String lines:"
    common_strings.each do |string|
      puts string
    end

    puts "\nDifferent Strings:"
    different_strings.each do |string|
      puts string
    end
  end

  duplicates = result[:same_sha256]

  if duplicates.empty?
    "No files with the same SHA256 found."
  else
    puts "Found #{duplicates.size} files with the same SHA256"
    if verbose
      duplicates.each do |sha256, files|
        puts "Files with the same SHA256 hash (#{sha256}) in both directories:"
        files.each { |file| puts "- #{file}" }
      end
    end
  end
end