Class: DependencyGrapher::Analyzer
- Inherits:
-
Object
- Object
- DependencyGrapher::Analyzer
- Defined in:
- lib/dependency_grapher/analyzer.rb
Instance Attribute Summary collapse
-
#dependencies ⇒ Object
Returns the value of attribute dependencies.
Instance Method Summary collapse
-
#initialize(dependencies = nil) ⇒ Analyzer
constructor
A new instance of Analyzer.
- #load_dependencies(dependencies) ⇒ Object
- #set_dependency_flags ⇒ Object
-
#set_method_types ⇒ Object
OPTIMIZE.
Constructor Details
#initialize(dependencies = nil) ⇒ Analyzer
Returns a new instance of Analyzer.
7 8 9 |
# File 'lib/dependency_grapher/analyzer.rb', line 7 def initialize(dependencies = nil) @dependencies = dependencies end |
Instance Attribute Details
#dependencies ⇒ Object
Returns the value of attribute dependencies.
5 6 7 |
# File 'lib/dependency_grapher/analyzer.rb', line 5 def dependencies @dependencies end |
Instance Method Details
#load_dependencies(dependencies) ⇒ Object
11 12 13 |
# File 'lib/dependency_grapher/analyzer.rb', line 11 def load_dependencies(dependencies) @dependencies = dependencies end |
#set_dependency_flags ⇒ Object
15 16 17 18 19 20 21 |
# File 'lib/dependency_grapher/analyzer.rb', line 15 def set_dependency_flags @dependencies.each do |dep| if dep.receiver.types.include?(:framework) dep.flags << :violation unless dep.kaller.types.include?(:service) end end end |
#set_method_types ⇒ Object
OPTIMIZE
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/dependency_grapher/analyzer.rb', line 24 def set_method_types services = GetKnownClasses.call(:services) framework_roots = Set.new # Marks all receiver of service objects as :framework @dependencies.each do |dep| if services.include?(dep.kaller.root) dep.kaller.types << :service dep.receiver.types << :framework framework_roots << dep.receiver.root end end # Marks all methods with a root that is shared with # methods in the frameworks list as :framework @dependencies.each do |dep| if framework_roots.include?(dep.kaller.root) dep.kaller.types << :framework elsif framework_roots.include?(dep.receiver.root) dep.receiver.types << :framework end end end |