Class: MendixBridge::DependencyIndex
- Inherits:
-
Object
- Object
- MendixBridge::DependencyIndex
- Defined in:
- lib/mendix_bridge/dependency_index.rb
Defined Under Namespace
Classes: Edge
Constant Summary collapse
- UNQUALIFIED_REFERENCE_KEYS =
%w[ included_in_user_roles manageable_roles ].freeze
- KIND_KEYS =
{ "calls" => "call", "microflow_calls" => "microflow_call", "nanoflow_calls" => "nanoflow_call", "javascript_action_calls" => "javascript_action_call", "page_links" => "page_link", "layout" => "layout", "structure" => "mapping_structure", "generalization" => "generalization", "from" => "association_source", "to" => "association_target", "execute_roles" => "execute_role", "view_roles" => "view_role", "module_roles" => "module_role", "role" => "security_role", "home_page" => "navigation_home", "login_page" => "navigation_login", "not_found_page" => "navigation_not_found", "target" => "target", "type" => "type_reference" }.freeze
Instance Attribute Summary collapse
-
#edges ⇒ Object
readonly
Returns the value of attribute edges.
Class Method Summary collapse
Instance Method Summary collapse
- #callees(name, transitive: false) ⇒ Object
- #callers(name, transitive: false) ⇒ Object
- #dependencies(name, transitive: false) ⇒ Object
- #dependents(name, transitive: false) ⇒ Object
- #impact(name) ⇒ Object
-
#initialize(inventory, edges: nil) ⇒ DependencyIndex
constructor
A new instance of DependencyIndex.
- #to_h ⇒ Object
Constructor Details
#initialize(inventory, edges: nil) ⇒ DependencyIndex
Returns a new instance of DependencyIndex.
52 53 54 55 56 57 |
# File 'lib/mendix_bridge/dependency_index.rb', line 52 def initialize(inventory, edges: nil) @inventory = inventory @names = inventory.elements.filter_map(&:qualified_name).to_set @qualified_names = @names.select { |name| name.include?(".") }.to_set @edges = (edges || build_edges).freeze end |
Instance Attribute Details
#edges ⇒ Object (readonly)
Returns the value of attribute edges.
37 38 39 |
# File 'lib/mendix_bridge/dependency_index.rb', line 37 def edges @edges end |
Class Method Details
.load(path, inventory:) ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/mendix_bridge/dependency_index.rb', line 39 def self.load(path, inventory:) data = JSON.parse(File.read(path)) edges = data.fetch("edges").map do |edge| Edge.new( from: edge.fetch("from"), to: edge.fetch("to"), kind: edge.fetch("kind"), path: edge.fetch("path") ) end new(inventory, edges:) end |
Instance Method Details
#callees(name, transitive: false) ⇒ Object
74 75 76 77 78 79 |
# File 'lib/mendix_bridge/dependency_index.rb', line 74 def callees(name, transitive: false) select_edges( dependencies(name, transitive:), %w[call microflow_call nanoflow_call javascript_action_call] ) end |
#callers(name, transitive: false) ⇒ Object
67 68 69 70 71 72 |
# File 'lib/mendix_bridge/dependency_index.rb', line 67 def callers(name, transitive: false) select_edges( dependents(name, transitive:), %w[call microflow_call nanoflow_call javascript_action_call] ) end |
#dependencies(name, transitive: false) ⇒ Object
59 60 61 |
# File 'lib/mendix_bridge/dependency_index.rb', line 59 def dependencies(name, transitive: false) traverse(name, direction: :forward, transitive:) end |
#dependents(name, transitive: false) ⇒ Object
63 64 65 |
# File 'lib/mendix_bridge/dependency_index.rb', line 63 def dependents(name, transitive: false) traverse(name, direction: :reverse, transitive:) end |
#impact(name) ⇒ Object
81 82 83 |
# File 'lib/mendix_bridge/dependency_index.rb', line 81 def impact(name) dependents(name, transitive: true) end |
#to_h ⇒ Object
85 86 87 88 89 90 91 |
# File 'lib/mendix_bridge/dependency_index.rb', line 85 def to_h { schema_version: 1, nodes: @names.length, edges: edges.map(&:to_h) } end |