snapbot 0.4.0 → 0.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: fd8932c76924b2ce01335b13174915694258dcd419d5c7da3fe5daa45a7e66c7
4
- data.tar.gz: 9aa4282ef7e47c1789b742f28a977c8ea387d526ed0a8b4d524b6e205120d4f1
3
+ metadata.gz: 3ccc2f9565d40b7b3dd10ffd1f92054e7b718eb28613cdc9336531f35a916204
4
+ data.tar.gz: 661b49c7b72f6a55736a88fcdafc74e249d6d59c8fcbd115b0fcf6c89442ee51
5
5
  SHA512:
6
- metadata.gz: 5c3e26e2eedb55db8876619da0c63fb79754b8c584d3ed1cf6599fbc37d8f8174af90f706bf6c5ee34e88e60a4482ab57b438613c04e426992a0f8ab80b13499
7
- data.tar.gz: 3153f489921edecb2ca66bb7781911d0ff13e3ce563749773e649cb5a8c1c6229cc67f89cfbdcb96e17e9270cfcdc65ea2a4af7aa10e2cec8f29f6977e397357
6
+ metadata.gz: d19d016d55b593f14106933bb66926d5d9b18b1b986deabfd644ab7f5c27dddb33cfe1ed6ef50952aea72d833eda570937ae6dac1be41d7519c06f403cba64d2
7
+ data.tar.gz: 22416a76acec3531aa6487de788068c919e69023d9569237daa7990f3db088fe853a3c0a2594632b0edab29a9ea6013921a5379c24878bc6fd8f3d3e89cf04c1
@@ -1,7 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "open3"
4
-
5
3
  module Snapbot
6
4
  module Diagram
7
5
  # Render some DOT via Graphviz dot command line
@@ -44,6 +44,8 @@ module Snapbot
44
44
 
45
45
  def add_relationships(instance, set)
46
46
  reflect_associations(instance).each do |association|
47
+ next unless valid_association?(association) # Skip POROs
48
+
47
49
  records = Array(instance.send(association.name)).compact
48
50
  records.each do |record|
49
51
  set.add(Relationship.new(instance_name(instance), instance_name(record)))
@@ -65,6 +67,18 @@ module Snapbot
65
67
 
66
68
  private
67
69
 
70
+ # rubocop:disable Style/RescueModifier
71
+ def valid_association?(association)
72
+ # AR7.x raises an ArgumentError when the class is a PORO. AR6.x would fall over
73
+ # later with NoMethodError on `relation_delegate_class`. Either way, we're not
74
+ # valid if the association.klass is not descended from our `base_activerecord_class`
75
+ return true if (association.klass rescue ArgumentError) < base_activerecord_class
76
+
77
+ warn "#{association.active_record} -> :#{association.name} is not a valid association. " \
78
+ "Make sure it inherits from #{base_activerecord_class}"
79
+ end
80
+ # rubocop:enable Style/RescueModifier
81
+
68
82
  def instance_name(instance)
69
83
  "#{instance.model_name}##{instance.id}"
70
84
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Snapbot
4
- VERSION = "0.4.0"
4
+ VERSION = "0.4.1"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: snapbot
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Russell Garner
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-08-10 00:00:00.000000000 Z
11
+ date: 2022-08-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: binding_of_caller