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 +4 -4
- data/Gemfile.lock +1 -1
- data/lib/arerd/association.rb +9 -0
- data/lib/arerd/erd_generator.rb +4 -2
- data/lib/arerd/version.rb +1 -1
- metadata +5 -5
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 5884c815cee73195f4d846b20fa20f939087b51871bcecc0ebbc826145da793c
|
|
4
|
+
data.tar.gz: 3c8a47907dc904e2b5bba626cb57a08ef862c291410b90735bacf77ced0be131
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: e48476221e260c72808f2def3785515bcc1423bc8c168c48267c65b505d28a23ba23b544f34535249377572050ce8a5de3febe92bb5fa8dca615e9b8656b847b
|
|
7
|
+
data.tar.gz: 3b1bc29b10783b05c1ea1f47693d072b746d8bdb0da8b82130c93462b527d69d7f1647c31db993bff501570651549f3067e647dac35949309f877db9c4451d6d
|
data/Gemfile.lock
CHANGED
data/lib/arerd/association.rb
CHANGED
|
@@ -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
|
data/lib/arerd/erd_generator.rb
CHANGED
|
@@ -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
|
|
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
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.
|
|
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-
|
|
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
|
|
42
|
-
|
|
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: []
|