rails-annotate-solargraph 0.2.0 → 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: 744b5deaf3bfdd5fdf4b81b54abd8f4672336402bce178af67b04ff704b6ceab
4
- data.tar.gz: 062d49842f237ddb38202975c0c88733fb3a825ebcb4c7cbd7641b45b58ee993
3
+ metadata.gz: 0f1d0f284eac106e51e1abc19eec0d7b8790aab9ee188e1cabea5defb04417da
4
+ data.tar.gz: 392519ce6da6313e8a3308dee6f54b66629ee108120b8abcb94e1d838dc86470
5
5
  SHA512:
6
- metadata.gz: 35eb981e6a0b52331164d80fd7238aadae0403cd9f4d93c7dc9a6c00e31714f6b731c23e961542ee5eac64a48c2820de926fcacaea1e6b8ff9b34c501781c05b
7
- data.tar.gz: 6d0f472969a50ed833398216789d0000b8c288685946ab90621f48edca85f57034350df39a5006ae5ddb6b4a30623658c529584e6eca504b0202ff6b633b3379
6
+ metadata.gz: 23e25ae122d969be4f5d4081638592e3db7d6ab46adf60cdaf82057953441576d842bc2db79af664371637e332b25c5fee091fe930e53ffd88f97d78a04533c9
7
+ data.tar.gz: 43d0752100b231426877a84665ba8030d5121b8f0d7b07549f2312c7e30cb7f1c0f9c9807b99bc085394fd369cb81a95ec63c15366e92a9eb96116fdb91b8fee
data/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  ## [Unreleased]
2
2
 
3
+ ## [0.2.3] - 2022-04-16
4
+
5
+ - A nicer fix for the previous problem
6
+
7
+ ## [0.2.2] - 2022-04-16
8
+
9
+ - Inexistent class loading error has been resolved
10
+
11
+ ## [0.2.1] - 2022-04-16
12
+
13
+ - Rakefile template refactoring and bug fix
14
+
3
15
  ## [0.2.0] - 2022-04-16
4
16
 
5
17
  - Associations get fully documented
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- rails-annotate-solargraph (0.2.0)
4
+ rails-annotate-solargraph (0.2.3)
5
5
  rails (>= 5.0, < 8.0)
6
6
 
7
7
  GEM
@@ -1,18 +1,16 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- include ::Rails::Annotate::Solargraph::TerminalColors
4
-
5
3
  if ::Rails.env.development?
6
4
  namespace :annotate do
7
5
  namespace :solargraph do
8
6
  desc "Add YARD comments documenting the models' schemas"
9
7
  task generate: :environment do
10
- system! 'bundle exec bin/rails runner "::Rails::Annotate::Solargraph.generate"'
8
+ ::Rails::Annotate::Solargraph.generate
11
9
  end
12
10
 
13
11
  desc "Remove YARD comments documenting the models' schemas"
14
12
  task remove: :environment do
15
- system! 'bundle exec bin/rails runner "::Rails::Annotate::Solargraph.remove"'
13
+ ::Rails::Annotate::Solargraph.remove
16
14
  end
17
15
  end
18
16
 
@@ -25,8 +23,4 @@ if ::Rails.env.development?
25
23
  end
26
24
  end
27
25
  end
28
-
29
- def system!(val)
30
- system(val) || abort(error_string("Command `#{val}` failed"))
31
- end
32
26
  end
@@ -147,17 +147,25 @@ module Rails
147
147
  # @param reflection [ActiveRecord::Reflection::AbstractReflection]
148
148
  # @return [void]
149
149
  def document_relation(doc_string, attr_name, reflection)
150
+ reflection_class = begin
151
+ reflection.klass
152
+ rescue ::NameError
153
+ Object
154
+ end
155
+
156
+ associated_table_name = reflection_class.try(:table_name) || '<unknown>'
157
+ foreign_key = reflection.try(:foreign_key) || '<unknown>'
150
158
  db_description = \
151
159
  case reflection
152
160
  when ::ActiveRecord::Reflection::BelongsToReflection
153
- type_docstring = reflection.klass
154
- "`belongs_to` relation with `#{reflection.klass}`. Database column `#{@klass.table_name}.#{reflection.foreign_key}`."
161
+ type_docstring = reflection_class
162
+ "`belongs_to` relation with `#{reflection_class}`. Database column `#{@klass.table_name}.#{foreign_key}`."
155
163
  when ::ActiveRecord::Reflection::HasOneReflection
156
- type_docstring = reflection.klass
157
- "`has_one` relation with `#{reflection.klass}`. Database column `#{reflection.klass.table_name}.#{reflection.foreign_key}`."
164
+ type_docstring = reflection_class
165
+ "`has_one` relation with `#{reflection_class}`. Database column `#{associated_table_name}.#{foreign_key}`."
158
166
  when ::ActiveRecord::Reflection::HasManyReflection
159
- type_docstring = "Array<#{reflection.klass}>"
160
- "`has_many` relation with `#{reflection.klass}`. Database column `#{reflection.klass.table_name}.#{reflection.foreign_key}`."
167
+ type_docstring = "Array<#{reflection_class}>"
168
+ "`has_many` relation with `#{reflection_class}`. Database column `#{associated_table_name}.#{foreign_key}`."
161
169
  end
162
170
 
163
171
  doc_string << <<~DOC
@@ -3,7 +3,7 @@
3
3
  module Rails
4
4
  module Annotate
5
5
  module Solargraph
6
- VERSION = '0.2.0'
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.0
4
+ version: 0.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mateusz Drewniak