Sha256: 6ec4c6ac228585d1b4d3d077064a9c250d2a2899c3a40635a9cfbc4b29c5d15f
Contents?: true
Size: 1.95 KB
Versions: 9
Compression:
Stored size: 1.95 KB
Contents
module CMSScanner module Controller # Base Controller class Base include OptParseValidator # @return [ Array<OptParseValidator::OptBase> ] def cli_options; end def before_scan; end def run; end def after_scan; end def ==(other) self.class == other.class end # @return [ Target ] def target @@target ||= NS::Target.new(parsed_options[:url]) end # Set the parsed options and initialize the browser # with them # # @param [ Hash ] options def self.parsed_options=(options) @@parsed_options = options NS::Browser.instance(options) end # @return [ Hash ] def parsed_options @@parsed_options ||= {} end # @return [ Hash ] def datastore @@datastore ||= {} end # @return [ Formatter::Base ] def formatter @@formatter ||= NS::Formatter.load(parsed_options[:format], datastore[:views]) end # @see Formatter#output # # @return [ Void ] def output(tpl, vars = {}) formatter.output(*tpl_params(tpl, vars)) end # @see Formatter#render # # @return [ String ] def render(tpl, vars = {}) formatter.render(*tpl_params(tpl, vars)) end protected # @param [ String ] tpl # @param [ Hash ] vars # # @return [ Array<String> ] def tpl_params(tpl, vars) [ tpl, instance_variable_values.merge(vars), self.class.name.demodulize.underscore ] end # @return [ Hash ] All the instance variable keys (and their values) and the verbose value def instance_variable_values h = { verbose: parsed_options[:verbose] } instance_variables.each do |a| s = a.to_s n = s[1..s.size] h[n.to_sym] = instance_variable_get(a) end h end end end end
Version data entries
9 entries across 9 versions & 1 rubygems