Class: Parsing

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

Class Method Summary collapse

Class Method Details

.generate_options_from_yaml(yaml_c) ⇒ Object



25
26
27
28
29
30
31
32
# File 'lib/utilities/parsing.rb', line 25

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_attrsObject



16
17
18
19
20
21
22
23
# File 'lib/utilities/parsing.rb', line 16

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) ⇒ Object



5
6
7
8
9
10
# File 'lib/utilities/parsing.rb', line 5

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) ⇒ Object



12
13
14
# File 'lib/utilities/parsing.rb', line 12

def self.parse_config_file(file_location)
  yaml_c = YAML.load_file(file_location)
end

.variable_set(options = {}) ⇒ Object



34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/utilities/parsing.rb', line 34

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