rails-erd 1.3.1 → 1.4.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 +2 -1
- data/lib/rails_erd/config.rb +2 -2
- data/lib/rails_erd/diagram/graphviz.rb +2 -1
- data/lib/rails_erd/domain/relationship.rb +13 -9
- data/lib/rails_erd/domain/specialization.rb +6 -0
- data/lib/rails_erd/version.rb +1 -1
- data/test/test_helper.rb +1 -1
- data/test/unit/graphviz_test.rb +1 -1
- metadata +9 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d754b17dc91d089d0e6bbccfce2bf4d269db3b7b
|
4
|
+
data.tar.gz: f87e6ed6a771e3956a44edb77aba932e626203a2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 278db5cb89bda7905a7ba8fda35cdfd5466fafd4231bbf86272a9463a088a015be01daee8033432bfe1a1fddad872e6728fe1b75e37ad7b9e78c433bd3974c91
|
7
|
+
data.tar.gz: c02232f93661c164eefdbc04289569e3a6579ec1146271e5ce94ece1cbdcecb8dacc3b2f86f2c67ea2c0a05210a052869a70c09a6fc7c71138ef9e7916382223
|
data/README.md
CHANGED
@@ -1,7 +1,8 @@
|
|
1
1
|
Rails ERD - Generate Entity-Relationship Diagrams for Rails applications
|
2
2
|
========================================================================
|
3
|
+
[![Build Status](https://travis-ci.org/voormedia/rails-erd.svg?branch=master)](https://travis-ci.org/voormedia/rails-erd) [![Code Climate](https://codeclimate.com/github/voormedia/rails-erd/badges/gpa.svg)](https://codeclimate.com/github/voormedia/rails-erd)
|
3
4
|
|
4
|
-
[Rails ERD](http://voormedia.github.io/rails-erd/) is a
|
5
|
+
[Rails ERD](http://voormedia.github.io/rails-erd/) is a gem that allows you to easily generate a diagram based on your application's Active Record models. The diagram gives an overview of how your models are related. Having a diagram that describes your models is perfect documentation for your application.
|
5
6
|
|
6
7
|
The second goal of Rails ERD is to provide you with a tool to inspect your application's domain model. If you don't like the default output, it is very easy to use the API to build your own diagrams.
|
7
8
|
|
data/lib/rails_erd/config.rb
CHANGED
@@ -26,11 +26,11 @@ module RailsERD
|
|
26
26
|
if use_os_x_fonts?
|
27
27
|
{ normal: "ArialMT",
|
28
28
|
bold: "Arial BoldMT",
|
29
|
-
italic: "
|
29
|
+
italic: "Arial ItalicMT" }
|
30
30
|
else
|
31
31
|
{ normal: "Arial",
|
32
32
|
bold: "Arial Bold",
|
33
|
-
italic: "
|
33
|
+
italic: "Arial Italic" }
|
34
34
|
end
|
35
35
|
end
|
36
36
|
|
@@ -194,9 +194,10 @@ module RailsERD
|
|
194
194
|
|
195
195
|
save do
|
196
196
|
raise "Saving diagram failed!\nOutput directory '#{File.dirname(filename)}' does not exist." unless File.directory?(File.dirname(filename))
|
197
|
+
|
197
198
|
begin
|
198
199
|
# GraphViz doesn't like spaces in the filename
|
199
|
-
graph.output(filetype => filename.gsub(/\s/,"
|
200
|
+
graph.output(filetype => filename.gsub(/\s/,"_"))
|
200
201
|
filename
|
201
202
|
rescue RuntimeError => e
|
202
203
|
raise "Saving diagram failed!\nGraphviz produced errors. Verify it " +
|
@@ -63,17 +63,10 @@ module RailsERD
|
|
63
63
|
|
64
64
|
def initialize(domain, associations) # @private :nodoc:
|
65
65
|
@domain = domain
|
66
|
-
@reverse_associations, @forward_associations =
|
67
|
-
associations.partition(&:belongs_to?)
|
68
|
-
else
|
69
|
-
# Many-to-many associations don't have a clearly defined direction.
|
70
|
-
# We sort by name and use the first model as the source.
|
71
|
-
source = associations.map(&:active_record).sort_by(&:name).first
|
72
|
-
associations.partition { |association| association.active_record != source }
|
73
|
-
end
|
66
|
+
@reverse_associations, @forward_associations = partition_associations(associations)
|
74
67
|
|
75
68
|
assoc = @forward_associations.first || @reverse_associations.first
|
76
|
-
@source
|
69
|
+
@source = @domain.entity_by_name(self.class.send(:association_owner, assoc))
|
77
70
|
@destination = @domain.entity_by_name(self.class.send(:association_target, assoc))
|
78
71
|
@source, @destination = @destination, @source if assoc.belongs_to?
|
79
72
|
end
|
@@ -152,6 +145,17 @@ module RailsERD
|
|
152
145
|
|
153
146
|
private
|
154
147
|
|
148
|
+
def partition_associations(associations)
|
149
|
+
if any_habtm?(associations)
|
150
|
+
# Many-to-many associations don't have a clearly defined direction.
|
151
|
+
# We sort by name and use the first model as the source.
|
152
|
+
source = associations.map(&:active_record).sort_by(&:name).first
|
153
|
+
associations.partition { |association| association.active_record != source }
|
154
|
+
else
|
155
|
+
associations.partition(&:belongs_to?)
|
156
|
+
end
|
157
|
+
end
|
158
|
+
|
155
159
|
def associations_range(associations, absolute_max)
|
156
160
|
# The minimum of the range is the maximum value of each association
|
157
161
|
# minimum. If there is none, it is zero by definition. The reasoning is
|
data/lib/rails_erd/version.rb
CHANGED
data/test/test_helper.rb
CHANGED
data/test/unit/graphviz_test.rb
CHANGED
@@ -94,7 +94,7 @@ class GraphvizTest < ActiveSupport::TestCase
|
|
94
94
|
test "create should create output for filenames that have spaces" do
|
95
95
|
create_simple_domain
|
96
96
|
Diagram::Graphviz.create :filename => "erd with spaces"
|
97
|
-
assert File.exists?("
|
97
|
+
assert File.exists?("erd_with_spaces.png")
|
98
98
|
end
|
99
99
|
|
100
100
|
test "create should write to file with dot extension without requiring graphviz" do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rails-erd
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Rolf Timmermans
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-05-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|
@@ -44,28 +44,28 @@ dependencies:
|
|
44
44
|
requirements:
|
45
45
|
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: 1.
|
47
|
+
version: '1.2'
|
48
48
|
type: :runtime
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: 1.
|
54
|
+
version: '1.2'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: choice
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
59
|
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: 0.
|
61
|
+
version: 0.2.0
|
62
62
|
type: :runtime
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
66
|
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version: 0.
|
68
|
+
version: 0.2.0
|
69
69
|
description: Automatically generate an entity-relationship diagram (ERD) for your
|
70
70
|
Rails models.
|
71
71
|
email:
|
@@ -121,15 +121,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
121
121
|
requirements:
|
122
122
|
- - ">="
|
123
123
|
- !ruby/object:Gem::Version
|
124
|
-
version:
|
124
|
+
version: 1.9.3
|
125
125
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
126
126
|
requirements:
|
127
127
|
- - ">="
|
128
128
|
- !ruby/object:Gem::Version
|
129
129
|
version: '0'
|
130
130
|
requirements: []
|
131
|
-
rubyforge_project:
|
132
|
-
rubygems_version: 2.4.
|
131
|
+
rubyforge_project:
|
132
|
+
rubygems_version: 2.4.6
|
133
133
|
signing_key:
|
134
134
|
specification_version: 4
|
135
135
|
summary: Entity-relationship diagram for your Rails models.
|