class CMSScanner::Controller::Base
Public Class Methods
Source
# File lib/cms_scanner/controller.rb, line 36 def self.option_parser=(parser) @@option_parser = parser end
@param [ OptParsevalidator::OptParser ] parser
Source
# File lib/cms_scanner/controller.rb, line 24 def self.reset @@target = nil @@datastore = nil @@formatter = nil end
Reset all the class attibutes Currently only used in specs
Public Instance Methods
Source
# File lib/cms_scanner/controller.rb, line 18 def ==(other) self.class == other.class end
Source
# File lib/cms_scanner/controller.rb, line 10 def cli_options; end
@return [ Array<OptParseValidator::OptBase> ]
Source
# File lib/cms_scanner/controller.rb, line 46 def datastore @@datastore ||= {} end
@return [ Hash ]
Source
# File lib/cms_scanner/controller.rb, line 51 def formatter @@formatter ||= NS::Formatter.load(NS::ParsedCli.format, datastore[:views]) end
@return [ Formatter::Base
]
Source
# File lib/cms_scanner/controller.rb, line 41 def option_parser @@option_parser end
@return [ OptParsevalidator::OptParser ]
Source
# File lib/cms_scanner/controller.rb, line 58 def output(tpl, vars = {}) formatter.output(*tpl_params(tpl, vars)) end
@see Formatter#output
@return [ Void ]
Source
# File lib/cms_scanner/controller.rb, line 65 def render(tpl, vars = {}) formatter.render(*tpl_params(tpl, vars)) end
@see Formatter#render
@return [ String ]
Source
# File lib/cms_scanner/controller.rb, line 31 def target @@target ||= NS::Target.new(NS::ParsedCli.url, NS::ParsedCli.options) end
@return [ Target
]
Source
# File lib/cms_scanner/controller.rb, line 75 def tmp_directory File.join('/tmp', NS.app_name) end
@return [ String ]
Source
# File lib/cms_scanner/controller.rb, line 70 def user_interaction? formatter.user_interaction? && !NS::ParsedCli.output end
@return [ Boolean ]
Protected Instance Methods
Source
# 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
@return [ Hash ] All the instance variable keys (and their values) and the verbose value
Source
# 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
@param [ String ] tpl @param [ Hash ] vars
@return [ Array<String> ]