Class: Objc_Obfuscator::CLI

Inherits:
Thor
  • Object
show all
Includes:
Integrator, Obfuscator, Thor::Actions
Defined in:
lib/objc-obfuscator/cli.rb

Instance Method Summary collapse

Methods included from Integrator

#integrate_xcode

Methods included from Obfuscator

#obfuscate_file

Instance Method Details

#integrate(encryption_key, project_path) ⇒ Object

Raises:

  • (Thor::Error)


51
52
53
54
55
56
57
58
59
60
61
62
# File 'lib/objc-obfuscator/cli.rb', line 51

def integrate(encryption_key, project_path)
  raise Thor::Error, 'A valid project file should be specified' unless File.exist?(project_path)

  podfile_path = File.join File.dirname(project_path), './Podfile'
  unless options[:podfile].empty? 
    podfile_path = options[:podfile]
  end
  raise Thor::Error, 'The project must be using cocoapods' unless File.exist?(podfile_path)

  integrate_xcode encryption_key, project_path, podfile_path, options[:target]

end

#obfuscate(key, *file_paths) ⇒ Object

Raises:

  • (Thor::Error)


24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/objc-obfuscator/cli.rb', line 24

def obfuscate(key, *file_paths)
  
  raise Thor::Error, 'A valid key and file must be provided' if key.empty? || file_paths.empty?

  file_paths.each do |file_path| 
    unless File.exist? file_path
      say_status :warning, "File #{file_path} not found!", :yellow
    else
      Dir.mktmpdir { |tmp_dir| obfuscate_file file_path, tmp_dir, key, options[:backup] }
    end
  end
end