Class: CMSScanner::Controllers

Inherits:
Array
  • Object
show all
Defined in:
lib/cms_scanner/controllers.rb

Overview

Controllers Container

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(option_parser = OptParseValidator::OptParser.new(nil, 40)) ⇒ Controllers

Returns a new instance of Controllers.



6
7
8
# File 'lib/cms_scanner/controllers.rb', line 6

def initialize(option_parser = OptParseValidator::OptParser.new(nil, 40))
  @option_parser = option_parser
end

Instance Attribute Details

#option_parserObject (readonly)

Returns the value of attribute option_parser.



4
5
6
# File 'lib/cms_scanner/controllers.rb', line 4

def option_parser
  @option_parser
end

Instance Method Details

#<<(controller) ⇒ Object

Parameters:



13
14
15
16
17
18
19
20
21
# File 'lib/cms_scanner/controllers.rb', line 13

def <<(controller)
  options = controller.cli_options

  unless include?(controller)
    option_parser.add(*options) if options
    super(controller)
  end
  self
end

#runObject



23
24
25
26
27
28
29
30
31
32
# File 'lib/cms_scanner/controllers.rb', line 23

def run
  parsed_options             = option_parser.results
  first.class.parsed_options = parsed_options

  redirect_output_to_file(parsed_options[:output]) if parsed_options[:output]

  each(&:before_scan)
  each(&:run)
  reverse.each(&:after_scan)
end