class CMSScanner::Controller::Base

Base Controller

Public Class Methods

option_parser=(parser) click to toggle source

@param [ OptParsevalidator::OptParser ] parser

# File lib/cms_scanner/controller.rb, line 36
def self.option_parser=(parser)
  @@option_parser = parser
end
reset() click to toggle source

Reset all the class attibutes Currently only used in specs

# File lib/cms_scanner/controller.rb, line 24
def self.reset
  @@target    = nil
  @@datastore = nil
  @@formatter = nil
end

Public Instance Methods

==(other) click to toggle source
# File lib/cms_scanner/controller.rb, line 18
def ==(other)
  self.class == other.class
end
after_scan() click to toggle source
# File lib/cms_scanner/controller.rb, line 16
def after_scan; end
before_scan() click to toggle source
# File lib/cms_scanner/controller.rb, line 12
def before_scan; end
cli_options() click to toggle source

@return [ Array<OptParseValidator::OptBase> ]

# File lib/cms_scanner/controller.rb, line 10
def cli_options; end
datastore() click to toggle source

@return [ Hash ]

# File lib/cms_scanner/controller.rb, line 46
def datastore
  @@datastore ||= {}
end
formatter() click to toggle source

@return [ Formatter::Base ]

# File lib/cms_scanner/controller.rb, line 51
def formatter
  @@formatter ||= NS::Formatter.load(NS::ParsedCli.format, datastore[:views])
end
option_parser() click to toggle source

@return [ OptParsevalidator::OptParser ]

# File lib/cms_scanner/controller.rb, line 41
def option_parser
  @@option_parser
end
output(tpl, vars = {}) click to toggle source

@see Formatter#output

@return [ Void ]

# File lib/cms_scanner/controller.rb, line 58
def output(tpl, vars = {})
  formatter.output(*tpl_params(tpl, vars))
end
render(tpl, vars = {}) click to toggle source

@see Formatter#render

@return [ String ]

# File lib/cms_scanner/controller.rb, line 65
def render(tpl, vars = {})
  formatter.render(*tpl_params(tpl, vars))
end
run() click to toggle source
# File lib/cms_scanner/controller.rb, line 14
def run; end
target() click to toggle source

@return [ Target ]

# File lib/cms_scanner/controller.rb, line 31
def target
  @@target ||= NS::Target.new(NS::ParsedCli.url, NS::ParsedCli.options)
end
tmp_directory() click to toggle source

@return [ String ]

# File lib/cms_scanner/controller.rb, line 75
def tmp_directory
  File.join('/tmp', NS.app_name)
end
user_interaction?() click to toggle source

@return [ Boolean ]

# File lib/cms_scanner/controller.rb, line 70
def user_interaction?
  formatter.user_interaction? && !NS::ParsedCli.output
end

Protected Instance Methods

instance_variable_values() click to toggle source

@return [ Hash ] All the instance variable keys (and their values) and the verbose value

# File lib/cms_scanner/controller.rb, line 94
def instance_variable_values
  h = { verbose: NS::ParsedCli.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
tpl_params(tpl, vars) click to toggle source

@param [ String ] tpl @param [ Hash ] vars

@return [ Array<String> ]

# File lib/cms_scanner/controller.rb, line 85
def tpl_params(tpl, vars)
  [
    tpl,
    instance_variable_values.merge(vars),
    self.class.name.demodulize.underscore
  ]
end