marmerdo 0.2.1 → 0.2.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +8 -0
- data/lib/marmerdo/cli.rb +8 -1
- data/lib/marmerdo/domain_diagram_generator.rb +5 -2
- data/lib/marmerdo/node.rb +4 -1
- data/lib/marmerdo/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2d7649f8c1f60bb395a64d723958f4a9aea06777c990d7ddf88e4b54e40179a6
|
4
|
+
data.tar.gz: 804cf7ade037d0f593b9182392c3255755d31c20872de6ab48792715023633ac
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 185cdb858ff71ee8f7432038edb3ae849ae6e26fdef88e8edd03a57408cfcfb6b59b959b2954a213eaf23e37f81e9d73391da1d0923d5eca5e2e9772241f0ad9
|
7
|
+
data.tar.gz: 5cc3d17fb9d9db7ff9f045bdbc63b10c210b3140c13dbd2eceadb4a812af0595134c6058456f1c6b430dfa40cfd94eb9c314cc9a87b08d407abed9e96448bda6
|
data/CHANGELOG.md
CHANGED
data/lib/marmerdo/cli.rb
CHANGED
@@ -9,9 +9,12 @@ module Marmerdo
|
|
9
9
|
class ArgumentError < Error; end
|
10
10
|
|
11
11
|
desc "generate SOURCE_GLOB OUTPUT_PATH", "Generate a mermaid diagram from markdown files"
|
12
|
+
option :link_extension, type: :boolean, default: true, desc: "Whether to write the file extension to the link."
|
12
13
|
def generate(source_glob, output_path)
|
13
14
|
raise ArgumentError, "You must provide a source glob and an output file" if source_glob.nil? || output_path.nil?
|
14
15
|
|
16
|
+
enable_link_extension = options[:link_extension]
|
17
|
+
|
15
18
|
nodes = Dir[source_glob].map do |source_path|
|
16
19
|
content = File.read(source_path)
|
17
20
|
node = Marmerdo::MarkdownParser.new(source_path, content).parse
|
@@ -23,7 +26,11 @@ module Marmerdo
|
|
23
26
|
|
24
27
|
puts "Writing domain diagram to #{output_path}."
|
25
28
|
|
26
|
-
domain_diagram = Marmerdo::DomainDiagramGenerator.new(
|
29
|
+
domain_diagram = Marmerdo::DomainDiagramGenerator.new(
|
30
|
+
output_path: output_path,
|
31
|
+
nodes: nodes,
|
32
|
+
enable_link_extension: enable_link_extension
|
33
|
+
).generate
|
27
34
|
output_content = OutputGenerator.new(output_path, domain_diagram).generate
|
28
35
|
File.write(output_path, output_content)
|
29
36
|
|
@@ -1,14 +1,17 @@
|
|
1
1
|
module Marmerdo
|
2
2
|
class DomainDiagramGenerator
|
3
|
-
def initialize(output_path:, nodes:)
|
3
|
+
def initialize(output_path:, nodes:, enable_link_extension:)
|
4
4
|
@output_path = output_path
|
5
5
|
@nodes = nodes
|
6
|
+
@enable_link_extension = enable_link_extension
|
6
7
|
end
|
7
8
|
|
8
9
|
# @return [String] mermaid class diagram
|
9
10
|
def generate
|
10
11
|
classes = @nodes.map(&:to_mermaid_line)
|
11
|
-
links = @nodes.map
|
12
|
+
links = @nodes.map do |node|
|
13
|
+
node.generate_mermaid_link(@output_path, enable_link_extension: @enable_link_extension)
|
14
|
+
end
|
12
15
|
|
13
16
|
relationships = @nodes.flat_map do |node|
|
14
17
|
node.relationships.map do |relationship|
|
data/lib/marmerdo/node.rb
CHANGED
@@ -18,9 +18,12 @@ module Marmerdo
|
|
18
18
|
"class #{name}"
|
19
19
|
end
|
20
20
|
|
21
|
-
def generate_mermaid_link(output_path)
|
21
|
+
def generate_mermaid_link(output_path, enable_link_extension:)
|
22
|
+
path = enable_link_extension ? @path : Pathname.new(@path).sub_ext("").to_s
|
23
|
+
|
22
24
|
output_dir = Pathname.new(output_path).dirname
|
23
25
|
relative_path = Pathname.new(path).relative_path_from(output_dir).to_s
|
26
|
+
relative_path = "./#{relative_path}" unless relative_path.start_with?("../")
|
24
27
|
"link #{name} \"#{relative_path}\""
|
25
28
|
end
|
26
29
|
end
|
data/lib/marmerdo/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: marmerdo
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- sijiaoh
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-12-
|
11
|
+
date: 2023-12-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: front_matter_parser
|