mermaid 0.0.1 → 0.0.2

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.
Files changed (56) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +15 -0
  3. data/README.md +116 -12
  4. data/Rakefile +2 -2
  5. data/lib/mermaid/class_diagram_renderer.rb +45 -0
  6. data/lib/mermaid/element_renderers/edge_renderer.rb +19 -0
  7. data/lib/mermaid/element_renderers/node_renderer.rb +16 -0
  8. data/lib/mermaid/element_renderers/relationship_renderer.rb +24 -0
  9. data/lib/mermaid/element_renderers/slice_renderer.rb +16 -0
  10. data/lib/mermaid/element_renderers/state_renderer.rb +15 -0
  11. data/lib/mermaid/element_renderers/task_renderer.rb +15 -0
  12. data/lib/mermaid/element_renderers/transition_renderer.rb +17 -0
  13. data/lib/mermaid/flowchart_diagram_renderer.rb +23 -0
  14. data/lib/mermaid/gantt_diagram_renderer.rb +16 -0
  15. data/lib/mermaid/gitgraph_diagram_renderer.rb +113 -0
  16. data/lib/mermaid/pie_diagram_renderer.rb +16 -0
  17. data/lib/mermaid/state_diagram_renderer.rb +42 -0
  18. data/lib/mermaid/timeline_diagram_renderer.rb +29 -0
  19. data/lib/mermaid/version.rb +1 -1
  20. data/lib/mermaid.rb +20 -10
  21. data/sig/diagrams/base.rbs +8 -0
  22. data/sig/diagrams/class_diagram.rbs +18 -0
  23. data/sig/diagrams/elements/edge.rbs +16 -0
  24. data/sig/diagrams/elements/node.rbs +15 -0
  25. data/sig/diagrams/elements/relationship.rbs +17 -0
  26. data/sig/diagrams/elements/slice.rbs +16 -0
  27. data/sig/diagrams/elements/state.rbs +15 -0
  28. data/sig/diagrams/elements/task.rbs +17 -0
  29. data/sig/diagrams/elements/transition.rbs +16 -0
  30. data/sig/diagrams/flowchart_diagram.rbs +14 -0
  31. data/sig/diagrams/gantt_diagram.rbs +14 -0
  32. data/sig/diagrams/pie_diagram.rbs +14 -0
  33. data/sig/diagrams/state_diagram.rbs +18 -0
  34. data/sig/mermaid/base_diagram.rbs +31 -0
  35. data/sig/mermaid/state_diagram.rbs +26 -0
  36. metadata +168 -35
  37. data/lib/mermaid/base_diagram.rb +0 -13
  38. data/lib/mermaid/c4_diagram.rb +0 -9
  39. data/lib/mermaid/class_diagram.rb +0 -10
  40. data/lib/mermaid/er_diagram.rb +0 -9
  41. data/lib/mermaid/flowchart_diagram/link.rb +0 -46
  42. data/lib/mermaid/flowchart_diagram/node.rb +0 -36
  43. data/lib/mermaid/flowchart_diagram/parser.rb +0 -30
  44. data/lib/mermaid/flowchart_diagram.rb +0 -32
  45. data/lib/mermaid/gantt_diagram.rb +0 -9
  46. data/lib/mermaid/git_graph_diagram.rb +0 -9
  47. data/lib/mermaid/info_flow_diagram.rb +0 -9
  48. data/lib/mermaid/mindmap_diagram.rb +0 -9
  49. data/lib/mermaid/pie_diagram.rb +0 -9
  50. data/lib/mermaid/quadrant_diagram.rb +0 -10
  51. data/lib/mermaid/requirement_diagram.rb +0 -9
  52. data/lib/mermaid/sankey_diagram.rb +0 -9
  53. data/lib/mermaid/sequence_diagram.rb +0 -9
  54. data/lib/mermaid/state_diagram.rb +0 -9
  55. data/lib/mermaid/user_journey_diagram.rb +0 -10
  56. data/lib/mermaid/xy_diagram.rb +0 -10
@@ -1,30 +0,0 @@
1
- module Mermaid
2
- module FlowchartDiagram::Parser
3
- def self.included(base)
4
- base.extend(ClassMethods)
5
- end
6
-
7
- module ClassMethods
8
- def parse(input)
9
- lines = input.split("\n")
10
- _, direction = lines.shift.split
11
- nodes = []
12
- links = []
13
- lines.each do |line|
14
- if line =~ /^(\S+)(?:\[(.*)\]|\((.*)\)|\{(.*)\})/
15
- id = $1
16
- label = $2 || $3 || $4
17
- shape = $2 ? 'box' : $3 ? 'round' : 'decision'
18
- nodes << Node.new(id: id, label: label, shape: shape)
19
- elsif line =~ /^(\S+)\s+-->(?:\|(.*)\|\s+)?(\S+)/
20
- from = $1
21
- label = $2
22
- to = $3
23
- links << Link.new(from: from, to: to, label: label)
24
- end
25
- end
26
- new(id: 'parsed', direction: direction, nodes: nodes, links: links)
27
- end
28
- end
29
- end
30
- end
@@ -1,32 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Mermaid
4
- class FlowchartDiagram < BaseDiagram
5
- include Parser
6
- NAME = 'flowchart'
7
- Direction = Types::String.default('LR').enum('LR', 'RL', 'TB', 'BT')
8
- attribute :id, Types::String
9
- attribute :direction, Direction
10
- attribute :nodes, Types::Array.of(Node)
11
- attribute :links, Types::Array.of(Link)
12
-
13
- def generate
14
- diagram = "#{NAME} #{direction}\n"
15
- labeled_nodes = Set.new
16
- links.each do |link|
17
- from_node = nodes.find { |node| node.id == link.from }
18
- to_node = nodes.find { |node| node.id == link.to }
19
- from_node_already_labeled = !labeled_nodes.include?(from_node)
20
- to_node_already_labeled = !labeled_nodes.include?(to_node)
21
- diagram += " #{from_node.to_s(from_node_already_labeled)} -->#{link.label ? "|#{link.label}|" : ''} #{to_node.to_s(to_node_already_labeled)}\n"
22
- labeled_nodes << from_node if from_node.label
23
- labeled_nodes << to_node if to_node.label
24
- end
25
- diagram
26
- end
27
-
28
- def inspect
29
- "#<#{self.class.name}: Nodes: #{nodes.size}, Links: #{links.size}>"
30
- end
31
- end
32
- end
@@ -1,9 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Mermaid
4
- class GanttDiagram < BaseDiagram
5
- def initialize(*)
6
- raise NotImplementedError, "GanttDiagram is not implemented yet"
7
- end
8
- end
9
- end
@@ -1,9 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Mermaid
4
- class GitGraphDiagram < BaseDiagram
5
- def initialize(*)
6
- raise NotImplementedError, "GitGraphDiagram is not implemented yet"
7
- end
8
- end
9
- end
@@ -1,9 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Mermaid
4
- class InfoFlowDiagram < BaseDiagram
5
- def initialize(*)
6
- raise NotImplementedError, "InfoFlowDiagram is not implemented yet"
7
- end
8
- end
9
- end
@@ -1,9 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Mermaid
4
- class MindmapDiagram < BaseDiagram
5
- def initialize(*)
6
- raise NotImplementedError, "MindmapDiagram is not implemented yet"
7
- end
8
- end
9
- end
@@ -1,9 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Mermaid
4
- class PieDiagram < BaseDiagram
5
- def initialize(*)
6
- raise NotImplementedError, "PieDiagram is not implemented yet"
7
- end
8
- end
9
- end
@@ -1,10 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Mermaid
4
- class QuadrantDiagram < BaseDiagram
5
-
6
- def initialize(*)
7
- raise NotImplementedError, "QuadrantDiagram is not implemented yet"
8
- end
9
- end
10
- end
@@ -1,9 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Mermaid
4
- class RequirementDiagram < BaseDiagram
5
- def initialize(*)
6
- raise NotImplementedError, "RequirementDiagram is not implemented yet"
7
- end
8
- end
9
- end
@@ -1,9 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Mermaid
4
- class SankeyDiagram < BaseDiagram
5
- def initialize(*)
6
- raise NotImplementedError, "SankeyDiagram is not implemented yet"
7
- end
8
- end
9
- end
@@ -1,9 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Mermaid
4
- class SequenceDiagram < BaseDiagram
5
- def initialize(*)
6
- raise NotImplementedError, "SequenceDiagram is not implemented yet"
7
- end
8
- end
9
- end
@@ -1,9 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Mermaid
4
- class StateDiagram < BaseDiagram
5
- def initialize(*)
6
- raise NotImplementedError, "StateDiagram is not implemented yet"
7
- end
8
- end
9
- end
@@ -1,10 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Mermaid
4
- class UserJourneyDiagram < BaseDiagram
5
-
6
- def initialize(*)
7
- raise NotImplementedError, "UserJourneyDiagram is not implemented yet"
8
- end
9
- end
10
- end
@@ -1,10 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Mermaid
4
- class XYDiagram < BaseDiagram
5
-
6
- def initialize(*)
7
- raise NotImplementedError, "XYDiagram is not implemented yet"
8
- end
9
- end
10
- end