Class: InteractorsMindmap::InteractorsNamesParser

Inherits:
Object
  • Object
show all
Defined in:
lib/interactors_mindmap/interactors_names_parser.rb

Overview

Parse interactor file names

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(files_path:) ⇒ InteractorsNamesParser

Returns a new instance of InteractorsNamesParser.



9
10
11
12
# File 'lib/interactors_mindmap/interactors_names_parser.rb', line 9

def initialize(files_path:)
  @files_path = files_path
  @inside_organize_block = false
end

Instance Attribute Details

#files_pathObject (readonly)

Returns the value of attribute files_path.



7
8
9
# File 'lib/interactors_mindmap/interactors_names_parser.rb', line 7

def files_path
  @files_path
end

#inside_organize_blockObject (readonly)

Returns the value of attribute inside_organize_block.



7
8
9
# File 'lib/interactors_mindmap/interactors_names_parser.rb', line 7

def inside_organize_block
  @inside_organize_block
end

Class Method Details

.perform(files_path:) ⇒ Object



14
15
16
# File 'lib/interactors_mindmap/interactors_names_parser.rb', line 14

def self.perform(files_path:)
  new(files_path:).perform
end

Instance Method Details

#performObject



18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/interactors_mindmap/interactors_names_parser.rb', line 18

def perform
  tree_node = InteractorsMindmap::TreeNode.new(root_data: "Interactors")

  Dir[files_path].each do |file|
    next unless proper_interactor_file_name?(file)

    processed_interactors_tree_node = process_interactors_file(file)

    tree_node.add_node_child(node: processed_interactors_tree_node.root)
  end

  tree_node.reorder_with_recursion!
  tree_node.to_formatted_array
end