diagram 0.2.1 → 0.3.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.
Files changed (50) hide show
  1. checksums.yaml +4 -4
  2. data/lib/diagrams/base.rb +246 -0
  3. data/lib/diagrams/class_diagram.rb +127 -2
  4. data/lib/diagrams/elements/class_entity.rb +28 -0
  5. data/lib/diagrams/elements/edge.rb +32 -0
  6. data/lib/diagrams/elements/event.rb +26 -0
  7. data/lib/diagrams/elements/node.rb +38 -0
  8. data/lib/diagrams/elements/relationship.rb +37 -0
  9. data/lib/diagrams/elements/slice.rb +27 -0
  10. data/lib/diagrams/elements/state.rb +28 -0
  11. data/lib/diagrams/elements/task.rb +27 -0
  12. data/lib/diagrams/elements/transition.rb +31 -0
  13. data/lib/diagrams/flowchart_diagram.rb +125 -4
  14. data/lib/diagrams/gantt_diagram.rb +97 -3
  15. data/lib/diagrams/pie_diagram.rb +111 -29
  16. data/lib/diagrams/state_diagram.rb +162 -4
  17. data/lib/diagrams/version.rb +1 -1
  18. data/lib/diagrams.rb +2 -2
  19. data/sig/diagrams/base.rbs +86 -0
  20. data/sig/diagrams/class_diagram.rbs +33 -0
  21. data/sig/diagrams/elements/class_entity.rbs +15 -0
  22. data/sig/diagrams/elements/edge.rbs +16 -0
  23. data/sig/diagrams/elements/event.rbs +14 -0
  24. data/sig/diagrams/elements/node.rbs +14 -0
  25. data/sig/diagrams/elements/relationship.rbs +16 -0
  26. data/sig/diagrams/elements/slice.rbs +14 -0
  27. data/sig/diagrams/elements/state.rbs +14 -0
  28. data/sig/diagrams/elements/task.rbs +16 -0
  29. data/sig/diagrams/elements/transition.rbs +15 -0
  30. data/sig/diagrams/elements/types.rbs +18 -0
  31. data/sig/diagrams/flowchart_diagram.rbs +32 -0
  32. data/sig/diagrams/gantt_diagram.rbs +29 -0
  33. data/sig/diagrams/pie_diagram.rbs +36 -0
  34. data/sig/diagrams/state_diagram.rbs +40 -0
  35. metadata +212 -22
  36. data/lib/diagrams/abstract_diagram.rb +0 -26
  37. data/lib/diagrams/class_diagram/class/field.rb +0 -15
  38. data/lib/diagrams/class_diagram/class/function/argument.rb +0 -14
  39. data/lib/diagrams/class_diagram/class/function.rb +0 -16
  40. data/lib/diagrams/class_diagram/class.rb +0 -12
  41. data/lib/diagrams/comparable.rb +0 -20
  42. data/lib/diagrams/flowchart_diagram/link.rb +0 -11
  43. data/lib/diagrams/flowchart_diagram/node.rb +0 -10
  44. data/lib/diagrams/gantt_diagram/section/task.rb +0 -13
  45. data/lib/diagrams/gantt_diagram/section.rb +0 -10
  46. data/lib/diagrams/pie_diagram/section.rb +0 -10
  47. data/lib/diagrams/plot.rb +0 -23
  48. data/lib/diagrams/state_diagram/event.rb +0 -10
  49. data/lib/diagrams/state_diagram/state.rb +0 -12
  50. data/lib/diagrams/state_diagram/transition.rb +0 -11
@@ -1,16 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Diagrams
4
- class ClassDiagram
5
- class Class
6
- class Function < Dry::Struct
7
- attribute :name, ClassDiagram::Types::String
8
- attribute :return_type, ClassDiagram::Types::String.optional.default('void')
9
- attribute :arguments, ClassDiagram::Types::Array.of(Argument)
10
- attribute :visibility,
11
- ClassDiagram::Types::String.optional.default('public')
12
- .constrained(format: /\A(public|private|protected)\z/)
13
- end
14
- end
15
- end
16
- end
@@ -1,12 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Diagrams
4
- class ClassDiagram
5
- class Class < Dry::Struct
6
- attribute :id, ClassDiagram::Types::String.constrained(format: /\A[a-zA-Z0-9_-]+\z/)
7
- attribute :label, ClassDiagram::Types::String.optional.default(nil)
8
- attribute :fields, ClassDiagram::Types::Array.of(Field)
9
- attribute :functions, ClassDiagram::Types::Array.of(Function)
10
- end
11
- end
12
- end
@@ -1,20 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Diagrams
4
- module Comparable
5
- def ==(other)
6
- other.class == self.class && other.state == state
7
- end
8
- alias eql? ==
9
-
10
- def hash
11
- state.hash
12
- end
13
-
14
- protected
15
-
16
- def state
17
- instance_variables.map { |name| instance_variable_get(name) }
18
- end
19
- end
20
- end
@@ -1,11 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Diagrams
4
- class FlowchartDiagram
5
- class Link < Dry::Struct
6
- attribute :from, FlowchartDiagram::Types::String
7
- attribute :to, FlowchartDiagram::Types::String
8
- attribute :label, FlowchartDiagram::Types::String.optional.default(nil)
9
- end
10
- end
11
- end
@@ -1,10 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Diagrams
4
- class FlowchartDiagram
5
- class Node < Dry::Struct
6
- attribute :id, FlowchartDiagram::Types::String
7
- attribute :label, FlowchartDiagram::Types::String
8
- end
9
- end
10
- end
@@ -1,13 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Diagrams
4
- class GanttDiagram
5
- class Section
6
- class Task < Dry::Struct
7
- attribute :name, GanttDiagram::Types::String
8
- attribute :start, GanttDiagram::Types::String
9
- attribute :end, GanttDiagram::Types::String
10
- end
11
- end
12
- end
13
- end
@@ -1,10 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Diagrams
4
- class GanttDiagram
5
- class Section < Dry::Struct
6
- attribute :name, GanttDiagram::Types::String
7
- attribute :tasks, GanttDiagram::Types::Array.of(Task)
8
- end
9
- end
10
- end
@@ -1,10 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Diagrams
4
- class PieDiagram
5
- class Section < Dry::Struct
6
- attribute :label, PieDiagram::Types::String.optional.default(nil)
7
- attribute :value, PieDiagram::Types::Coercible::Float.optional.default(0).constrained(gteq: 0)
8
- end
9
- end
10
- end
data/lib/diagrams/plot.rb DELETED
@@ -1,23 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Diagrams
4
- module Plot
5
- def self.included(base)
6
- base.extend(ClassMethods)
7
- end
8
-
9
- module ClassMethods
10
- def plottable?
11
- true
12
- end
13
- end
14
-
15
- def plottable?
16
- self.class.plottable?
17
- end
18
-
19
- def plot
20
- raise NotImplementedError
21
- end
22
- end
23
- end
@@ -1,10 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Diagrams
4
- class StateDiagram
5
- class Event < Dry::Struct
6
- attribute :id, StateDiagram::Types::String
7
- attribute :label, StateDiagram::Types::String.optional.default(nil)
8
- end
9
- end
10
- end
@@ -1,12 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Diagrams
4
- class StateDiagram
5
- class State < Dry::Struct
6
- attribute :id, StateDiagram::Types::String
7
- attribute :label, StateDiagram::Types::String.optional.default(nil)
8
- attribute :type,
9
- StateDiagram::Types::String.optional.default('state').enum('state', 'start', 'end', 'fork', 'join')
10
- end
11
- end
12
- end
@@ -1,11 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Diagrams
4
- class StateDiagram
5
- class Transition < Dry::Struct
6
- attribute :from, StateDiagram::Types::String
7
- attribute :to, StateDiagram::Types::String
8
- attribute :label, StateDiagram::Types::String.optional.default(nil)
9
- end
10
- end
11
- end