marmerdo 0.0.0 → 0.1.0

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: 5a85efc4c3e7d9abe175ad1ae273f069b58c0408484290794a3e48d710ab9b2c
4
- data.tar.gz: 0fe01c14fb23b07262b6263b3199efa10418a866b09a1e5ca7626d0381b644b4
3
+ metadata.gz: 8ce6cbcddd18a42bee1e2598c90df0afbf96e778d02339dfdd78673d38dc8089
4
+ data.tar.gz: 4d28c78b6f3795cf1d04f66d5d6f0087fb09a8597eab09fffbbffc6988d95c90
5
5
  SHA512:
6
- metadata.gz: 54e4fa9d7fdc2c383b74030f1a268ad9674fa8cd2182078e7878856665857a7c0a332b557d62980a8de9a17e251a96a8d7dae204b8122af9a7f9952830a561ad
7
- data.tar.gz: 0ab9af832c42fee5f0847195ce57595a171e257e8fd22505f46125531c64032c43ff3b1e189882ba2d6d7de0d8223e16aa5c2a24078816ddef22ab58523ddf42
6
+ metadata.gz: 10f9f7c3c329f97182f170708280b48751114cb2c041b6b9ad0051618e15aa0c6c83b505b7365254536b97ee4d6c097978dfa8a759fa756d377ab62f7b44cca8
7
+ data.tar.gz: 956553af5976166cec1c91f5dd862d6b5e9b6c379f9b38d9e5b14e50acbd1e02af214a6c74c5ca3e109b4522683d24136be56a2bf184cace2a518479789fb53d
data/.rubocop.yml CHANGED
@@ -1,5 +1,6 @@
1
1
  AllCops:
2
2
  TargetRubyVersion: 2.6
3
+ NewCops: enable
3
4
 
4
5
  Style/StringLiterals:
5
6
  Enabled: true
data/CHANGELOG.md CHANGED
@@ -1 +1,3 @@
1
- ## [Unreleased]
1
+ ## [0.1.0] - 2023-12-18
2
+
3
+ 最低限の機能を備えた初期リリース。
data/CODE_OF_CONDUCT.md CHANGED
@@ -39,7 +39,7 @@ This Code of Conduct applies within all community spaces, and also applies when
39
39
 
40
40
  ## Enforcement
41
41
 
42
- Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the community leaders responsible for enforcement at TODO: Write your email address. All complaints will be reviewed and investigated promptly and fairly.
42
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the community leaders responsible for enforcement at sijiaoh@outlook.com. All complaints will be reviewed and investigated promptly and fairly.
43
43
 
44
44
  All community leaders are obligated to respect the privacy and security of the reporter of any incident.
45
45
 
data/LICENSE.txt CHANGED
@@ -1,6 +1,6 @@
1
1
  The MIT License (MIT)
2
2
 
3
- Copyright (c) 2023 TODO: Write your name
3
+ Copyright (c) 2023 sijiaoh
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
data/README.md CHANGED
@@ -4,15 +4,13 @@
4
4
 
5
5
  ## Installation
6
6
 
7
- TODO: Replace `UPDATE_WITH_YOUR_GEM_NAME_PRIOR_TO_RELEASE_TO_RUBYGEMS_ORG` with your gem name right after releasing it to RubyGems.org. Please do not do it earlier due to security reasons. Alternatively, replace this section with instructions to install your gem from git if you don't plan to release to RubyGems.org.
8
-
9
7
  Install the gem and add to the application's Gemfile by executing:
10
8
 
11
- $ bundle add UPDATE_WITH_YOUR_GEM_NAME_PRIOR_TO_RELEASE_TO_RUBYGEMS_ORG
9
+ $ bundle add marmerdo
12
10
 
13
11
  If bundler is not being used to manage dependencies, install the gem by executing:
14
12
 
15
- $ gem install UPDATE_WITH_YOUR_GEM_NAME_PRIOR_TO_RELEASE_TO_RUBYGEMS_ORG
13
+ $ gem install marmerdo
16
14
 
17
15
  ## Usage
18
16
 
data/lib/marmerdo/cli.rb CHANGED
@@ -1,10 +1,26 @@
1
1
  require "thor"
2
+ require_relative "error"
3
+ require_relative "markdown_parser"
4
+ require_relative "domain_diagram_generator"
2
5
 
3
6
  module Marmerdo
4
7
  class Cli < Thor
5
- desc "generate", "Generate domain diagram from markdown docs."
6
- def generate
7
- puts "Hello World!"
8
+ class ArgumentError < Error; end
9
+
10
+ desc "generate SOURCE_GLOB OUTPUT", "Generate a mermaid diagram from markdown files"
11
+ def generate(source_glob, output)
12
+ raise ArgumentError, "You must provide a source glob and an output file" if source_glob.nil? || output.nil?
13
+
14
+ nodes = Dir[source_glob].map do |source_path|
15
+ puts "Parsing #{source_path}"
16
+ name = File.basename(source_path, ".*")
17
+ content = File.read(source_path)
18
+ Marmerdo::MarkdownParser.new(name, content).parse
19
+ end.compact
20
+
21
+ puts "Writing diagram to #{output}"
22
+ mermaid = Marmerdo::DomainDiagramGenerator.new(nodes).generate
23
+ File.write(output, mermaid)
8
24
  end
9
25
  end
10
26
  end
@@ -0,0 +1,3 @@
1
+ module Marmerdo
2
+ class Error < StandardError; end
3
+ end
@@ -9,23 +9,33 @@ module Marmerdo
9
9
  @content = content
10
10
  end
11
11
 
12
- # @return [Node]
12
+ # @return [Node, nil] the parsed node or nil if the file has no marmerdo front matter.
13
13
  def parse
14
+ return nil unless marmerdo_file?
15
+
14
16
  Node.new(
15
- name: front_matter["name"] || @name,
16
- namespace: front_matter["namespace"],
17
+ name: marmerdo_matter["name"] || @name,
18
+ namespace: marmerdo_matter["namespace"],
17
19
  relationships: relationships
18
20
  )
19
21
  end
20
22
 
21
23
  private
22
24
 
25
+ def marmerdo_file?
26
+ front_matter.key?("marmerdo")
27
+ end
28
+
23
29
  def front_matter
24
- @front_matter ||= FrontMatterParser::Parser.new(:md).call(@content).front_matter
30
+ @front_matter ||= FrontMatterParser::Parser.new(:md).call(@content).front_matter || {}
31
+ end
32
+
33
+ def marmerdo_matter
34
+ @marmerdo_matter ||= front_matter["marmerdo"] || {}
25
35
  end
26
36
 
27
37
  def relationships
28
- @relationships ||= front_matter.filter { |k, _| Relationship::TYPES.include?(k.to_sym) }.map do |type, to|
38
+ @relationships ||= marmerdo_matter.filter { |k| Relationship::TYPES.include?(k.to_sym) }.map do |type, to|
29
39
  Relationship.new(type: type, to: to)
30
40
  end
31
41
  end
@@ -1,3 +1,5 @@
1
+ require_relative "error"
2
+
1
3
  module Marmerdo
2
4
  class Relationship
3
5
  class UnknownRelationshipType < Error; end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Marmerdo
4
- VERSION = "0.0.0"
4
+ VERSION = "0.1.0"
5
5
  end
data/lib/marmerdo.rb CHANGED
@@ -4,6 +4,5 @@ require_relative "marmerdo/version"
4
4
  require_relative "marmerdo/cli"
5
5
 
6
6
  module Marmerdo
7
- class Error < StandardError; end
8
7
  # Your code goes here...
9
8
  end
data/marmerdo.gemspec CHANGED
@@ -36,4 +36,6 @@ Gem::Specification.new do |spec|
36
36
 
37
37
  # For more information and examples about making a new gem, check out our
38
38
  # guide at: https://bundler.io/guides/creating_gem.html
39
+
40
+ spec.metadata["rubygems_mfa_required"] = "true"
39
41
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: marmerdo
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.0
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - sijiaoh
@@ -58,6 +58,7 @@ files:
58
58
  - lib/marmerdo.rb
59
59
  - lib/marmerdo/cli.rb
60
60
  - lib/marmerdo/domain_diagram_generator.rb
61
+ - lib/marmerdo/error.rb
61
62
  - lib/marmerdo/markdown_parser.rb
62
63
  - lib/marmerdo/node.rb
63
64
  - lib/marmerdo/relationship.rb
@@ -71,6 +72,7 @@ metadata:
71
72
  homepage_uri: https://github.com/sijiaoh/marmerdo
72
73
  source_code_uri: https://github.com/sijiaoh/marmerdo
73
74
  changelog_uri: https://github.com/sijiaoh/marmerdo/blob/main/CHANGELOG.md
75
+ rubygems_mfa_required: 'true'
74
76
  post_install_message:
75
77
  rdoc_options: []
76
78
  require_paths: