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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 69476fe32f74a4b4a7081f5bf65ce187026b8e3afa257ad7b0c5b3622153bba4
4
- data.tar.gz: 7a0c231bdd97fb8a7c68e003d618421b8b5839ddce6cd8672e1f895478f0dd74
3
+ metadata.gz: 2d7649f8c1f60bb395a64d723958f4a9aea06777c990d7ddf88e4b54e40179a6
4
+ data.tar.gz: 804cf7ade037d0f593b9182392c3255755d31c20872de6ab48792715023633ac
5
5
  SHA512:
6
- metadata.gz: '08cb33a93c568b1e799aed8824a371d5716b521a6e8437727a304f59f1b806a1b6d56a7bef96cee1d6344fe8558b0db6fc86a5dd7fc002ce764ea54e48b5f9e9'
7
- data.tar.gz: 24c9314b548c06974be900afbc46d0e7ab2a98c9a01b36dd936fddff2a676c87f64da9e80a0a87d1a98a153973b504a9bf98fb74eb1374f1dfc49da7c4550aae
6
+ metadata.gz: 185cdb858ff71ee8f7432038edb3ae849ae6e26fdef88e8edd03a57408cfcfb6b59b959b2954a213eaf23e37f81e9d73391da1d0923d5eca5e2e9772241f0ad9
7
+ data.tar.gz: 5cc3d17fb9d9db7ff9f045bdbc63b10c210b3140c13dbd2eceadb4a812af0595134c6058456f1c6b430dfa40cfd94eb9c314cc9a87b08d407abed9e96448bda6
data/CHANGELOG.md CHANGED
@@ -1,3 +1,11 @@
1
+ ## [0.2.3] - 2023-12-25
2
+
3
+ Add link_extension option.
4
+
5
+ ## [0.2.2] - 2023-12-20
6
+
7
+ - 相対リンクが`./`から始まらないことがある問題を修正。
8
+
1
9
  ## [0.2.1] - 2023-12-20
2
10
 
3
11
  - 複数の関連先をサポート。
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(output_path: output_path, nodes: nodes).generate
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 { |node| node.generate_mermaid_link(@output_path) }
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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Marmerdo
4
- VERSION = "0.2.1"
4
+ VERSION = "0.2.3"
5
5
  end
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.1
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-20 00:00:00.000000000 Z
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