arerd 0.1.0 → 0.2.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9a3364c03a39be5bf9ac0727652516999efb340d3208fd87621556021c28de20
4
- data.tar.gz: c84c46b6e3e2fec66857e74c087e5ba6f03b2fe4cc42c3ed99d9997dc5f69038
3
+ metadata.gz: 5884c815cee73195f4d846b20fa20f939087b51871bcecc0ebbc826145da793c
4
+ data.tar.gz: 3c8a47907dc904e2b5bba626cb57a08ef862c291410b90735bacf77ced0be131
5
5
  SHA512:
6
- metadata.gz: 8a634f01c34f49fe14acfcfc9e9d37407723852857b05ab16ecef35ac5f5dfb420a6eeaf5695e156d0ca44e998a8f8df7032d8e3f987ab7b51b77b66c4035dc4
7
- data.tar.gz: 46d6acb3f3be56edb6630df0c97ff1a318d73b6aba02b2e009272ae0761bc616896040f6dd12ebc7beb8918845632274f7df9f70044f6ba8f4b5822f8305b1ee
6
+ metadata.gz: e48476221e260c72808f2def3785515bcc1423bc8c168c48267c65b505d28a23ba23b544f34535249377572050ce8a5de3febe92bb5fa8dca615e9b8656b847b
7
+ data.tar.gz: 3b1bc29b10783b05c1ea1f47693d072b746d8bdb0da8b82130c93462b527d69d7f1647c31db993bff501570651549f3067e647dac35949309f877db9c4451d6d
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- arerd (0.1.0)
4
+ arerd (0.2.0)
5
5
  rails (>= 6.0)
6
6
 
7
7
  GEM
@@ -2,6 +2,8 @@
2
2
 
3
3
  module Arerd
4
4
  class Association
5
+ include Comparable
6
+
5
7
  attr_reader :left_model, :left_key, :left_association_name,
6
8
  :right_model, :right_key, :right_association_name,
7
9
  :left_side_multiplicity, :right_side_multiplicity
@@ -26,6 +28,13 @@ module Arerd
26
28
  @right_side_multiplicity = right_side_multiplicity
27
29
  end
28
30
 
31
+ def <=>(other)
32
+ return nil unless other.is_a?(Association)
33
+
34
+ [left_model.name, right_model.name, left_association_name.to_s, right_association_name.to_s] <=>
35
+ [other.left_model.name, other.right_model.name, other.left_association_name.to_s, other.right_association_name.to_s]
36
+ end
37
+
29
38
  def self.build(association)
30
39
  case association.macro
31
40
  when :has_many
@@ -22,9 +22,11 @@ module Arerd
22
22
  def self.collect_models_and_associations
23
23
  Rails.application.eager_load!
24
24
 
25
- models = ApplicationRecord.descendants
25
+ models = ApplicationRecord.descendants.sort_by(&:name)
26
26
 
27
- associations = Arerd::Association.build_associations_from_models(models)
27
+ associations = Arerd::Association
28
+ .build_associations_from_models(models)
29
+ .sort
28
30
 
29
31
  {models:, associations:}
30
32
  end
data/lib/arerd/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Arerd
4
- VERSION = "0.1.0"
4
+ VERSION = "0.2.0"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: arerd
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Shuhei YOSHIDA
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2025-07-21 00:00:00.000000000 Z
11
+ date: 2025-07-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -38,8 +38,8 @@ dependencies:
38
38
  - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
- description: Provides a Rake task (db:erd) that extracts Entity-Relationship information
42
- from ActiveRecord and outputs an E-R diagram in Mermaid notation.
41
+ description: Provides a Rake task that extracts entity-relationship information from
42
+ ActiveRecord models and generates an ER diagram in Mermaid notation.
43
43
  email:
44
44
  - contact@yantene.net
45
45
  executables: []
@@ -92,5 +92,5 @@ requirements: []
92
92
  rubygems_version: 3.3.27
93
93
  signing_key:
94
94
  specification_version: 4
95
- summary: Rails gem for generating ERD from ActiveRecord in Mermaid format
95
+ summary: A Rails gem for generating an ERD from ActiveRecord models in Mermaid format
96
96
  test_files: []