rails-annotate-solargraph 0.2.2 → 0.2.3

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: 7d62415c07dd7235a4151593d2def72a55a7f8b7f7785f71eb66fe6996ce657d
4
- data.tar.gz: a4737b994cb8ece0516da3d2e57ba66e05a5243cfc29ad1149f99bb03e1f8d1b
3
+ metadata.gz: 0f1d0f284eac106e51e1abc19eec0d7b8790aab9ee188e1cabea5defb04417da
4
+ data.tar.gz: 392519ce6da6313e8a3308dee6f54b66629ee108120b8abcb94e1d838dc86470
5
5
  SHA512:
6
- metadata.gz: b67bd482cf97936d6b55a9c28b5845a45a53650683cc05a89823427573aee2d66ac9500147b53c8b18ab74c6883f3f3306db864341aa03344ca5c376a6173892
7
- data.tar.gz: 96d4d8aff31ee3a530635959539483572c268164c0214701e7b286cbcde37069419752ea3fd5b0bf466d5480dcdb4637f97952f764b932ea2824b8a14ec025c5
6
+ metadata.gz: 23e25ae122d969be4f5d4081638592e3db7d6ab46adf60cdaf82057953441576d842bc2db79af664371637e332b25c5fee091fe930e53ffd88f97d78a04533c9
7
+ data.tar.gz: 43d0752100b231426877a84665ba8030d5121b8f0d7b07549f2312c7e30cb7f1c0f9c9807b99bc085394fd369cb81a95ec63c15366e92a9eb96116fdb91b8fee
data/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  ## [Unreleased]
2
2
 
3
+ ## [0.2.3] - 2022-04-16
4
+
5
+ - A nicer fix for the previous problem
6
+
3
7
  ## [0.2.2] - 2022-04-16
4
8
 
5
9
  - Inexistent class loading error has been resolved
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- rails-annotate-solargraph (0.2.2)
4
+ rails-annotate-solargraph (0.2.3)
5
5
  rails (>= 5.0, < 8.0)
6
6
 
7
7
  GEM
@@ -15,18 +15,6 @@ module Rails
15
15
  # @return [Regexp]
16
16
  MAGIC_COMMENT_REGEXP = /(^#\s*encoding:.*(?:\n|r\n))|(^# coding:.*(?:\n|\r\n))|(^# -\*- coding:.*(?:\n|\r\n))|(^# -\*- encoding\s?:.*(?:\n|\r\n))|(^#\s*frozen_string_literal:.+(?:\n|\r\n))|(^# -\*- frozen_string_literal\s*:.+-\*-(?:\n|\r\n))/.freeze
17
17
 
18
- class << (FAKE_MODEL_CLASS = Object.new)
19
- def to_s
20
- ::Object.to_s
21
- end
22
-
23
- alias name to_s
24
-
25
- def table_name
26
- '<unknown>'
27
- end
28
- end
29
-
30
18
  class << self
31
19
  # @param type [Symbol, String, nil]
32
20
  # @return [String]
@@ -162,20 +150,22 @@ module Rails
162
150
  reflection_class = begin
163
151
  reflection.klass
164
152
  rescue ::NameError
165
- FAKE_MODEL_CLASS
153
+ Object
166
154
  end
167
155
 
156
+ associated_table_name = reflection_class.try(:table_name) || '<unknown>'
157
+ foreign_key = reflection.try(:foreign_key) || '<unknown>'
168
158
  db_description = \
169
159
  case reflection
170
160
  when ::ActiveRecord::Reflection::BelongsToReflection
171
161
  type_docstring = reflection_class
172
- "`belongs_to` relation with `#{reflection_class}`. Database column `#{@klass.table_name}.#{reflection.foreign_key}`."
162
+ "`belongs_to` relation with `#{reflection_class}`. Database column `#{@klass.table_name}.#{foreign_key}`."
173
163
  when ::ActiveRecord::Reflection::HasOneReflection
174
164
  type_docstring = reflection_class
175
- "`has_one` relation with `#{reflection_class}`. Database column `#{reflection_class.table_name}.#{reflection.foreign_key}`."
165
+ "`has_one` relation with `#{reflection_class}`. Database column `#{associated_table_name}.#{foreign_key}`."
176
166
  when ::ActiveRecord::Reflection::HasManyReflection
177
167
  type_docstring = "Array<#{reflection_class}>"
178
- "`has_many` relation with `#{reflection_class}`. Database column `#{reflection_class.table_name}.#{reflection.foreign_key}`."
168
+ "`has_many` relation with `#{reflection_class}`. Database column `#{associated_table_name}.#{foreign_key}`."
179
169
  end
180
170
 
181
171
  doc_string << <<~DOC
@@ -3,7 +3,7 @@
3
3
  module Rails
4
4
  module Annotate
5
5
  module Solargraph
6
- VERSION = '0.2.2'
6
+ VERSION = '0.2.3'
7
7
  end
8
8
  end
9
9
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rails-annotate-solargraph
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mateusz Drewniak