rails-erd 1.4.0 → 1.4.1
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/lib/rails_erd/diagram.rb +2 -2
- data/lib/rails_erd/domain/attribute.rb +11 -6
- data/lib/rails_erd/tasks.rake +1 -1
- data/lib/rails_erd/version.rb +2 -2
- data/test/test_helper.rb +4 -0
- data/test/unit/attribute_test.rb +2 -2
- data/test/unit/diagram_test.rb +4 -4
- data/test/unit/rake_task_test.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 537ccea2a689d7fc5eafcf6879b4f72f9a143c63
|
4
|
+
data.tar.gz: 22934779369b6203496dc48792b5442697131bfd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1539881900c1f05e0dbafbfba086dd4bcfee51a323c608b5f7d02b362d69818e9c7543a93e4a6d40f18443a243fefe2518fe944507983c466f7ca8724f1e01c3
|
7
|
+
data.tar.gz: 91502bc3daa15a4aff18bdd0cfd1b6993b1b8607f5aed5f5a224d4c36dfd99b5f1fc7d755a29242cdd9c14f726b2aff6fbc55eefcf8d402ee6a04de51cd37a6d
|
data/lib/rails_erd/diagram.rb
CHANGED
@@ -150,8 +150,8 @@ module RailsERD
|
|
150
150
|
|
151
151
|
def filtered_entities
|
152
152
|
@domain.entities.reject { |entity|
|
153
|
-
options.exclude && entity.model && [options.exclude].flatten.include?(entity.name.
|
154
|
-
options.only && entity.model && ![options.only].flatten.include?(entity.name.
|
153
|
+
options.exclude && entity.model && [options.exclude].flatten.include?(entity.name.to_sym) or
|
154
|
+
options.only && entity.model && ![options.only].flatten.include?(entity.name.to_sym) or
|
155
155
|
!options.inheritance && entity.specialized? or
|
156
156
|
!options.polymorphism && entity.generalized? or
|
157
157
|
!options.disconnected && entity.disconnected?
|
@@ -14,13 +14,18 @@ module RailsERD
|
|
14
14
|
attributes.sort! if RailsERD.options[:sort]
|
15
15
|
|
16
16
|
if RailsERD.options[:prepend_primary]
|
17
|
-
|
18
|
-
|
17
|
+
attributes = prepend_primary(model, attributes)
|
18
|
+
end
|
19
|
+
|
20
|
+
attributes
|
21
|
+
end
|
22
|
+
|
23
|
+
def prepend_primary(model, attributes)
|
24
|
+
primary_key = ActiveRecord::Base.get_primary_key(model)
|
25
|
+
primary = attributes.index { |column| column.name == primary_key }
|
19
26
|
|
20
|
-
|
21
|
-
|
22
|
-
attributes.unshift(primary)
|
23
|
-
end
|
27
|
+
if primary
|
28
|
+
attributes[primary], attributes[0] = attributes[0], attributes[primary]
|
24
29
|
end
|
25
30
|
|
26
31
|
attributes
|
data/lib/rails_erd/tasks.rake
CHANGED
@@ -8,7 +8,7 @@ namespace :erd do
|
|
8
8
|
RailsERD.options[option.to_sym] = case ENV[option]
|
9
9
|
when "true", "yes" then true
|
10
10
|
when "false", "no" then false
|
11
|
-
when /,/ then ENV[option].split(/\s*,\s*/)
|
11
|
+
when /,/ then ENV[option].split(/\s*,\s*/)
|
12
12
|
else ENV[option].to_sym
|
13
13
|
end
|
14
14
|
end
|
data/lib/rails_erd/version.rb
CHANGED
data/test/test_helper.rb
CHANGED
@@ -11,6 +11,10 @@ require "rails_erd/domain"
|
|
11
11
|
|
12
12
|
ActiveRecord::Base.establish_connection :adapter => "sqlite3", :database => ":memory:"
|
13
13
|
|
14
|
+
if ActiveSupport::TestCase.respond_to?(:test_order=)
|
15
|
+
ActiveSupport::TestCase.test_order = :random
|
16
|
+
end
|
17
|
+
|
14
18
|
class ActiveSupport::TestCase
|
15
19
|
include RailsERD
|
16
20
|
|
data/test/unit/attribute_test.rb
CHANGED
@@ -44,8 +44,8 @@ class AttributeTest < ActiveSupport::TestCase
|
|
44
44
|
assert_equal %w{id a}, Domain::Attribute.from_model(Domain.new, Foo).map(&:name)
|
45
45
|
end
|
46
46
|
|
47
|
-
test "from_model should return attributes with PK first if
|
48
|
-
RailsERD.options[:sort] =
|
47
|
+
test "from_model should return attributes with PK first if prepend_primary is true" do
|
48
|
+
RailsERD.options[:sort] = true
|
49
49
|
RailsERD.options[:prepend_primary] = true
|
50
50
|
|
51
51
|
create_model "Foo"
|
data/test/unit/diagram_test.rb
CHANGED
@@ -126,27 +126,27 @@ class DiagramTest < ActiveSupport::TestCase
|
|
126
126
|
test "generate should filter excluded entity" do
|
127
127
|
create_model "Book"
|
128
128
|
create_model "Author"
|
129
|
-
assert_equal [Book], retrieve_entities(:exclude => [
|
129
|
+
assert_equal [Book], retrieve_entities(:exclude => [:Author]).map(&:model)
|
130
130
|
end
|
131
131
|
|
132
132
|
test "generate should filter excluded entities" do
|
133
133
|
create_model "Book"
|
134
134
|
create_model "Author"
|
135
135
|
create_model "Editor"
|
136
|
-
assert_equal [Book], retrieve_entities(:exclude => [
|
136
|
+
assert_equal [Book], retrieve_entities(:exclude => [:Author, :Editor]).map(&:model)
|
137
137
|
end
|
138
138
|
|
139
139
|
test "generate should include only specified entity" do
|
140
140
|
create_model "Book"
|
141
141
|
create_model "Author"
|
142
|
-
assert_equal [Book], retrieve_entities(:only => [
|
142
|
+
assert_equal [Book], retrieve_entities(:only => [:Book]).map(&:model)
|
143
143
|
end
|
144
144
|
|
145
145
|
test "generate should include only specified entities" do
|
146
146
|
create_model "Book"
|
147
147
|
create_model "Author"
|
148
148
|
create_model "Editor"
|
149
|
-
assert_equal [Author, Editor], retrieve_entities(:only => [
|
149
|
+
assert_equal [Author, Editor], retrieve_entities(:only => [:Author, :Editor]).map(&:model)
|
150
150
|
end
|
151
151
|
|
152
152
|
test "generate should filter disconnected entities if disconnected is false" do
|
data/test/unit/rake_task_test.rb
CHANGED
@@ -160,6 +160,6 @@ Error occurred while loading application: FooBar (RuntimeError)
|
|
160
160
|
test "options task should set known array command line options" do
|
161
161
|
ENV["attributes"] = "content,timestamps"
|
162
162
|
Rake::Task["erd:options"].execute
|
163
|
-
assert_equal [
|
163
|
+
assert_equal %w[content timestamps], RailsERD.options.attributes
|
164
164
|
end
|
165
165
|
end
|
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.
|
4
|
+
version: 1.4.1
|
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-07-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|