diagram 0.2.1 → 0.3.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 (66) hide show
  1. checksums.yaml +4 -4
  2. data/lib/diagram.rb +3 -0
  3. data/lib/diagrams/base.rb +244 -0
  4. data/lib/diagrams/class_diagram.rb +123 -2
  5. data/lib/diagrams/elements/class_entity.rb +24 -0
  6. data/lib/diagrams/elements/edge.rb +28 -0
  7. data/lib/diagrams/elements/event.rb +22 -0
  8. data/lib/diagrams/elements/git_branch.rb +27 -0
  9. data/lib/diagrams/elements/git_commit.rb +36 -0
  10. data/lib/diagrams/elements/node.rb +30 -0
  11. data/lib/diagrams/elements/relationship.rb +33 -0
  12. data/lib/diagrams/elements/slice.rb +23 -0
  13. data/lib/diagrams/elements/state.rb +24 -0
  14. data/lib/diagrams/elements/task.rb +23 -0
  15. data/lib/diagrams/elements/timeline_event.rb +21 -0
  16. data/lib/diagrams/elements/timeline_period.rb +23 -0
  17. data/lib/diagrams/elements/timeline_section.rb +23 -0
  18. data/lib/diagrams/elements/transition.rb +27 -0
  19. data/lib/diagrams/elements.rb +12 -0
  20. data/lib/diagrams/flowchart_diagram.rb +119 -4
  21. data/lib/diagrams/gantt_diagram.rb +94 -3
  22. data/lib/diagrams/gitgraph_diagram.rb +345 -0
  23. data/lib/diagrams/pie_diagram.rb +108 -29
  24. data/lib/diagrams/state_diagram.rb +157 -4
  25. data/lib/diagrams/timeline_diagram.rb +161 -0
  26. data/lib/diagrams/version.rb +1 -1
  27. data/lib/diagrams.rb +6 -1
  28. data/sig/diagrams/base.rbs +86 -0
  29. data/sig/diagrams/class_diagram.rbs +33 -0
  30. data/sig/diagrams/elements/class_entity.rbs +15 -0
  31. data/sig/diagrams/elements/edge.rbs +16 -0
  32. data/sig/diagrams/elements/event.rbs +14 -0
  33. data/sig/diagrams/elements/git_branch.rbs +19 -0
  34. data/sig/diagrams/elements/git_commit.rbs +23 -0
  35. data/sig/diagrams/elements/node.rbs +14 -0
  36. data/sig/diagrams/elements/relationship.rbs +16 -0
  37. data/sig/diagrams/elements/slice.rbs +14 -0
  38. data/sig/diagrams/elements/state.rbs +14 -0
  39. data/sig/diagrams/elements/task.rbs +16 -0
  40. data/sig/diagrams/elements/timeline_event.rbs +17 -0
  41. data/sig/diagrams/elements/timeline_period.rbs +18 -0
  42. data/sig/diagrams/elements/timeline_section.rbs +18 -0
  43. data/sig/diagrams/elements/transition.rbs +15 -0
  44. data/sig/diagrams/elements/types.rbs +18 -0
  45. data/sig/diagrams/flowchart_diagram.rbs +32 -0
  46. data/sig/diagrams/gantt_diagram.rbs +29 -0
  47. data/sig/diagrams/gitgraph_diagram.rbs +35 -0
  48. data/sig/diagrams/pie_diagram.rbs +36 -0
  49. data/sig/diagrams/state_diagram.rbs +40 -0
  50. data/sig/diagrams/timeline_diagram.rbs +33 -0
  51. metadata +228 -22
  52. data/lib/diagrams/abstract_diagram.rb +0 -26
  53. data/lib/diagrams/class_diagram/class/field.rb +0 -15
  54. data/lib/diagrams/class_diagram/class/function/argument.rb +0 -14
  55. data/lib/diagrams/class_diagram/class/function.rb +0 -16
  56. data/lib/diagrams/class_diagram/class.rb +0 -12
  57. data/lib/diagrams/comparable.rb +0 -20
  58. data/lib/diagrams/flowchart_diagram/link.rb +0 -11
  59. data/lib/diagrams/flowchart_diagram/node.rb +0 -10
  60. data/lib/diagrams/gantt_diagram/section/task.rb +0 -13
  61. data/lib/diagrams/gantt_diagram/section.rb +0 -10
  62. data/lib/diagrams/pie_diagram/section.rb +0 -10
  63. data/lib/diagrams/plot.rb +0 -23
  64. data/lib/diagrams/state_diagram/event.rb +0 -10
  65. data/lib/diagrams/state_diagram/state.rb +0 -12
  66. data/lib/diagrams/state_diagram/transition.rb +0 -11
metadata CHANGED
@@ -1,15 +1,28 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: diagram
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Abdelkader Boudih
8
- autorequire:
9
8
  bindir: bin
10
9
  cert_chain: []
11
- date: 2024-02-03 00:00:00.000000000 Z
10
+ date: 2025-04-01 00:00:00.000000000 Z
12
11
  dependencies:
12
+ - !ruby/object:Gem::Dependency
13
+ name: dry-equalizer
14
+ requirement: !ruby/object:Gem::Requirement
15
+ requirements:
16
+ - - ">="
17
+ - !ruby/object:Gem::Version
18
+ version: '0.2'
19
+ type: :runtime
20
+ prerelease: false
21
+ version_requirements: !ruby/object:Gem::Requirement
22
+ requirements:
23
+ - - ">="
24
+ - !ruby/object:Gem::Version
25
+ version: '0.2'
13
26
  - !ruby/object:Gem::Dependency
14
27
  name: dry-struct
15
28
  requirement: !ruby/object:Gem::Requirement
@@ -24,6 +37,174 @@ dependencies:
24
37
  - - ">="
25
38
  - !ruby/object:Gem::Version
26
39
  version: 1.6.0
40
+ - !ruby/object:Gem::Dependency
41
+ name: dry-types
42
+ requirement: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - ">="
45
+ - !ruby/object:Gem::Version
46
+ version: '1.0'
47
+ type: :runtime
48
+ prerelease: false
49
+ version_requirements: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - ">="
52
+ - !ruby/object:Gem::Version
53
+ version: '1.0'
54
+ - !ruby/object:Gem::Dependency
55
+ name: json
56
+ requirement: !ruby/object:Gem::Requirement
57
+ requirements:
58
+ - - ">="
59
+ - !ruby/object:Gem::Version
60
+ version: '0'
61
+ type: :runtime
62
+ prerelease: false
63
+ version_requirements: !ruby/object:Gem::Requirement
64
+ requirements:
65
+ - - ">="
66
+ - !ruby/object:Gem::Version
67
+ version: '0'
68
+ - !ruby/object:Gem::Dependency
69
+ name: zeitwerk
70
+ requirement: !ruby/object:Gem::Requirement
71
+ requirements:
72
+ - - ">="
73
+ - !ruby/object:Gem::Version
74
+ version: '2.6'
75
+ type: :runtime
76
+ prerelease: false
77
+ version_requirements: !ruby/object:Gem::Requirement
78
+ requirements:
79
+ - - ">="
80
+ - !ruby/object:Gem::Version
81
+ version: '2.6'
82
+ - !ruby/object:Gem::Dependency
83
+ name: bundler
84
+ requirement: !ruby/object:Gem::Requirement
85
+ requirements:
86
+ - - ">="
87
+ - !ruby/object:Gem::Version
88
+ version: 2.5.5
89
+ type: :development
90
+ prerelease: false
91
+ version_requirements: !ruby/object:Gem::Requirement
92
+ requirements:
93
+ - - ">="
94
+ - !ruby/object:Gem::Version
95
+ version: 2.5.5
96
+ - !ruby/object:Gem::Dependency
97
+ name: minitest
98
+ requirement: !ruby/object:Gem::Requirement
99
+ requirements:
100
+ - - "~>"
101
+ - !ruby/object:Gem::Version
102
+ version: '5.0'
103
+ type: :development
104
+ prerelease: false
105
+ version_requirements: !ruby/object:Gem::Requirement
106
+ requirements:
107
+ - - "~>"
108
+ - !ruby/object:Gem::Version
109
+ version: '5.0'
110
+ - !ruby/object:Gem::Dependency
111
+ name: rake
112
+ requirement: !ruby/object:Gem::Requirement
113
+ requirements:
114
+ - - "~>"
115
+ - !ruby/object:Gem::Version
116
+ version: '13.0'
117
+ type: :development
118
+ prerelease: false
119
+ version_requirements: !ruby/object:Gem::Requirement
120
+ requirements:
121
+ - - "~>"
122
+ - !ruby/object:Gem::Version
123
+ version: '13.0'
124
+ - !ruby/object:Gem::Dependency
125
+ name: rubocop
126
+ requirement: !ruby/object:Gem::Requirement
127
+ requirements:
128
+ - - "~>"
129
+ - !ruby/object:Gem::Version
130
+ version: '1.59'
131
+ type: :development
132
+ prerelease: false
133
+ version_requirements: !ruby/object:Gem::Requirement
134
+ requirements:
135
+ - - "~>"
136
+ - !ruby/object:Gem::Version
137
+ version: '1.59'
138
+ - !ruby/object:Gem::Dependency
139
+ name: rubocop-minitest
140
+ requirement: !ruby/object:Gem::Requirement
141
+ requirements:
142
+ - - "~>"
143
+ - !ruby/object:Gem::Version
144
+ version: '0.34'
145
+ type: :development
146
+ prerelease: false
147
+ version_requirements: !ruby/object:Gem::Requirement
148
+ requirements:
149
+ - - "~>"
150
+ - !ruby/object:Gem::Version
151
+ version: '0.34'
152
+ - !ruby/object:Gem::Dependency
153
+ name: rubocop-performance
154
+ requirement: !ruby/object:Gem::Requirement
155
+ requirements:
156
+ - - "~>"
157
+ - !ruby/object:Gem::Version
158
+ version: '1.20'
159
+ type: :development
160
+ prerelease: false
161
+ version_requirements: !ruby/object:Gem::Requirement
162
+ requirements:
163
+ - - "~>"
164
+ - !ruby/object:Gem::Version
165
+ version: '1.20'
166
+ - !ruby/object:Gem::Dependency
167
+ name: rubocop-rake
168
+ requirement: !ruby/object:Gem::Requirement
169
+ requirements:
170
+ - - "~>"
171
+ - !ruby/object:Gem::Version
172
+ version: '0.6'
173
+ type: :development
174
+ prerelease: false
175
+ version_requirements: !ruby/object:Gem::Requirement
176
+ requirements:
177
+ - - "~>"
178
+ - !ruby/object:Gem::Version
179
+ version: '0.6'
180
+ - !ruby/object:Gem::Dependency
181
+ name: steep
182
+ requirement: !ruby/object:Gem::Requirement
183
+ requirements:
184
+ - - ">="
185
+ - !ruby/object:Gem::Version
186
+ version: '0'
187
+ type: :development
188
+ prerelease: false
189
+ version_requirements: !ruby/object:Gem::Requirement
190
+ requirements:
191
+ - - ">="
192
+ - !ruby/object:Gem::Version
193
+ version: '0'
194
+ - !ruby/object:Gem::Dependency
195
+ name: yard
196
+ requirement: !ruby/object:Gem::Requirement
197
+ requirements:
198
+ - - "~>"
199
+ - !ruby/object:Gem::Version
200
+ version: '0.9'
201
+ type: :development
202
+ prerelease: false
203
+ version_requirements: !ruby/object:Gem::Requirement
204
+ requirements:
205
+ - - "~>"
206
+ - !ruby/object:Gem::Version
207
+ version: '0.9'
27
208
  description: Work with diagrams in Ruby
28
209
  email:
29
210
  - seuros@pre-history.com
@@ -31,28 +212,55 @@ executables: []
31
212
  extensions: []
32
213
  extra_rdoc_files: []
33
214
  files:
215
+ - lib/diagram.rb
34
216
  - lib/diagrams.rb
35
- - lib/diagrams/abstract_diagram.rb
217
+ - lib/diagrams/base.rb
36
218
  - lib/diagrams/class_diagram.rb
37
- - lib/diagrams/class_diagram/class.rb
38
- - lib/diagrams/class_diagram/class/field.rb
39
- - lib/diagrams/class_diagram/class/function.rb
40
- - lib/diagrams/class_diagram/class/function/argument.rb
41
- - lib/diagrams/comparable.rb
219
+ - lib/diagrams/elements.rb
220
+ - lib/diagrams/elements/class_entity.rb
221
+ - lib/diagrams/elements/edge.rb
222
+ - lib/diagrams/elements/event.rb
223
+ - lib/diagrams/elements/git_branch.rb
224
+ - lib/diagrams/elements/git_commit.rb
225
+ - lib/diagrams/elements/node.rb
226
+ - lib/diagrams/elements/relationship.rb
227
+ - lib/diagrams/elements/slice.rb
228
+ - lib/diagrams/elements/state.rb
229
+ - lib/diagrams/elements/task.rb
230
+ - lib/diagrams/elements/timeline_event.rb
231
+ - lib/diagrams/elements/timeline_period.rb
232
+ - lib/diagrams/elements/timeline_section.rb
233
+ - lib/diagrams/elements/transition.rb
42
234
  - lib/diagrams/flowchart_diagram.rb
43
- - lib/diagrams/flowchart_diagram/link.rb
44
- - lib/diagrams/flowchart_diagram/node.rb
45
235
  - lib/diagrams/gantt_diagram.rb
46
- - lib/diagrams/gantt_diagram/section.rb
47
- - lib/diagrams/gantt_diagram/section/task.rb
236
+ - lib/diagrams/gitgraph_diagram.rb
48
237
  - lib/diagrams/pie_diagram.rb
49
- - lib/diagrams/pie_diagram/section.rb
50
- - lib/diagrams/plot.rb
51
238
  - lib/diagrams/state_diagram.rb
52
- - lib/diagrams/state_diagram/event.rb
53
- - lib/diagrams/state_diagram/state.rb
54
- - lib/diagrams/state_diagram/transition.rb
239
+ - lib/diagrams/timeline_diagram.rb
55
240
  - lib/diagrams/version.rb
241
+ - sig/diagrams/base.rbs
242
+ - sig/diagrams/class_diagram.rbs
243
+ - sig/diagrams/elements/class_entity.rbs
244
+ - sig/diagrams/elements/edge.rbs
245
+ - sig/diagrams/elements/event.rbs
246
+ - sig/diagrams/elements/git_branch.rbs
247
+ - sig/diagrams/elements/git_commit.rbs
248
+ - sig/diagrams/elements/node.rbs
249
+ - sig/diagrams/elements/relationship.rbs
250
+ - sig/diagrams/elements/slice.rbs
251
+ - sig/diagrams/elements/state.rbs
252
+ - sig/diagrams/elements/task.rbs
253
+ - sig/diagrams/elements/timeline_event.rbs
254
+ - sig/diagrams/elements/timeline_period.rbs
255
+ - sig/diagrams/elements/timeline_section.rbs
256
+ - sig/diagrams/elements/transition.rbs
257
+ - sig/diagrams/elements/types.rbs
258
+ - sig/diagrams/flowchart_diagram.rbs
259
+ - sig/diagrams/gantt_diagram.rbs
260
+ - sig/diagrams/gitgraph_diagram.rbs
261
+ - sig/diagrams/pie_diagram.rbs
262
+ - sig/diagrams/state_diagram.rbs
263
+ - sig/diagrams/timeline_diagram.rbs
56
264
  homepage: https://github.com/seuros/diagram-ruby
57
265
  licenses:
58
266
  - MIT
@@ -61,7 +269,6 @@ metadata:
61
269
  source_code_uri: https://github.com/seuros/diagram-ruby
62
270
  changelog_uri: https://github.com/seuros/diagram-ruby/blob/master/CHANGELOG.md
63
271
  rubygems_mfa_required: 'true'
64
- post_install_message:
65
272
  rdoc_options: []
66
273
  require_paths:
67
274
  - lib
@@ -69,15 +276,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
69
276
  requirements:
70
277
  - - ">="
71
278
  - !ruby/object:Gem::Version
72
- version: 3.1.0
279
+ version: 3.3.0
73
280
  required_rubygems_version: !ruby/object:Gem::Requirement
74
281
  requirements:
75
282
  - - ">="
76
283
  - !ruby/object:Gem::Version
77
284
  version: '0'
78
285
  requirements: []
79
- rubygems_version: 3.4.10
80
- signing_key:
286
+ rubygems_version: 3.6.2
81
287
  specification_version: 4
82
288
  summary: Work with diagrams in Ruby
83
289
  test_files: []
@@ -1,26 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Diagrams
4
- # Abstract class for diagrams
5
- class AbstractDiagram < Dry::Struct
6
- module Types
7
- include Dry.Types()
8
- end
9
-
10
- def initialize(*)
11
- raise NotImplementedError, 'Cannot instantiate abstract class' if instance_of?(AbstractDiagram)
12
-
13
- super
14
- end
15
-
16
- def type
17
- raise NotImplementedError, 'Subclasses must define `type`.'
18
- end
19
-
20
- ## Errors
21
- class ValidationError < StandardError; end
22
- class EmptyDiagramError < ValidationError; end
23
- class InvalidPercentageError < ValidationError; end
24
- class DuplicateLabelError < ValidationError; end
25
- end
26
- end
@@ -1,15 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Diagrams
4
- class ClassDiagram
5
- class Class
6
- class Field < Dry::Struct
7
- attribute :name, ClassDiagram::Types::String
8
- attribute :type, ClassDiagram::Types::String.optional.default('String')
9
- attribute :visibility,
10
- ClassDiagram::Types::String.optional.default('public')
11
- .constrained(format: /\A(public|private|protected|Internal)\z/)
12
- end
13
- end
14
- end
15
- end
@@ -1,14 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Diagrams
4
- class ClassDiagram
5
- class Class
6
- class Function
7
- class Argument < Dry::Struct
8
- attribute :name, ClassDiagram::Types::String
9
- attribute :type, ClassDiagram::Types::String.optional.default(nil)
10
- end
11
- end
12
- end
13
- end
14
- end
@@ -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