activerecord_uml 0.6.0 → 0.11.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/exe/activerecord_uml +5 -4
- data/lib/activerecord_uml.rb +1 -0
- data/lib/activerecord_uml/diagram_drawer.rb +23 -5
- data/lib/activerecord_uml/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 14ef2902767bb5de3b65b387a336ab4f3ebe234dea52cf6c8b1d3cb756818fdc
|
4
|
+
data.tar.gz: 760d9f81fda80c254be2de0f207474555f93ae470260b9dc6644940981b0e720
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 685b19398a365c8b47905bfdf6aba021fc61cbfaa4ecf022f6777a05dc09341b404816f3ba308edb729651d76a37c16970087de7072021591dbb490a4d3e2d9e
|
7
|
+
data.tar.gz: 4c1079d76751897c77ddfae33ed10708e675e0726871d3a34ffd57a8699ce36609a9fa5e2a56c2f906e140d780330fb3f7fa5e530da69ceb5d21bde66022e6a0
|
data/README.md
CHANGED
data/exe/activerecord_uml
CHANGED
@@ -1,7 +1,8 @@
|
|
1
1
|
#! /usr/bin/env ruby
|
2
|
-
require "activerecord_uml"
|
3
2
|
|
4
|
-
|
5
|
-
|
3
|
+
activerecord_uml = File.join __dir__,"../lib/activerecord_uml"
|
4
|
+
ruby_script = "require \"#{activerecord_uml}\"; ActiverecordUml.draw"
|
5
|
+
rails = File.join Dir.pwd,"bin/rails"
|
6
|
+
rails_runner_command = "echo '#{ruby_script}' | #{rails} runner - #{ARGV.join ' '}"
|
6
7
|
|
7
|
-
|
8
|
+
system rails_runner_command
|
data/lib/activerecord_uml.rb
CHANGED
@@ -28,11 +28,20 @@ EOF
|
|
28
28
|
|
29
29
|
def relations
|
30
30
|
@class_name.reflect_on_all_associations(:belongs_to).map do |a|
|
31
|
-
"#{a.
|
31
|
+
"#{a.class_name} --* #{@class_name}#{label_for a}"
|
32
32
|
end.concat(@class_name.reflect_on_all_associations(:has_many).map do |a|
|
33
|
-
|
33
|
+
if a.is_a? ActiveRecord::Reflection::ThroughReflection
|
34
|
+
if a.source_reflection
|
35
|
+
# If a source association is specified, the class name of the source association is displayed.
|
36
|
+
"#{@class_name} *--* #{a.source_reflection.class_name}#{label_for a}"
|
37
|
+
else
|
38
|
+
"#{@class_name} *--* #{a.class_name}#{label_for a}"
|
39
|
+
end
|
40
|
+
else
|
41
|
+
"#{@class_name} --* #{a.class_name}#{label_for a}"
|
42
|
+
end
|
34
43
|
end).concat(@class_name.reflect_on_all_associations(:has_one).map do |a|
|
35
|
-
"#{@class_name} --* #{a.
|
44
|
+
"#{@class_name} --* #{a.class_name}#{label_for a}"
|
36
45
|
end)
|
37
46
|
end
|
38
47
|
|
@@ -47,9 +56,18 @@ EOF
|
|
47
56
|
method_parameters = @class_name.new.method(m)
|
48
57
|
.parameters
|
49
58
|
.filter { |a| a[0] == :req }
|
50
|
-
.map { |a| a[1] }
|
51
|
-
|
59
|
+
.map { |a| a[1] }
|
60
|
+
|
61
|
+
if method_parameters.length > 3
|
62
|
+
method_parameters = method_parameters.slice(0, 3).append("...")
|
63
|
+
end
|
64
|
+
|
65
|
+
[m.to_s, method_parameters.join(", ")]
|
52
66
|
end
|
53
67
|
end
|
68
|
+
|
69
|
+
def label_for(association)
|
70
|
+
association.class_name != association.name.to_s.classify ? " : #{association.name.to_s.classify}" : ""
|
71
|
+
end
|
54
72
|
end
|
55
73
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: activerecord_uml
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.11.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- shigeru.nakajima
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-06-
|
11
|
+
date: 2021-06-28 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Generate UML class diagram for Mermaid.js from ActiveRecord instances
|
14
14
|
by Rails runner.
|