marmerdo 0.0.0 → 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 +4 -4
- data/.rubocop.yml +1 -0
- data/CHANGELOG.md +3 -1
- data/CODE_OF_CONDUCT.md +1 -1
- data/LICENSE.txt +1 -1
- data/README.md +2 -4
- data/lib/marmerdo/cli.rb +19 -3
- data/lib/marmerdo/error.rb +3 -0
- data/lib/marmerdo/markdown_parser.rb +15 -5
- data/lib/marmerdo/relationship.rb +2 -0
- data/lib/marmerdo/version.rb +1 -1
- data/lib/marmerdo.rb +0 -1
- data/marmerdo.gemspec +2 -0
- metadata +3 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8ce6cbcddd18a42bee1e2598c90df0afbf96e778d02339dfdd78673d38dc8089
|
4
|
+
data.tar.gz: 4d28c78b6f3795cf1d04f66d5d6f0087fb09a8597eab09fffbbffc6988d95c90
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 10f9f7c3c329f97182f170708280b48751114cb2c041b6b9ad0051618e15aa0c6c83b505b7365254536b97ee4d6c097978dfa8a759fa756d377ab62f7b44cca8
|
7
|
+
data.tar.gz: 956553af5976166cec1c91f5dd862d6b5e9b6c379f9b38d9e5b14e50acbd1e02af214a6c74c5ca3e109b4522683d24136be56a2bf184cace2a518479789fb53d
|
data/.rubocop.yml
CHANGED
data/CHANGELOG.md
CHANGED
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
|
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
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
|
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
|
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
|
-
|
6
|
-
|
7
|
-
|
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
|
@@ -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:
|
16
|
-
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 ||=
|
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
|
data/lib/marmerdo/version.rb
CHANGED
data/lib/marmerdo.rb
CHANGED
data/marmerdo.gemspec
CHANGED
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.
|
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:
|