interactors_mindmap 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 3c7908ea508ee698cac74eea78dc7e724ee9a7abd63cb404c2282f0781afdfb0
4
+ data.tar.gz: 1f164ee15df340156205a201a8fe3456ff1f5344f12f4c7a6e69d79383bb48a6
5
+ SHA512:
6
+ metadata.gz: 40a7b0e4c1fd15f02dcad44a5756d4549ade50f1b3f8aaa003c2baaa0438f6bbd35f6b9bd760837230e5f2b610d613c03ca9ea8a7cd4a4a6da29b8adbc1011d3
7
+ data.tar.gz: 999dac3e9b958dd441b43beead21fc7864413f72f0dbcc8be4806d0c0a3fb432cee11a32ed69d0ac7f4392ff7abdff91da718cfebc08ef29ab1749e374e6bf65
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
data/.rubocop.yml ADDED
@@ -0,0 +1,24 @@
1
+ AllCops:
2
+ TargetRubyVersion: 2.6
3
+
4
+ Style/StringLiterals:
5
+ Enabled: true
6
+ EnforcedStyle: double_quotes
7
+
8
+ Style/StringLiteralsInInterpolation:
9
+ Enabled: true
10
+ EnforcedStyle: double_quotes
11
+
12
+ Layout/LineLength:
13
+ Max: 120
14
+
15
+ Layout/ArgumentAlignment:
16
+ Enabled: false
17
+
18
+ Metrics/MethodLength:
19
+ Enabled: true
20
+ Max: 35
21
+
22
+ Metrics/BlockLength:
23
+ Enabled: true
24
+ Max: 30
data/CHANGELOG.md ADDED
@@ -0,0 +1,5 @@
1
+ ## [Unreleased]
2
+
3
+ ## [0.1.0] - 2024-05-25
4
+
5
+ - Initial release
@@ -0,0 +1,84 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ We as members, contributors, and leaders pledge to make participation in our community a harassment-free experience for everyone, regardless of age, body size, visible or invisible disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, religion, or sexual identity and orientation.
6
+
7
+ We pledge to act and interact in ways that contribute to an open, welcoming, diverse, inclusive, and healthy community.
8
+
9
+ ## Our Standards
10
+
11
+ Examples of behavior that contributes to a positive environment for our community include:
12
+
13
+ * Demonstrating empathy and kindness toward other people
14
+ * Being respectful of differing opinions, viewpoints, and experiences
15
+ * Giving and gracefully accepting constructive feedback
16
+ * Accepting responsibility and apologizing to those affected by our mistakes, and learning from the experience
17
+ * Focusing on what is best not just for us as individuals, but for the overall community
18
+
19
+ Examples of unacceptable behavior include:
20
+
21
+ * The use of sexualized language or imagery, and sexual attention or
22
+ advances of any kind
23
+ * Trolling, insulting or derogatory comments, and personal or political attacks
24
+ * Public or private harassment
25
+ * Publishing others' private information, such as a physical or email
26
+ address, without their explicit permission
27
+ * Other conduct which could reasonably be considered inappropriate in a
28
+ professional setting
29
+
30
+ ## Enforcement Responsibilities
31
+
32
+ Community leaders are responsible for clarifying and enforcing our standards of acceptable behavior and will take appropriate and fair corrective action in response to any behavior that they deem inappropriate, threatening, offensive, or harmful.
33
+
34
+ Community leaders have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, and will communicate reasons for moderation decisions when appropriate.
35
+
36
+ ## Scope
37
+
38
+ This Code of Conduct applies within all community spaces, and also applies when an individual is officially representing the community in public spaces. Examples of representing our community include using an official e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event.
39
+
40
+ ## Enforcement
41
+
42
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the community leaders responsible for enforcement at ttincho77@gmail.com. All complaints will be reviewed and investigated promptly and fairly.
43
+
44
+ All community leaders are obligated to respect the privacy and security of the reporter of any incident.
45
+
46
+ ## Enforcement Guidelines
47
+
48
+ Community leaders will follow these Community Impact Guidelines in determining the consequences for any action they deem in violation of this Code of Conduct:
49
+
50
+ ### 1. Correction
51
+
52
+ **Community Impact**: Use of inappropriate language or other behavior deemed unprofessional or unwelcome in the community.
53
+
54
+ **Consequence**: A private, written warning from community leaders, providing clarity around the nature of the violation and an explanation of why the behavior was inappropriate. A public apology may be requested.
55
+
56
+ ### 2. Warning
57
+
58
+ **Community Impact**: A violation through a single incident or series of actions.
59
+
60
+ **Consequence**: A warning with consequences for continued behavior. No interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, for a specified period of time. This includes avoiding interactions in community spaces as well as external channels like social media. Violating these terms may lead to a temporary or permanent ban.
61
+
62
+ ### 3. Temporary Ban
63
+
64
+ **Community Impact**: A serious violation of community standards, including sustained inappropriate behavior.
65
+
66
+ **Consequence**: A temporary ban from any sort of interaction or public communication with the community for a specified period of time. No public or private interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, is allowed during this period. Violating these terms may lead to a permanent ban.
67
+
68
+ ### 4. Permanent Ban
69
+
70
+ **Community Impact**: Demonstrating a pattern of violation of community standards, including sustained inappropriate behavior, harassment of an individual, or aggression toward or disparagement of classes of individuals.
71
+
72
+ **Consequence**: A permanent ban from any sort of public interaction within the community.
73
+
74
+ ## Attribution
75
+
76
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 2.0,
77
+ available at https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
78
+
79
+ Community Impact Guidelines were inspired by [Mozilla's code of conduct enforcement ladder](https://github.com/mozilla/diversity).
80
+
81
+ [homepage]: https://www.contributor-covenant.org
82
+
83
+ For answers to common questions about this code of conduct, see the FAQ at
84
+ https://www.contributor-covenant.org/faq. Translations are available at https://www.contributor-covenant.org/translations.
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2024 martinnicolas
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,52 @@
1
+ # InteractorsMindmap
2
+
3
+ [![Tests](https://github.com/martinnicolas/interactors_mindmap/actions/workflows/main.yml/badge.svg)](https://github.com/martinnicolas/interactors_mindmap/actions/workflows/main.yml) [![Wercker](https://img.shields.io/github/license/mashape/apistatus.svg)](https://opensource.org/licenses/MIT) [![Contributor Covenant](https://img.shields.io/badge/Contributor%20Covenant-2.1-4baaaa.svg)](code_of_conduct.md)
4
+
5
+ This gem generates a mindmap chart to document your interactors flow on your Ruby on Rails application.
6
+
7
+ ![example](https://raw.githubusercontent.com/martinnicolas/interactors_mindmap/master/spec/fixtures/assets/test.png)
8
+
9
+ ## Installation
10
+
11
+ Install the gem and add to the application's Gemfile by executing:
12
+
13
+ $ bundle add interactors_mindmap
14
+
15
+ If bundler is not being used to manage dependencies, install the gem by executing:
16
+
17
+ $ gem install interactors_mindmap
18
+
19
+ ## Usage
20
+
21
+ Run `interactors_mindmap` on the root path of your RoR application to generate an interactors mindmap chart.
22
+
23
+ ### Running with options
24
+
25
+ By default running `interactors_mindmap`, without arguments, will show you the usage information message. You can use different options to run `interactors_mindmap` and generate only the files what you need:
26
+
27
+ - `interactors_mindmap --all`: This will generate the `interactors.md` and `interactors.html` files.
28
+ - `interactors_mindmap --md`: This will generate only the `interactors.md` file.
29
+ - `interactors_mindmap --html`: This will generate only the `interactors.html` file.
30
+ - `interactors_mindmap --version`: This will show the gem version.
31
+ - `interactors_mindmap --help`: This will show a usage information message.
32
+
33
+ This gem use [https://markmap.js.org/](https://markmap.js.org/) to generate your interactors mindmap chart.
34
+ Open `interactors.html` generated file to see your interactors mindmap chart on your browser. Alternatively, if you use Visual Studio Code IDE you can install [markmap](https://marketplace.visualstudio.com/items?itemName=gera2ld.markmap-vscodemd`) extension to open `interactors.md` generated file on the IDE.
35
+
36
+ ## Development
37
+
38
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
39
+
40
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
41
+
42
+ ## Contributing
43
+
44
+ Bug reports and pull requests are welcome on GitHub at https://github.com/martinnicolas/interactors_mindmap. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/martinnicolas/interactors_mindmap/blob/master/CODE_OF_CONDUCT.md).
45
+
46
+ ## License
47
+
48
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
49
+
50
+ ## Code of Conduct
51
+
52
+ Everyone interacting in the InteractorsMindmap project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/martinnicolas/interactors_mindmap/blob/master/CODE_OF_CONDUCT.md).
data/Rakefile ADDED
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "bundler/gem_tasks"
4
+ require "rspec/core/rake_task"
5
+
6
+ RSpec::Core::RakeTask.new(:spec)
7
+
8
+ require "rubocop/rake_task"
9
+
10
+ RuboCop::RakeTask.new
11
+
12
+ task default: %i[spec rubocop]
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require_relative "../lib/interactors_mindmap"
5
+
6
+ ARGV << "--help" if ARGV.empty?
7
+
8
+ InteractorsMindmap::Cli.new(ARGV).run
@@ -0,0 +1,65 @@
1
+ # frozen_string_literal: true
2
+
3
+ # InteractorsMindmap module
4
+ module InteractorsMindmap
5
+ # Command line interface
6
+ class Cli
7
+ HELP_TEXT = <<~HELP_TEXT
8
+ Usage:
9
+ interactors_mindmap [options]
10
+ Options:
11
+ --all # Generate md and html file
12
+ --md # Generate md file
13
+ --html # Generate html file
14
+ --help # Show this message
15
+ HELP_TEXT
16
+
17
+ attr_reader :argv
18
+
19
+ def initialize(argv)
20
+ @argv = argv
21
+ end
22
+
23
+ def run
24
+ first_argument = argv.first
25
+ case first_argument
26
+ when "--all"
27
+ generate_all_docs
28
+ when "--md"
29
+ generate_md_doc
30
+ when "--html"
31
+ generate_html_doc
32
+ when "--help"
33
+ help
34
+ when "--version"
35
+ version
36
+ else
37
+ help
38
+ end
39
+ end
40
+
41
+ private
42
+
43
+ def generate_all_docs
44
+ InteractorsMindmap.generate_docs
45
+ end
46
+
47
+ def generate_md_doc
48
+ interactor_names = InteractorsMindmap.interactor_names_from_files_on_path
49
+ InteractorsMindmap.generate_md_file(interactor_names)
50
+ end
51
+
52
+ def generate_html_doc
53
+ interactor_names = InteractorsMindmap.interactor_names_from_files_on_path
54
+ InteractorsMindmap.generate_html_file(interactor_names)
55
+ end
56
+
57
+ def help
58
+ puts HELP_TEXT
59
+ end
60
+
61
+ def version
62
+ puts InteractorsMindmap::VERSION
63
+ end
64
+ end
65
+ end
@@ -0,0 +1,81 @@
1
+ # frozen_string_literal: true
2
+
3
+ # InteractorsMindmap module
4
+ module InteractorsMindmap
5
+ # Generate doc files
6
+ class DocFilesGenerator
7
+ HTML_FILE_NAME = "interactors.html"
8
+ MD_FILE_NAME = "interactors.md"
9
+
10
+ attr_reader :interactor_names
11
+
12
+ def initialize(interactor_names:)
13
+ @interactor_names = interactor_names
14
+ end
15
+
16
+ def self.generate_md_file(interactor_names:)
17
+ new(interactor_names: interactor_names).generate_md_file
18
+ end
19
+
20
+ def self.generate_html_file(interactor_names:)
21
+ new(interactor_names: interactor_names).generate_html_file
22
+ end
23
+
24
+ def generate_md_file
25
+ magic_comments = <<~COMMENTS
26
+ ---
27
+ markmap:
28
+ initialExpandLevel: 6
29
+ colorFreezeLevel: 2
30
+ ---
31
+
32
+ COMMENTS
33
+
34
+ File.write(MD_FILE_NAME, magic_comments)
35
+
36
+ interactor_names.each do |interactor_name|
37
+ File.open(MD_FILE_NAME, "a") { |f| f.write "#{interactor_name}\n" }
38
+ end
39
+ end
40
+
41
+ def generate_html_file
42
+ page = <<~HTML
43
+ <!DOCTYPE html>
44
+ <html lang="en">
45
+ <head>
46
+ <meta charset="UTF-8" />
47
+ <meta http-equiv="X-UA-Compatible" content="IE=edge" />
48
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
49
+ <title>InteractorsMindmap</title>
50
+ <style>
51
+ svg.markmap {
52
+ width: 100%;
53
+ height: 100vh;
54
+ }
55
+ body {
56
+ background-color: #181818;
57
+ color: #FFFFFF;
58
+ }
59
+ </style>
60
+ <script src="https://cdn.jsdelivr.net/npm/markmap-autoloader@0.16"></script>
61
+ </head>
62
+ <body>
63
+ <div class="markmap">
64
+ <script type="text/template">
65
+ ---
66
+ markmap:
67
+ initialExpandLevel: 6
68
+ colorFreezeLevel: 2
69
+ ---
70
+
71
+ #{interactor_names.join("\n ")}
72
+ </script>
73
+ </div>
74
+ </body>
75
+ </html>
76
+ HTML
77
+
78
+ File.open(HTML_FILE_NAME, "w") { |f| f.write page }
79
+ end
80
+ end
81
+ end
@@ -0,0 +1,84 @@
1
+ # frozen_string_literal: true
2
+
3
+ # InteractorsMindmap module
4
+ module InteractorsMindmap
5
+ # Parse interactor file names
6
+ class InteractorsNamesParser
7
+ attr_reader :files_path, :inside_organize_block
8
+
9
+ def initialize(files_path:)
10
+ @files_path = files_path
11
+ @inside_organize_block = false
12
+ end
13
+
14
+ def self.perform(files_path:)
15
+ new(files_path: files_path).perform
16
+ end
17
+
18
+ def perform
19
+ tree_node = InteractorsMindmap::TreeNode.new(root_data: "Interactors")
20
+
21
+ Dir[files_path].sort.each do |file|
22
+ processed_interactors_tree_node = process_interactors_file(file)
23
+
24
+ tree_node.add_node_child(node: processed_interactors_tree_node.root)
25
+ end
26
+
27
+ tree_node.reorder_with_recursion!
28
+ tree_node.to_formatted_array
29
+ end
30
+
31
+ private
32
+
33
+ def process_interactors_file(file)
34
+ tree_node = InteractorsMindmap::TreeNode.new(root_data: interactor_class_name_from_file(file))
35
+
36
+ file_content = File.read(file)
37
+
38
+ file_content.each_line do |line|
39
+ if first_line_in_organize_block?(line)
40
+ interactor_names = interactor_names_in_first_line_organize_block(line)
41
+ interactor_names.each do |interactor_name|
42
+ tree_node.add_child(child_data: interactor_name)
43
+ end
44
+ end
45
+
46
+ next unless line_inside_organize_block?(line)
47
+
48
+ interactor_names = interactor_name_in_organize_block(line)
49
+ interactor_names.each do |interactor_name|
50
+ tree_node.add_child(child_data: interactor_name)
51
+ end
52
+ end
53
+
54
+ reset_inside_organize_block
55
+ tree_node
56
+ end
57
+
58
+ def interactor_class_name_from_file(file)
59
+ filename = file.split("/").last
60
+ name_without_extension = filename.split(".").first
61
+ name_without_extension.split("_").collect!(&:capitalize).join
62
+ end
63
+
64
+ def first_line_in_organize_block?(line)
65
+ @inside_organize_block = true if line =~ /^\s{2}[^\s]/ && line.strip.start_with?("organize")
66
+ end
67
+
68
+ def line_inside_organize_block?(line)
69
+ line =~ /^\s{4}[^\s]/ && inside_organize_block
70
+ end
71
+
72
+ def interactor_names_in_first_line_organize_block(line)
73
+ line.strip.split(/[^[[:word:]!:]]+/).drop(1)
74
+ end
75
+
76
+ def interactor_name_in_organize_block(line)
77
+ line.strip.split(/[^[[:word:]!:]]+/)
78
+ end
79
+
80
+ def reset_inside_organize_block
81
+ @inside_organize_block = false
82
+ end
83
+ end
84
+ end
@@ -0,0 +1,164 @@
1
+ # frozen_string_literal: true
2
+
3
+ # InteractorsMindmap module
4
+ module InteractorsMindmap
5
+ # Tree node data structure to manage data
6
+ class TreeNode
7
+ attr_reader :root
8
+
9
+ def initialize(root_data:)
10
+ @root = TreeNode::Node.new(data: root_data)
11
+ end
12
+
13
+ def add_child(child_data:, parent: nil)
14
+ if parent.nil?
15
+ root.add_child(child_data: child_data)
16
+ else
17
+ parent.add_child(child_data: child_data)
18
+ end
19
+ end
20
+
21
+ def add_node_child(node:, parent: nil)
22
+ if parent.nil?
23
+ root.add_node_child(node: node)
24
+ else
25
+ parent.add_node_child(node: node)
26
+ end
27
+ end
28
+
29
+ def search_node(data:)
30
+ root.search_node(data: data)
31
+ end
32
+
33
+ def reorder_with_recursion!
34
+ root.children.each do |child|
35
+ found_nodes = search_node(data: child.data)
36
+ found_children_nodes = found_nodes.select { |node| node.level > child.level }
37
+ found_children_nodes.map { |child_node| child_node.replace_with(node: child) }
38
+ end
39
+ end
40
+
41
+ def to_formatted_array(node: root)
42
+ array = []
43
+
44
+ array << node.formatted_data
45
+
46
+ if node.children.any?
47
+ node.children.each do |child|
48
+ array << to_formatted_array(node: child)
49
+ end
50
+ end
51
+
52
+ array.flatten
53
+ end
54
+
55
+ # Node data structure to manage data
56
+ class Node
57
+ attr_reader :data
58
+ attr_accessor :children, :level, :parent
59
+
60
+ def initialize(data:, parent: nil)
61
+ @data = data
62
+ @parent = parent
63
+ @children = []
64
+
65
+ calculate_level
66
+ end
67
+
68
+ def add_child(child_data:)
69
+ node = TreeNode::Node.new(data: child_data, parent: self)
70
+
71
+ @children << node
72
+ end
73
+
74
+ def add_node_child(node:)
75
+ clon = node.clone_node
76
+
77
+ @children << clon
78
+
79
+ clon.parent = self
80
+ clon.recalculate_level
81
+ end
82
+
83
+ def children_data
84
+ children.map(&:data)
85
+ end
86
+
87
+ def children_formatted_data
88
+ children.map(&:formatted_data)
89
+ end
90
+
91
+ def root?
92
+ parent.nil?
93
+ end
94
+
95
+ def formatted_data
96
+ data_with_space = " #{data}"
97
+ data_with_space.rjust(data_with_space.length + level, "#")
98
+ end
99
+
100
+ def replace_with(node:)
101
+ "Cant replace root_node" if root?
102
+
103
+ index = parent.children.find_index(self)
104
+ clon = node.clone_node
105
+ clon.parent = parent
106
+ parent.children[index] = clon
107
+ clon.recalculate_level
108
+ end
109
+
110
+ def recalculate_level
111
+ calculate_level
112
+
113
+ return unless children.any?
114
+
115
+ children.map(&:recalculate_level)
116
+ end
117
+
118
+ def search_node(data:)
119
+ nodes = []
120
+
121
+ if children.any?
122
+ children.each do |child|
123
+ nodes << child.search_node(data: data)
124
+ end
125
+ elsif self.data == data
126
+ nodes << self
127
+ end
128
+
129
+ nodes.flatten
130
+ end
131
+
132
+ def clone_node
133
+ clon = clone
134
+
135
+ if children.any?
136
+ children_clones = []
137
+
138
+ children.each do |child|
139
+ child.parent = clon
140
+ children_clones << child.clone_node
141
+ end
142
+
143
+ clon.children = children_clones
144
+ end
145
+
146
+ clon
147
+ end
148
+
149
+ private
150
+
151
+ def calculate_level
152
+ calculated_level = 1
153
+
154
+ node_parent = parent
155
+ until root? || node_parent.nil?
156
+ node_parent = node_parent.parent
157
+ calculated_level += 1
158
+ end
159
+
160
+ @level = calculated_level
161
+ end
162
+ end
163
+ end
164
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module InteractorsMindmap
4
+ VERSION = "0.1.0"
5
+ end
@@ -0,0 +1,52 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "interactors_mindmap/version"
4
+ require_relative "interactors_mindmap/interactors_names_parser"
5
+ require_relative "interactors_mindmap/doc_files_generator"
6
+ require_relative "interactors_mindmap/cli"
7
+ require_relative "interactors_mindmap/tree_node"
8
+
9
+ # Module to parse file names and generate interactors docs
10
+ module InteractorsMindmap
11
+ INTERACTORS_FILES_PATH = "**/app/interactors/*.rb"
12
+ NO_INTERACTORS_FOUND_MESSAGE = "No interactors found!"
13
+ MD_FILE_GENERATED_MESSAGE = "Interactors .md file successfully generated!"
14
+ HTML_FILE_GENERATED_MESSAGE = "Interactors .html file successfully generated!"
15
+
16
+ def self.generate_docs(interactors_files_path = INTERACTORS_FILES_PATH)
17
+ interactor_names = interactor_names_from_files_on_path(interactors_files_path)
18
+
19
+ if interactor_names.one?
20
+ puts NO_INTERACTORS_FOUND_MESSAGE
21
+ return
22
+ end
23
+ generate_md_file(interactor_names)
24
+ generate_html_file(interactor_names)
25
+ end
26
+
27
+ def self.interactor_names_from_files_on_path(interactors_files_path = INTERACTORS_FILES_PATH)
28
+ InteractorsMindmap::InteractorsNamesParser.perform(files_path: interactors_files_path)
29
+ end
30
+
31
+ def self.generate_md_file(interactor_names)
32
+ if interactor_names.one?
33
+ puts NO_INTERACTORS_FOUND_MESSAGE
34
+ return
35
+ end
36
+
37
+ InteractorsMindmap::DocFilesGenerator.generate_md_file(interactor_names: interactor_names)
38
+
39
+ puts MD_FILE_GENERATED_MESSAGE
40
+ end
41
+
42
+ def self.generate_html_file(interactor_names)
43
+ if interactor_names.one?
44
+ puts NO_INTERACTORS_FOUND_MESSAGE
45
+ return
46
+ end
47
+
48
+ InteractorsMindmap::DocFilesGenerator.generate_html_file(interactor_names: interactor_names)
49
+
50
+ puts HTML_FILE_GENERATED_MESSAGE
51
+ end
52
+ end
@@ -0,0 +1,4 @@
1
+ module InteractorsMindmap
2
+ VERSION: String
3
+ # See the writing guide of rbs: https://github.com/ruby/rbs#guides
4
+ end
metadata ADDED
@@ -0,0 +1,78 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: interactors_mindmap
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - martinnicolas
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2024-06-16 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: simplecov
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ description: Generate mindmap chart for Interactors.
28
+ email:
29
+ - ttincho77@gmail.com
30
+ executables:
31
+ - interactors_mindmap
32
+ extensions: []
33
+ extra_rdoc_files: []
34
+ files:
35
+ - ".rspec"
36
+ - ".rubocop.yml"
37
+ - CHANGELOG.md
38
+ - CODE_OF_CONDUCT.md
39
+ - LICENSE.txt
40
+ - README.md
41
+ - Rakefile
42
+ - exe/interactors_mindmap
43
+ - lib/interactors_mindmap.rb
44
+ - lib/interactors_mindmap/cli.rb
45
+ - lib/interactors_mindmap/doc_files_generator.rb
46
+ - lib/interactors_mindmap/interactors_names_parser.rb
47
+ - lib/interactors_mindmap/tree_node.rb
48
+ - lib/interactors_mindmap/version.rb
49
+ - sig/interactors_mindmap.rbs
50
+ homepage: https://github.com/martinnicolas/interactors_mindmap
51
+ licenses:
52
+ - MIT
53
+ metadata:
54
+ allowed_push_host: https://rubygems.org
55
+ homepage_uri: https://github.com/martinnicolas/interactors_mindmap
56
+ source_code_uri: https://github.com/martinnicolas/interactors_mindmap
57
+ changelog_uri: https://github.com/martinnicolas/interactors_mindmap/CHANGELOG.md
58
+ bug_tracker_uri: https://github.com/martinnicolas/interactors_mindmap/issues
59
+ post_install_message:
60
+ rdoc_options: []
61
+ require_paths:
62
+ - lib
63
+ required_ruby_version: !ruby/object:Gem::Requirement
64
+ requirements:
65
+ - - ">="
66
+ - !ruby/object:Gem::Version
67
+ version: 2.6.0
68
+ required_rubygems_version: !ruby/object:Gem::Requirement
69
+ requirements:
70
+ - - ">="
71
+ - !ruby/object:Gem::Version
72
+ version: '0'
73
+ requirements: []
74
+ rubygems_version: 3.5.3
75
+ signing_key:
76
+ specification_version: 4
77
+ summary: Mindmap chart for Interactors.
78
+ test_files: []