class Parsing

This class performs all of the parsing associated with the YAML file or the reading in of the paths for the 4 variables

Public Class Methods

generate_options_from_yaml(yaml_c) click to toggle source

This method reads in the options from the YAML file and assigns them the hash values within the yaml_c hash

# File lib/utilities/parsing.rb, line 33
def self.generate_options_from_yaml(yaml_c) 
   options = {}
   options[:apk] = yaml_c["apk"]
   options[:apktool] = yaml_c["apktool"]
   options[:output_directory] = yaml_c["output_directory"]
   options[:d2j] = yaml_c["d2j"]
  return options  
end
modify_yaml_attrs() click to toggle source

This method creates a hash called yaml_c that takes in the 4 environment variables defined

# File lib/utilities/parsing.rb, line 22
def self.modify_yaml_attrs
 yaml_c = {
 "apk" => ENV["APK"],
 "apktool" => ENV["APKTOOL"],
 "output_directory" => ENV["OUTPUT_DIR"],
 "d2j" => ENV["DEX2JAR"]
  }
end
parse(file_location=nil, test=false) click to toggle source

This method raises an error if a YAML file is not given

# File lib/utilities/parsing.rb, line 8
def self.parse(file_location=nil, test=false)
  raise "NoFileProvidedForParsing" if !(file_location)
  yaml_c = test ? modify_yaml_attrs : parse_config_file(file_location) 
  opts = generate_options_from_yaml(yaml_c)   
  variable_set(opts)
end
parse_config_file(file_location) click to toggle source

This method loads and parses the YAML config file

# File lib/utilities/parsing.rb, line 16
def self.parse_config_file(file_location)
  yaml_c = YAML.load_file(file_location)
end
variable_set(options={}) click to toggle source

This method specifies executing the gem for the 3 options of reading in the APK location manually, having a single APK within the YAML file, or having multiple APKs within the YAML file

# File lib/utilities/parsing.rb, line 45
def self.variable_set(options={})
  Decompiler.set_static_vars(options)
  apk_loc = options[:apk]
  if apk_loc.kind_of?(String)
    Decompiler.set_apk_var(apk_loc)
    Decompiler.execute
  elsif apk_loc.kind_of?(Array)
    apk_loc.each do |apkl|
      Decompiler.set_apk_var(apkl)
      Decompiler.execute
    end
  end
end