rails-erd 1.6.0 → 1.6.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 +5 -5
- data/lib/rails_erd/domain.rb +7 -1
- data/lib/rails_erd/version.rb +1 -1
- data/test/test_helper.rb +13 -0
- data/test/unit/attribute_test.rb +10 -11
- metadata +7 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 16bfef1b79087e3017df7723bef8cf286df5a812
|
4
|
+
data.tar.gz: 7162f90b6dce224a0ec89693e7d307fbc15a9b45
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 34e2582512bfe6313f626d4de969eebc328415c97456b1cd151df3e19d75e55cc0b65a9ded7ba0c363d3708072d001266d96657e2a8669ee6a7c4ca7b0cc3ee0
|
7
|
+
data.tar.gz: 16ddf4ba4c7d640a4c139905fe6f238f76c70cf20712c467ebb9bf9075f0ee6603c0c532114b86bd0e66f7d275f5ae0200802e91c8978a469c6e39208dd3c709
|
data/lib/rails_erd/domain.rb
CHANGED
@@ -49,7 +49,13 @@ module RailsERD
|
|
49
49
|
# Returns the domain model name, which is the name of your Rails
|
50
50
|
# application or +nil+ outside of Rails.
|
51
51
|
def name
|
52
|
-
defined?
|
52
|
+
return unless defined?(Rails) && Rails.application
|
53
|
+
|
54
|
+
if Rails.application.class.respond_to?(:module_parent)
|
55
|
+
Rails.application.class.module_parent.name
|
56
|
+
else
|
57
|
+
Rails.application.class.parent.name
|
58
|
+
end
|
53
59
|
end
|
54
60
|
|
55
61
|
# Returns all entities of your domain model.
|
data/lib/rails_erd/version.rb
CHANGED
data/test/test_helper.rb
CHANGED
@@ -16,6 +16,14 @@ if ActiveSupport::TestCase.respond_to?(:test_order=)
|
|
16
16
|
ActiveSupport::TestCase.test_order = :random
|
17
17
|
end
|
18
18
|
|
19
|
+
# Patch to make Rails 6.1 work.
|
20
|
+
module Kernel
|
21
|
+
# class_eval on an object acts like singleton_class.class_eval.
|
22
|
+
def class_eval(*args, &block)
|
23
|
+
singleton_class.class_eval(*args, &block)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
19
27
|
class ActiveSupport::TestCase
|
20
28
|
include RailsERD
|
21
29
|
|
@@ -171,6 +179,11 @@ class ActiveSupport::TestCase
|
|
171
179
|
|
172
180
|
parts[1..-1].inject([[Object, parts.first.to_sym]]) do |pairs,string|
|
173
181
|
last_parent, last_child = pairs.last
|
182
|
+
# Fixes for Rails 6. No idea if this is actually correct as I can't decipher what the heck is going on in this
|
183
|
+
# code.
|
184
|
+
if last_child == :ActiveRecord || last_child == :primary
|
185
|
+
break []
|
186
|
+
end
|
174
187
|
|
175
188
|
break pairs unless last_parent.const_defined?(last_child)
|
176
189
|
|
data/test/unit/attribute_test.rb
CHANGED
@@ -3,9 +3,9 @@ require File.expand_path("../test_helper", File.dirname(__FILE__))
|
|
3
3
|
|
4
4
|
class AttributeTest < ActiveSupport::TestCase
|
5
5
|
def with_native_limit(type, new_limit)
|
6
|
-
ActiveRecord::Base.connection.class_eval do
|
6
|
+
ActiveRecord::Base.connection.singleton_class.class_eval do
|
7
7
|
undef :native_database_types
|
8
|
-
define_method
|
8
|
+
define_method(:native_database_types) do
|
9
9
|
super().tap do |types|
|
10
10
|
types[type][:limit] = new_limit
|
11
11
|
end
|
@@ -13,9 +13,9 @@ class AttributeTest < ActiveSupport::TestCase
|
|
13
13
|
end
|
14
14
|
yield
|
15
15
|
ensure
|
16
|
-
ActiveRecord::Base.connection.class_eval do
|
16
|
+
ActiveRecord::Base.connection.singleton_class.class_eval do
|
17
17
|
undef :native_database_types
|
18
|
-
define_method
|
18
|
+
define_method(:native_database_types) do
|
19
19
|
super()
|
20
20
|
end
|
21
21
|
end
|
@@ -266,14 +266,14 @@ class AttributeTest < ActiveSupport::TestCase
|
|
266
266
|
end
|
267
267
|
|
268
268
|
test "limit should return nil for oddball column types that misuse the limit attribute" do
|
269
|
-
create_model "Business", :location => :integer
|
270
|
-
|
271
|
-
attribute.column.class_eval do
|
272
|
-
define_method :limit do
|
269
|
+
create_model "Business", :location => :integer do
|
270
|
+
define_singleton_method :limit do
|
273
271
|
# https://github.com/voormedia/rails-erd/issues/21
|
274
272
|
{ :srid => 4326, :type => "point", :geographic => true }
|
275
273
|
end
|
276
274
|
end
|
275
|
+
|
276
|
+
attribute = create_attribute(Business, "location")
|
277
277
|
assert_nil attribute.limit
|
278
278
|
end
|
279
279
|
|
@@ -306,13 +306,12 @@ class AttributeTest < ActiveSupport::TestCase
|
|
306
306
|
end
|
307
307
|
|
308
308
|
test "scale should return nil for oddball column types that misuse the scale attribute" do
|
309
|
-
create_model "Kobold", :size => :integer
|
310
|
-
attribute = create_attribute(Kobold, "size")
|
311
|
-
attribute.column.class_eval do
|
309
|
+
create_model "Kobold", :size => :integer do
|
312
310
|
define_method :scale do
|
313
311
|
1..5
|
314
312
|
end
|
315
313
|
end
|
314
|
+
attribute = create_attribute(Kobold, "size")
|
316
315
|
assert_nil attribute.scale
|
317
316
|
end
|
318
317
|
end
|
metadata
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rails-erd
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.6.
|
4
|
+
version: 1.6.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Rolf Timmermans
|
8
8
|
- Kerri Miller
|
9
|
-
autorequire:
|
9
|
+
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2021-02-16 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activerecord
|
@@ -147,7 +147,7 @@ homepage: https://github.com/voormedia/rails-erd
|
|
147
147
|
licenses:
|
148
148
|
- MIT
|
149
149
|
metadata: {}
|
150
|
-
post_install_message:
|
150
|
+
post_install_message:
|
151
151
|
rdoc_options: []
|
152
152
|
require_paths:
|
153
153
|
- lib
|
@@ -162,9 +162,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
162
162
|
- !ruby/object:Gem::Version
|
163
163
|
version: '0'
|
164
164
|
requirements: []
|
165
|
-
rubyforge_project:
|
166
|
-
rubygems_version: 2.
|
167
|
-
signing_key:
|
165
|
+
rubyforge_project:
|
166
|
+
rubygems_version: 2.6.14
|
167
|
+
signing_key:
|
168
168
|
specification_version: 4
|
169
169
|
summary: Entity-relationship diagram for your Rails models.
|
170
170
|
test_files:
|