Class: Lagoon::Parser::ControllerParser
- Inherits:
-
Object
- Object
- Lagoon::Parser::ControllerParser
- Defined in:
- lib/lagoon/parser/controller_parser.rb
Instance Attribute Summary collapse
-
#config ⇒ Object
readonly
Returns the value of attribute config.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ ControllerParser
constructor
A new instance of ControllerParser.
- #parse ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ ControllerParser
Returns a new instance of ControllerParser.
8 9 10 11 12 |
# File 'lib/lagoon/parser/controller_parser.rb', line 8 def initialize( = {}) @options = .is_a?(Options) ? : Options.for(:controller, ) @analyzer = Lagoon::Analyzer::ActionControllerAnalyzer.new @filter = ApplicationClassFilter.new(directory: 'controllers', include_all: @options[:all_controllers]) end |
Instance Attribute Details
#config ⇒ Object (readonly)
Returns the value of attribute config.
6 7 8 |
# File 'lib/lagoon/parser/controller_parser.rb', line 6 def config @config end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
6 7 8 |
# File 'lib/lagoon/parser/controller_parser.rb', line 6 def @options end |
Instance Method Details
#parse ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/lagoon/parser/controller_parser.rb', line 14 def parse controllers = load_controllers classes = [] relationships = [] warnings = [] controllers.sort_by { |controller| controller.name.to_s }.each do |controller| next if excluded?(controller) controller_data = @analyzer.analyze_controller(controller, ) classes << controller_data if [:include_inheritance] relationships.concat( @analyzer.extract_inheritance( controller, include_framework_base: [:include_framework_bases] ) ) end rescue StandardError => e raise if [:strict] warnings << "Failed to analyze controller #{controller.name || '(anonymous)'}: #{e.}" end { classes: classes.sort_by { |controller| controller[:name] }, relationships: relationships.sort_by { |relationship| [relationship[:source], relationship[:target]] }, warnings: warnings, counts: { classes: classes.size, relationships: relationships.size, skipped: warnings.size } } end |