Class: XCRes::AggregateAnalyzer

Inherits:
Analyzer
  • Object
show all
Defined in:
lib/xcres/analyzer/aggregate_analyzer.rb

Overview

A AggregateAnalyzer runs multiple Analyzer.

Direct Known Subclasses

ResourcesAggregateAnalyzer

Instance Attribute Summary collapse

Attributes inherited from Analyzer

#exclude_file_patterns, #logger, #options, #sections, #target

Instance Method Summary collapse

Methods inherited from Analyzer

#filter_exclusions, #find_file_refs_by_extname, #is_file_ref_included_in_application_target?, #new_section, #project, #resources_files

Methods included from FileHelper

#basename_without_ext

Constructor Details

#initialize(project = nil, options = {}) ⇒ AggregateAnalyzer

Returns a new instance of AggregateAnalyzer.



13
14
15
16
# File 'lib/xcres/analyzer/aggregate_analyzer.rb', line 13

def initialize(project=nil, options={})
  super
  self.analyzers = []
end

Instance Attribute Details

#analyzersArray<Analyzer>

Returns an array of Analyzer.

Returns:

  • (Array<Analyzer>)

    an array of Analyzer.



11
12
13
# File 'lib/xcres/analyzer/aggregate_analyzer.rb', line 11

def analyzers
  @analyzers
end

Instance Method Details

#add_with_class(analyzer_class, options = {}) ⇒ Analyzer

Instantiate and add an analyzer by its class. All properties will be copied to the child analyzer.

Parameters:

  • analyzer_class (Class)

    the class of the analyzer to instantiate and add

  • options (Hash) (defaults to: {})

    options which will be passed on initialization

Returns:



38
39
40
41
42
43
44
# File 'lib/xcres/analyzer/aggregate_analyzer.rb', line 38

def add_with_class(analyzer_class, options={})
  analyzer = analyzer_class.new(target, self.options.merge(options))
  analyzer.exclude_file_patterns = exclude_file_patterns
  analyzer.logger = logger
  self.analyzers << analyzer
  analyzer
end

#analyzeArray<Hash>

Run all aggregated analyzers

Returns:

  • (Array<Hash>)

    the built sections



23
24
25
# File 'lib/xcres/analyzer/aggregate_analyzer.rb', line 23

def analyze
  @sections = analyzers.map(&:analyze).flatten.compact
end