Class: Metasploit::Framework::Compiler::Headers::Base
- Inherits:
-
Object
- Object
- Metasploit::Framework::Compiler::Headers::Base
- Defined in:
- lib/metasploit/framework/compiler/headers/base.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#loaded_dep ⇒ Object
Returns the value of attribute loaded_dep.
Instance Method Summary collapse
-
#include(lib_name) ⇒ String
Returns the header source code.
-
#initialize ⇒ Base
constructor
Initializes the Base class for headers.
Constructor Details
#initialize ⇒ Base
Initializes the Base class for headers.
10 11 12 13 |
# File 'lib/metasploit/framework/compiler/headers/base.rb', line 10 def initialize # This is used to avoid loading the same dependency code twice @loaded_dep = [] end |
Instance Attribute Details
#loaded_dep ⇒ Object
Returns the value of attribute loaded_dep.
7 8 9 |
# File 'lib/metasploit/framework/compiler/headers/base.rb', line 7 def loaded_dep @loaded_dep end |
Instance Method Details
#include(lib_name) ⇒ String
Returns the header source code.
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/metasploit/framework/compiler/headers/base.rb', line 19 def include(lib_name) lib = lib_dep_map[lib_name] unless lib raise RuntimeError, "#{lib_name} not found" end # Load the dependencies first, and only once dep = '' lib.each do |f| unless loaded_dep.include?(f) dep_path = File.join(headers_path, f) dep << File.read(dep_path) << "\n" loaded_dep << f end end # Load the headers lib_path = File.join(headers_path, lib_name) "#{dep}#{File.read(lib_path)}" end |