Class: MotionBlender::Analyzer
- Inherits:
-
Object
- Object
- MotionBlender::Analyzer
- Defined in:
- lib/motion_blender/analyzer.rb,
lib/motion_blender/analyzer/cache.rb,
lib/motion_blender/analyzer/parser.rb,
lib/motion_blender/analyzer/source.rb,
lib/motion_blender/analyzer/require.rb,
lib/motion_blender/analyzer/evaluator.rb,
lib/motion_blender/analyzer/original_finder.rb
Defined Under Namespace
Classes: Cache, Evaluator, OriginalFinder, Parser, Require, Source
Instance Attribute Summary collapse
-
#cache ⇒ Object
readonly
Returns the value of attribute cache.
-
#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.
10 11 12 13 14 |
# File 'lib/motion_blender/analyzer.rb', line 10 def initialize @analyzed_files = Set.new @files = [] @dependencies = {} end |
Instance Attribute Details
#cache ⇒ Object (readonly)
Returns the value of attribute cache.
8 9 10 |
# File 'lib/motion_blender/analyzer.rb', line 8 def cache @cache end |
#dependencies ⇒ Object (readonly)
Returns the value of attribute dependencies.
8 9 10 |
# File 'lib/motion_blender/analyzer.rb', line 8 def dependencies @dependencies end |
#files ⇒ Object (readonly)
Returns the value of attribute files.
8 9 10 |
# File 'lib/motion_blender/analyzer.rb', line 8 def files @files end |
Instance Method Details
#analyze(file, backtrace = []) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/motion_blender/analyzer.rb', line 16 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.present? @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
34 35 36 37 38 39 40 41 42 43 |
# File 'lib/motion_blender/analyzer.rb', line 34 def parse file, backtrace parser = Parser.new file begin parser.parse rescue LoadError => err err.set_backtrace [parser.last_trace, *backtrace].compact raise err end parser.requires end |