Class: MotionBlender::Analyzer
- Inherits:
-
Object
- Object
- MotionBlender::Analyzer
- Defined in:
- lib/motion_blender/analyzer.rb,
lib/motion_blender/analyzer/parser.rb,
lib/motion_blender/analyzer/require.rb,
lib/motion_blender/analyzer/evaluator.rb,
lib/motion_blender/analyzer/original_finder.rb
Defined Under Namespace
Classes: Evaluator, OriginalFinder, Parser, Require
Instance Attribute Summary collapse
-
#dependencies ⇒ Object
readonly
Returns the value of attribute dependencies.
-
#files ⇒ Object
readonly
Returns the value of attribute files.
Instance Method Summary collapse
- #analyze(file, backtrace = []) ⇒ Object
-
#initialize ⇒ Analyzer
constructor
A new instance of Analyzer.
- #parse(file, backtrace) ⇒ Object
Constructor Details
#initialize ⇒ Analyzer
Returns a new instance of Analyzer.
9 10 11 12 13 |
# File 'lib/motion_blender/analyzer.rb', line 9 def initialize @analyzed_files = Set.new @files = [] @dependencies = {} end |
Instance Attribute Details
#dependencies ⇒ Object (readonly)
Returns the value of attribute dependencies.
7 8 9 |
# File 'lib/motion_blender/analyzer.rb', line 7 def dependencies @dependencies end |
#files ⇒ Object (readonly)
Returns the value of attribute files.
7 8 9 |
# File 'lib/motion_blender/analyzer.rb', line 7 def files @files end |
Instance Method Details
#analyze(file, backtrace = []) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/motion_blender/analyzer.rb', line 15 def analyze file, backtrace = [] return if MotionBlender.config.excepted_files.include? file return if @analyzed_files.include? file @analyzed_files << file requires = parse file, backtrace if requires.any? @dependencies[file] = requires.map(&:file) @files = [*@files, file, *@dependencies[file]].uniq requires.each do |req| req.run_callbacks :require do analyze req.file, [req.trace, *backtrace] end end end end |
#parse(file, backtrace) ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/motion_blender/analyzer.rb', line 32 def parse file, backtrace parser = Parser.new file begin parser.run_callbacks :parse do parser.parse end rescue LoadError => err err.set_backtrace [parser.last_trace, *backtrace].compact raise err end parser.requires end |