Class: Metasploit::Model::Module::Ancestor::Spec::Template
- Inherits:
-
Spec::Template
- Object
- Base
- Spec::Template
- Metasploit::Model::Module::Ancestor::Spec::Template
- Extended by:
- Spec::Template::Write
- Defined in:
- app/models/metasploit/model/module/ancestor/spec/template.rb
Overview
Writes templates for the #module_ancestor to disk.
Constant Summary collapse
- DEFAULT_SEARCH_PATHNAMES =
Default value for #search_pathnames.
[ Pathname.new('module/ancestors') ]
- DEFAULT_SOURCE_RELATIVE_NAME =
Default value for #source_relative_name.
'base'
Constants inherited from Spec::Template
Spec::Template::BACKTRACE_FILE_REGEXP, Spec::Template::EXPLICIT_TRIM_MODE, Spec::Template::EXTENSION
Instance Attribute Summary collapse
-
#metasploit_module_relative_name ⇒ String
Name of the Class/Module declared in the template file.
-
#module_ancestor ⇒ Metasploit::Model::Module::Ancestor
The module ancestor to write.
Instance Method Summary collapse
-
#destination_pathname ⇒ Pathname?
The pathname where to Spec::Template::Write#write to template results.
-
#locals ⇒ Hash{Symbol => Object}
Local variables exposed to partials.
-
#overwrite ⇒ Boolean
Whether to overwrite a pre-existing file.
-
#search_pathnames ⇒ Array<Pathname>
Pathnames to search for partials.
-
#source_relative_name ⇒ String
Name of template under #search_pathnames without Spec::Template::EXTENSION.
Methods included from Spec::Template::Write
Methods inherited from Spec::Template
#find_pathname, #partial_pathname, #render, #render_super, #result, root, root=, #search_real_pathnames, #source_pathname, #write
Methods inherited from Base
Constructor Details
This class inherits a constructor from Metasploit::Model::Base
Instance Attribute Details
#metasploit_module_relative_name ⇒ String
Name of the Class/Module declared in the template file.
37 |
# File 'app/models/metasploit/model/module/ancestor/spec/template.rb', line 37 attr_writer :metasploit_module_relative_name |
#module_ancestor ⇒ Metasploit::Model::Module::Ancestor
The module ancestor to write.
43 44 45 |
# File 'app/models/metasploit/model/module/ancestor/spec/template.rb', line 43 def module_ancestor @module_ancestor end |
Instance Method Details
#destination_pathname ⇒ Pathname?
The pathname where to Spec::Template::Write#write to template results.
62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 |
# File 'app/models/metasploit/model/module/ancestor/spec/template.rb', line 62 def destination_pathname unless instance_variable_defined? :@destination_pathname @destination_pathname = nil if module_ancestor destination_pathname = module_ancestor.real_pathname unless destination_pathname # validate to derive real_path and therefore real_pathname module_ancestor.valid? destination_pathname = module_ancestor.real_pathname end @destination_pathname = destination_pathname end end @destination_pathname end |
#locals ⇒ Hash{Symbol => Object}
Local variables exposed to partials.
87 88 89 90 91 92 |
# File 'app/models/metasploit/model/module/ancestor/spec/template.rb', line 87 def locals @locals ||= { metasploit_module_relative_name: , module_ancestor: module_ancestor } end |
#overwrite ⇒ Boolean
Whether to overwrite a pre-existing file.
104 105 106 107 108 109 110 |
# File 'app/models/metasploit/model/module/ancestor/spec/template.rb', line 104 def overwrite unless instance_variable_defined? :@overwrite @overwrite = false end @overwrite end |
#search_pathnames ⇒ Array<Pathname>
Pathnames to search for partials.
115 116 117 |
# File 'app/models/metasploit/model/module/ancestor/spec/template.rb', line 115 def search_pathnames @search_pathnames ||= DEFAULT_SEARCH_PATHNAMES.dup end |
#source_relative_name ⇒ String
Name of template under #search_pathnames without Spec::Template::EXTENSION.
122 123 124 |
# File 'app/models/metasploit/model/module/ancestor/spec/template.rb', line 122 def source_relative_name @source_relative_name ||= DEFAULT_SOURCE_RELATIVE_NAME end |