diagram 0.3.0 → 0.3.3

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 (47) hide show
  1. checksums.yaml +4 -4
  2. data/lib/diagram.rb +3 -0
  3. data/lib/diagrams/base.rb +8 -6
  4. data/lib/diagrams/class_diagram.rb +0 -4
  5. data/lib/diagrams/elements/class_entity.rb +0 -4
  6. data/lib/diagrams/elements/edge.rb +0 -4
  7. data/lib/diagrams/elements/erd_attribute.rb +28 -0
  8. data/lib/diagrams/elements/erd_entity.rb +23 -0
  9. data/lib/diagrams/elements/erd_relationship.rb +40 -0
  10. data/lib/diagrams/elements/event.rb +0 -4
  11. data/lib/diagrams/elements/gantt_section.rb +23 -0
  12. data/lib/diagrams/elements/git_branch.rb +27 -0
  13. data/lib/diagrams/elements/git_commit.rb +36 -0
  14. data/lib/diagrams/elements/node.rb +0 -8
  15. data/lib/diagrams/elements/relationship.rb +0 -4
  16. data/lib/diagrams/elements/slice.rb +0 -4
  17. data/lib/diagrams/elements/state.rb +0 -4
  18. data/lib/diagrams/elements/task.rb +20 -12
  19. data/lib/diagrams/elements/timeline_event.rb +21 -0
  20. data/lib/diagrams/elements/timeline_period.rb +23 -0
  21. data/lib/diagrams/elements/timeline_section.rb +23 -0
  22. data/lib/diagrams/elements/transition.rb +0 -4
  23. data/lib/diagrams/elements.rb +12 -0
  24. data/lib/diagrams/er_diagram.rb +143 -0
  25. data/lib/diagrams/flowchart_diagram.rb +0 -6
  26. data/lib/diagrams/gantt_diagram.rb +118 -35
  27. data/lib/diagrams/gitgraph_diagram.rb +345 -0
  28. data/lib/diagrams/pie_diagram.rb +0 -3
  29. data/lib/diagrams/state_diagram.rb +0 -5
  30. data/lib/diagrams/timeline_diagram.rb +159 -0
  31. data/lib/diagrams/version.rb +1 -1
  32. data/lib/diagrams.rb +13 -1
  33. data/sig/diagrams/elements/erd_attribute.rbs +20 -0
  34. data/sig/diagrams/elements/erd_entity.rbs +20 -0
  35. data/sig/diagrams/elements/erd_relationship.rbs +25 -0
  36. data/sig/diagrams/elements/gantt_section.rbs +18 -0
  37. data/sig/diagrams/elements/git_branch.rbs +19 -0
  38. data/sig/diagrams/elements/git_commit.rbs +23 -0
  39. data/sig/diagrams/elements/task.rbs +13 -5
  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/er_diagram.rbs +30 -0
  44. data/sig/diagrams/gantt_diagram.rbs +28 -10
  45. data/sig/diagrams/gitgraph_diagram.rbs +35 -0
  46. data/sig/diagrams/timeline_diagram.rbs +14 -0
  47. metadata +28 -2
@@ -0,0 +1,159 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Diagrams
4
+ # Represents a timeline diagram illustrating a chronology of events.
5
+ class TimelineDiagram < Base
6
+ DEFAULT_SECTION_TITLE = 'Default Section'
7
+
8
+ attr_reader :title, :sections
9
+
10
+ # Initializes a new TimelineDiagram.
11
+ #
12
+ # @param title [String, nil] Optional title for the timeline.
13
+ # @param sections [Array<Element::TimelineSection>] Initial sections (optional).
14
+ # @param version [String, Integer, nil] User-defined version identifier.
15
+ def initialize(title: nil, sections: [], version: 1)
16
+ super(version:)
17
+ @title = title&.strip
18
+ @sections = sections.is_a?(Array) ? sections : []
19
+ # Ensure there's always at least a default section if none provided initially
20
+ ensure_default_section if @sections.empty?
21
+ update_checksum!
22
+ end
23
+
24
+ # Sets the title of the timeline.
25
+ #
26
+ # @param new_title [String] The title text.
27
+ # @return [String] The new title.
28
+ def set_title(new_title)
29
+ @title = new_title.strip
30
+ update_checksum!
31
+ @title
32
+ end
33
+
34
+ # Adds a new section to the timeline.
35
+ # Subsequent periods/events will be added to this section.
36
+ #
37
+ # @param section_title [String] The title of the section.
38
+ # @raise [ArgumentError] if a section with the same title already exists.
39
+ # @return [Elements::TimelineSection] The newly added section.
40
+ def add_section(section_title)
41
+ clean_title = section_title.strip
42
+ raise ArgumentError, "Section title '#{clean_title}' cannot be empty" if clean_title.empty?
43
+ raise ArgumentError, "Section with title '#{clean_title}' already exists" if find_section(clean_title)
44
+
45
+ # Remove default section if it's empty and we're adding a real one
46
+ if @sections.size == 1 && @sections.first.title == DEFAULT_SECTION_TITLE && @sections.first.periods.empty?
47
+ @sections.clear
48
+ end
49
+
50
+ new_section = Elements::TimelineSection.new(title: clean_title)
51
+ @sections << new_section
52
+ update_checksum!
53
+ new_section
54
+ end
55
+
56
+ # Adds a time period with one or more events to the current (last) section.
57
+ #
58
+ # @param period_label [String] The label for the time period (e.g., "2004", "Bronze Age").
59
+ # @param events [Array<String> | String] A single event description or an array of event descriptions.
60
+ # @raise [ArgumentError] if period_label or any event description is empty.
61
+ # @raise [StandardError] if no sections exist (shouldn't happen due to default section).
62
+ # @return [Elements::TimelinePeriod] The newly added period.
63
+ def add_period(period_label:, events:)
64
+ clean_label = period_label.strip
65
+ raise ArgumentError, 'Period label cannot be empty' if clean_label.empty?
66
+
67
+ event_list = Array(events).map(&:strip).reject(&:empty?)
68
+ raise ArgumentError, 'Events cannot be empty' if event_list.empty?
69
+
70
+ timeline_events = event_list.map { |desc| Elements::TimelineEvent.new(description: desc) }
71
+ new_period = Elements::TimelinePeriod.new(label: clean_label, events: timeline_events)
72
+
73
+ current_section = @sections.last
74
+ raise StandardError, 'Cannot add period: No section available.' unless current_section
75
+
76
+ # Add period to the current section's periods array
77
+ # Dry::Struct arrays are immutable, so we need to create a new section object
78
+ updated_periods = current_section.periods + [new_period]
79
+ # Create a completely new section instance with the updated periods array
80
+ updated_section = Elements::TimelineSection.new(title: current_section.title, periods: updated_periods)
81
+
82
+ # Find the index of the current section and update it in place
83
+ # Rebuild the sections array, replacing the modified section
84
+ current_section_title = current_section.title
85
+ # Rebuild the sections array by mapping, replacing the target section
86
+ @sections = @sections.map do |section|
87
+ section.title == current_section_title ? updated_section : section
88
+ end
89
+
90
+ update_checksum!
91
+ new_period
92
+ end
93
+
94
+ # --- Base Class Implementation ---
95
+
96
+ def to_h_content
97
+ content = {
98
+ sections: @sections.map(&:to_h)
99
+ }
100
+ content[:title] = @title if @title
101
+ content
102
+ end
103
+
104
+ def identifiable_elements
105
+ # Sections and Periods are the main identifiable structures. Events are nested.
106
+ # Use section title and period label as identifiers.
107
+ {
108
+ sections: @sections,
109
+ periods: @sections.flat_map(&:periods) # Flatten periods from all sections
110
+ }
111
+ end
112
+
113
+ def self.from_h(data_hash, version:, checksum:)
114
+ title = data_hash[:title] || data_hash['title']
115
+ sections_data = data_hash[:sections] || data_hash['sections'] || []
116
+
117
+ sections = sections_data.map do |section_h|
118
+ section_data = section_h.transform_keys(&:to_sym)
119
+ periods_data = section_data[:periods] || []
120
+ periods = periods_data.map do |period_h|
121
+ period_data = period_h.transform_keys(&:to_sym)
122
+ events_data = period_data[:events] || []
123
+ events = events_data.map do |event_h|
124
+ event_data = event_h.transform_keys(&:to_sym)
125
+ Elements::TimelineEvent.new(event_data)
126
+ end
127
+ Elements::TimelinePeriod.new(period_data.merge(events:))
128
+ end
129
+ Elements::TimelineSection.new(section_data.merge(periods:))
130
+ end
131
+
132
+ diagram = new(title:, sections:, version:)
133
+
134
+ # Optional: Verify checksum
135
+ if checksum && diagram.checksum != checksum
136
+ warn "Checksum mismatch for loaded TimelineDiagram (version: #{version}). Expected #{checksum}, got #{diagram.checksum}."
137
+ end
138
+
139
+ diagram
140
+ end
141
+
142
+ private
143
+
144
+ # Ensures a default section exists if the sections array is empty.
145
+ def ensure_default_section
146
+ return if @sections.any? { |s| s.title == DEFAULT_SECTION_TITLE }
147
+
148
+ @sections << Elements::TimelineSection.new(title: DEFAULT_SECTION_TITLE)
149
+ end
150
+
151
+ # Finds a section by its title.
152
+ def find_section(section_title)
153
+ @sections.find { |s| s.title == section_title }
154
+ end
155
+
156
+ # Protected method access for from_h
157
+ protected :update_checksum!
158
+ end
159
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Diagrams
4
- VERSION = '0.3.0'
4
+ VERSION = '0.3.3'
5
5
  end
data/lib/diagrams.rb CHANGED
@@ -1,9 +1,21 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'zeitwerk'
4
- require_relative 'diagrams/version' # Keep this for gemspec access before setup
4
+ require 'digest'
5
+ require 'json'
6
+ require 'dry-equalizer'
7
+ require 'dry-struct'
8
+ require_relative 'diagrams/version'
5
9
 
6
10
  loader = Zeitwerk::Loader.for_gem
11
+ loader.ignore("#{__dir__}/diagram.rb")
12
+ # Add inflection for ERDiagram
13
+ loader.inflector.inflect(
14
+ 'er_diagram' => 'ERDiagram',
15
+ 'erd_entity' => 'ERDEntity',
16
+ 'erd_attribute' => 'ERDAttribute',
17
+ 'erd_relationship' => 'ERDRelationship'
18
+ )
7
19
  loader.setup
8
20
 
9
21
  # This module handles diagrams creation and manipulation.
@@ -0,0 +1,20 @@
1
+ module Diagrams
2
+ module Elements
3
+ # Represents an attribute within an ERD entity.
4
+ class ERDAttribute < ::Dry::Struct
5
+ include Elements::Types
6
+
7
+ # Attributes
8
+ attr_reader type: String
9
+ attr_reader name: String
10
+ attr_reader keys: Array[Symbol] # :PK | :FK | :UK
11
+ attr_reader comment: String?
12
+
13
+ # Methods
14
+ def initialize: (type: String, name: String, ?keys: Array[Symbol], ?comment: String?) -> void
15
+ | (Hash[Symbol, untyped]) -> void # Allow hash initialization
16
+
17
+ def to_h: () -> Hash[Symbol, String | Array[Symbol]]
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,20 @@
1
+ require_relative 'erd_attribute'
2
+
3
+ module Diagrams
4
+ module Elements
5
+ # Represents an entity (table) in an ER Diagram.
6
+ class ERDEntity < ::Dry::Struct
7
+ include Elements::Types
8
+
9
+ # Attributes
10
+ attr_reader name: String
11
+ attr_reader entity_attributes: Array[ERDAttribute]
12
+
13
+ # Methods
14
+ def initialize: (name: String, ?entity_attributes: Array[ERDAttribute]) -> void
15
+ | (Hash[Symbol, untyped]) -> void # Allow hash initialization
16
+
17
+ def to_h: () -> Hash[Symbol, String | Array[Hash[Symbol, untyped]]] # Output key is still :attributes
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,25 @@
1
+ module Diagrams
2
+ module Elements
3
+ # Represents a relationship between two entities in an ER Diagram.
4
+ class ERDRelationship < ::Dry::Struct
5
+ include Elements::Types
6
+
7
+ # Type alias for cardinality symbols
8
+ type CARDINALITY = :ZERO_OR_ONE | :ONE_ONLY | :ZERO_OR_MORE | :ONE_OR_MORE
9
+
10
+ # Attributes
11
+ attr_reader entity1: String
12
+ attr_reader entity2: String
13
+ attr_reader cardinality1: CARDINALITY
14
+ attr_reader cardinality2: CARDINALITY
15
+ attr_reader identifying: bool
16
+ attr_reader label: String?
17
+
18
+ # Methods
19
+ def initialize: (entity1: String, entity2: String, cardinality1: CARDINALITY, cardinality2: CARDINALITY, ?identifying: bool, ?label: String?) -> void
20
+ | (Hash[Symbol, untyped]) -> void # Allow hash initialization
21
+
22
+ def to_h: () -> Hash[Symbol, String | Symbol | bool]
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,18 @@
1
+ module Diagrams
2
+ module Elements
3
+ # Represents a section within a Gantt chart, grouping multiple tasks.
4
+ class GanttSection < ::Dry::Struct
5
+ include Elements::Types
6
+
7
+ # Attributes
8
+ attr_reader title: String
9
+ attr_reader tasks: Array[Task]
10
+
11
+ # Methods
12
+ def initialize: (title: String, ?tasks: Array[Task]) -> void
13
+ | (Hash[Symbol, untyped]) -> void # Allow hash initialization
14
+
15
+ def to_h: () -> Hash[Symbol, String | Array[Hash[Symbol, untyped]]]
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,19 @@
1
+ module Diagrams
2
+ module Elements
3
+ # Represents a branch in a Gitgraph diagram.
4
+ class GitBranch < ::Dry::Struct
5
+ include Elements::Types
6
+
7
+ # Attributes
8
+ attr_reader name: String
9
+ attr_reader head_commit_id: String?
10
+ attr_reader start_commit_id: String
11
+
12
+ # Methods
13
+ def initialize: (name: String, ?head_commit_id: String?, start_commit_id: String) -> void
14
+ | (Hash[Symbol, untyped]) -> void # Allow hash initialization
15
+
16
+ def to_h: () -> Hash[Symbol, String]
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,23 @@
1
+ module Diagrams
2
+ module Elements
3
+ # Represents a commit in a Gitgraph diagram.
4
+ class GitCommit < ::Dry::Struct
5
+ include Elements::Types
6
+
7
+ # Attributes
8
+ attr_reader id: String
9
+ attr_reader parent_ids: Array[String]
10
+ attr_reader branch_name: String
11
+ attr_reader message: String?
12
+ attr_reader tag: String?
13
+ attr_reader type: Symbol # :NORMAL | :REVERSE | :HIGHLIGHT | :MERGE | :CHERRY_PICK
14
+ attr_reader cherry_pick_source_id: String?
15
+
16
+ # Methods
17
+ def initialize: (id: String, ?parent_ids: Array[String], branch_name: String, ?message: String?, ?tag: String?, ?type: Symbol, ?cherry_pick_source_id: String?) -> void
18
+ | (Hash[Symbol, untyped]) -> void # Allow hash initialization
19
+
20
+ def to_h: () -> Hash[Symbol, String | Array[String] | Symbol]
21
+ end
22
+ end
23
+ end
@@ -4,13 +4,21 @@ module Diagrams
4
4
  include Diagrams::Elements::Types
5
5
 
6
6
  # Attributes
7
- def id: () -> ::String
8
- def name: () -> ::String
9
- def start_date: () -> ::String # Or ::Date if type is changed
10
- def end_date: () -> ::String # Or ::Date if type is changed
7
+ # Type alias for status symbols
8
+ type STATUS = :done | :active | :crit
9
+
10
+ # Attributes
11
+ attr_reader id: String # Unique ID for dependencies
12
+ attr_reader label: String # Display name
13
+ attr_reader status: STATUS? # Task status (nil implies default/future)
14
+ attr_reader start: String # Start date, task ID, or 'after taskX[, taskY]'
15
+ attr_reader duration: String # Duration string (e.g., '7d', '2w')
11
16
 
12
17
  # Methods
13
- def to_h: () -> { id: ::String, name: ::String, start_date: ::String, end_date: ::String }
18
+ def initialize: (id: String, label: String, start: String, duration: String, ?status: STATUS?) -> void
19
+ | (Hash[Symbol, untyped]) -> void # Allow hash initialization
20
+
21
+ def to_h: () -> Hash[Symbol, String | Symbol | nil]
14
22
  end
15
23
  end
16
24
  end
@@ -0,0 +1,17 @@
1
+ module Diagrams
2
+ module Elements
3
+ # Represents a single event description within a timeline period.
4
+ class TimelineEvent < ::Dry::Struct
5
+ include Elements::Types
6
+
7
+ # Attributes
8
+ attr_reader description: String
9
+
10
+ # Methods
11
+ def initialize: (description: String) -> void
12
+ | (Hash[Symbol, untyped]) -> void # Allow hash initialization
13
+
14
+ def to_h: () -> Hash[Symbol, String]
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,18 @@
1
+ module Diagrams
2
+ module Elements
3
+ # Represents a specific time period on the timeline, containing one or more events.
4
+ class TimelinePeriod < ::Dry::Struct
5
+ include Elements::Types
6
+
7
+ # Attributes
8
+ attr_reader label: String
9
+ attr_reader events: Array[TimelineEvent]
10
+
11
+ # Methods
12
+ def initialize: (label: String, events: Array[TimelineEvent]) -> void
13
+ | (Hash[Symbol, untyped]) -> void # Allow hash initialization
14
+
15
+ def to_h: () -> Hash[Symbol, String | Array[Hash[Symbol, String]]]
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,18 @@
1
+ module Diagrams
2
+ module Elements
3
+ # Represents a section or age within the timeline, grouping multiple time periods.
4
+ class TimelineSection < ::Dry::Struct
5
+ include Elements::Types
6
+
7
+ # Attributes
8
+ attr_reader title: String
9
+ attr_reader periods: Array[TimelinePeriod]
10
+
11
+ # Methods
12
+ def initialize: (title: String, ?periods: Array[TimelinePeriod]) -> void
13
+ | (Hash[Symbol, untyped]) -> void # Allow hash initialization
14
+
15
+ def to_h: () -> Hash[Symbol, String | Array[Hash[Symbol, untyped]]]
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,30 @@
1
+ module Diagrams
2
+ # Represents an Entity Relationship Diagram (ERD).
3
+ class ERDiagram < Base
4
+ # Instance Variables (via attr_reader)
5
+ attr_reader entities: Hash[String, Elements::ERDEntity]
6
+ attr_reader relationships: Array[Elements::ERDRelationship]
7
+
8
+ # Initialization
9
+ def initialize: (?entities: Array[Elements::ERDEntity], ?relationships: Array[Elements::ERDRelationship], ?version: String | Integer) -> void
10
+
11
+ # Public Methods
12
+ def add_entity: (name: String, ?attributes: Array[Hash[Symbol, untyped]]) -> Elements::ERDEntity
13
+ def add_relationship: (entity1: String, entity2: String, cardinality1: Symbol, cardinality2: Symbol, ?identifying: bool, ?label: String?) -> Elements::ERDRelationship
14
+ def find_entity: (String entity_name) -> Elements::ERDEntity?
15
+
16
+ # --- Base Class Implementation ---
17
+ def to_h_content: () -> Hash[Symbol, Array[Hash[Symbol, untyped]]]
18
+ def identifiable_elements: () -> Hash[Symbol, Array[Elements::ERDEntity | Elements::ERDRelationship]]
19
+
20
+ # Class method for deserialization
21
+ def self.from_h: (Hash[Symbol, untyped] data_hash, version: String | Integer | nil, checksum: String?) -> ERDiagram
22
+
23
+ # --- Private Methods ---
24
+ private
25
+ def validate_relationships!: () -> void
26
+
27
+ # Inherited protected method
28
+ # def update_checksum!: () -> String
29
+ end
30
+ end
@@ -1,29 +1,47 @@
1
1
  module Diagrams
2
+ # Represents a Gantt Chart diagram consisting of tasks over time, grouped into sections.
2
3
  class GanttDiagram < Base
3
- attr_reader title: ::String
4
- attr_reader tasks: ::Array[Elements::Task]
4
+ DEFAULT_SECTION_TITLE: String
5
+
6
+ attr_reader title: String?
7
+ attr_reader sections: Array[Elements::GanttSection] # Use GanttSection
5
8
 
6
9
  # Initializes a new GanttDiagram.
7
- def initialize: (?title: ::String?, ?tasks: ::Array[Elements::Task]?, ?version: Integer | String?) -> void
10
+ def initialize: (?title: String?, ?sections: Array[Elements::GanttSection]?, ?version: String | Integer) -> void
11
+
12
+ # Adds a new section to the diagram.
13
+ def add_section: (String section_title) -> Elements::GanttSection
14
+
15
+ # Adds a task to the current (last) section of the diagram.
16
+ def add_task: (id: String, label: String, start: String, duration: String, ?status: Elements::Task::STATUS?) -> Elements::Task
8
17
 
9
- # Adds a task to the diagram.
10
- def add_task: (Elements::Task task) -> Elements::Task
18
+ # Finds a task by its ID across all sections.
19
+ def find_task: (String task_id) -> Elements::Task?
11
20
 
12
- # Finds a task by its ID.
13
- def find_task: (::String task_id) -> Elements::Task?
21
+ # Finds a section by its title.
22
+ def find_section: (String section_title) -> Elements::GanttSection?
14
23
 
15
24
  # Returns the specific content of the Gantt diagram as a hash.
16
- def to_h_content: () -> { title: ::String, tasks: ::Array[Hash[Symbol, untyped]] }
25
+ def to_h_content: () -> Hash[Symbol, untyped] # More specific: { title: String?, sections: Array[Hash] }
17
26
 
18
27
  # Returns a hash mapping element types to their collections for diffing.
19
- def identifiable_elements: () -> { tasks: ::Array[Elements::Task] }
28
+ def identifiable_elements: () -> Hash[Symbol, Array[Elements::Task]] # Diffing tasks directly
20
29
 
21
30
  # Class method to create a GanttDiagram from a hash.
22
- def self.from_h: (Hash[Symbol | String, untyped] data_hash, version: Integer | String?, checksum: String?) -> GanttDiagram
31
+ def self.from_h: (Hash[Symbol, untyped] data_hash, version: String | Integer | nil, checksum: String?) -> GanttDiagram
23
32
 
24
33
  private
25
34
 
35
+ # Helper to get all tasks from all sections.
36
+ def all_tasks: () -> Array[Elements::Task]
37
+
38
+ # Ensures a default section exists if the sections array is empty.
39
+ def ensure_default_section: () -> void
40
+
26
41
  # Validates the consistency of tasks during initialization.
27
42
  def validate_elements!: () -> void
43
+
44
+ # Inherited protected method
45
+ # def update_checksum!: () -> String
28
46
  end
29
47
  end
@@ -0,0 +1,35 @@
1
+ module Diagrams
2
+ # Represents a Gitgraph diagram, tracking commits, branches, and their relationships.
3
+ class GitgraphDiagram < Base
4
+ # Instance Variables (via attr_reader)
5
+ attr_reader commits: Hash[String, Elements::GitCommit]
6
+ attr_reader branches: Hash[String, Elements::GitBranch]
7
+ attr_reader commit_order: Array[String]
8
+ attr_reader current_branch_name: String
9
+
10
+ # Initialization
11
+ def initialize: (?version: String | Integer) -> void
12
+
13
+ # --- Git Operations ---
14
+ def commit: (?id: String?, ?message: String?, ?tag: String?, ?type: Symbol) -> Elements::GitCommit
15
+ def branch: (name: String, ?start_commit_id: String?) -> Elements::GitBranch
16
+ def checkout: (name: String) -> String
17
+ def merge: (from_branch_name: String, ?id: String?, ?tag: String?, ?type: Symbol) -> Elements::GitCommit
18
+ def cherry_pick: (commit_id: String, ?parent_override_id: String?) -> Elements::GitCommit
19
+
20
+ # --- Base Class Implementation ---
21
+ def to_h_content: () -> Hash[Symbol, untyped] # More specific: Hash[Symbol, Array[Hash[Symbol, untyped]] | Array[String] | String]
22
+ def identifiable_elements: () -> Hash[Symbol, Array[Elements::GitCommit | Elements::GitBranch]]
23
+
24
+ # Class method for deserialization
25
+ def self.from_h: (Hash[Symbol, untyped] data_hash, version: String | Integer | nil, checksum: String?) -> GitgraphDiagram
26
+
27
+ # --- Private/Protected Methods ---
28
+ private
29
+ def generate_commit_id: (Array[String] parent_ids, String? message) -> String
30
+ def current_head_commit_id: () -> String?
31
+
32
+ # Inherited protected method
33
+ # def update_checksum!: () -> String # Defined in Base, but accessible via send in from_h
34
+ end
35
+ end
@@ -0,0 +1,14 @@
1
+ # RBS signatures for patches applied to the 'diagram' gem's TimelineDiagram class
2
+ module Diagrams
3
+ class TimelineDiagram < Base
4
+ # Added by mermaid-ruby gem
5
+ # Generates the Mermaid syntax for the timeline diagram.
6
+ def to_mermaid: () -> String
7
+
8
+ # Original methods from diagram gem (if known/needed for context)
9
+ # attr_reader title: String?
10
+ # attr_reader sections: Array[Elements::TimelineSection]
11
+ # def initialize: (?title: String?, ?sections: Array[Elements::TimelineSection], ?version: untyped) -> void
12
+ # ... other methods ...
13
+ end
14
+ end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: diagram
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.3.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Abdelkader Boudih
8
8
  bindir: bin
9
9
  cert_chain: []
10
- date: 2025-03-31 00:00:00.000000000 Z
10
+ date: 2025-04-01 00:00:00.000000000 Z
11
11
  dependencies:
12
12
  - !ruby/object:Gem::Dependency
13
13
  name: dry-equalizer
@@ -212,39 +212,65 @@ executables: []
212
212
  extensions: []
213
213
  extra_rdoc_files: []
214
214
  files:
215
+ - lib/diagram.rb
215
216
  - lib/diagrams.rb
216
217
  - lib/diagrams/base.rb
217
218
  - lib/diagrams/class_diagram.rb
219
+ - lib/diagrams/elements.rb
218
220
  - lib/diagrams/elements/class_entity.rb
219
221
  - lib/diagrams/elements/edge.rb
222
+ - lib/diagrams/elements/erd_attribute.rb
223
+ - lib/diagrams/elements/erd_entity.rb
224
+ - lib/diagrams/elements/erd_relationship.rb
220
225
  - lib/diagrams/elements/event.rb
226
+ - lib/diagrams/elements/gantt_section.rb
227
+ - lib/diagrams/elements/git_branch.rb
228
+ - lib/diagrams/elements/git_commit.rb
221
229
  - lib/diagrams/elements/node.rb
222
230
  - lib/diagrams/elements/relationship.rb
223
231
  - lib/diagrams/elements/slice.rb
224
232
  - lib/diagrams/elements/state.rb
225
233
  - lib/diagrams/elements/task.rb
234
+ - lib/diagrams/elements/timeline_event.rb
235
+ - lib/diagrams/elements/timeline_period.rb
236
+ - lib/diagrams/elements/timeline_section.rb
226
237
  - lib/diagrams/elements/transition.rb
238
+ - lib/diagrams/er_diagram.rb
227
239
  - lib/diagrams/flowchart_diagram.rb
228
240
  - lib/diagrams/gantt_diagram.rb
241
+ - lib/diagrams/gitgraph_diagram.rb
229
242
  - lib/diagrams/pie_diagram.rb
230
243
  - lib/diagrams/state_diagram.rb
244
+ - lib/diagrams/timeline_diagram.rb
231
245
  - lib/diagrams/version.rb
232
246
  - sig/diagrams/base.rbs
233
247
  - sig/diagrams/class_diagram.rbs
234
248
  - sig/diagrams/elements/class_entity.rbs
235
249
  - sig/diagrams/elements/edge.rbs
250
+ - sig/diagrams/elements/erd_attribute.rbs
251
+ - sig/diagrams/elements/erd_entity.rbs
252
+ - sig/diagrams/elements/erd_relationship.rbs
236
253
  - sig/diagrams/elements/event.rbs
254
+ - sig/diagrams/elements/gantt_section.rbs
255
+ - sig/diagrams/elements/git_branch.rbs
256
+ - sig/diagrams/elements/git_commit.rbs
237
257
  - sig/diagrams/elements/node.rbs
238
258
  - sig/diagrams/elements/relationship.rbs
239
259
  - sig/diagrams/elements/slice.rbs
240
260
  - sig/diagrams/elements/state.rbs
241
261
  - sig/diagrams/elements/task.rbs
262
+ - sig/diagrams/elements/timeline_event.rbs
263
+ - sig/diagrams/elements/timeline_period.rbs
264
+ - sig/diagrams/elements/timeline_section.rbs
242
265
  - sig/diagrams/elements/transition.rbs
243
266
  - sig/diagrams/elements/types.rbs
267
+ - sig/diagrams/er_diagram.rbs
244
268
  - sig/diagrams/flowchart_diagram.rbs
245
269
  - sig/diagrams/gantt_diagram.rbs
270
+ - sig/diagrams/gitgraph_diagram.rbs
246
271
  - sig/diagrams/pie_diagram.rbs
247
272
  - sig/diagrams/state_diagram.rbs
273
+ - sig/diagrams/timeline_diagram.rbs
248
274
  homepage: https://github.com/seuros/diagram-ruby
249
275
  licenses:
250
276
  - MIT