rails-annotate-solargraph 0.5.4 → 0.5.5

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: ec69805fa2a76baa2426ff33c59c38e0718a6a4eec157f22316f763dd54f3bfa
4
- data.tar.gz: c4117b15f2c46581519cb45fac4c29ddc8f23eed4e681884d2f4937d9517b891
3
+ metadata.gz: 58575ab157cd56c94cd086172ab769ca710e29bd15a72403a0fd0829357bab11
4
+ data.tar.gz: 896fdff02aa40756ecc427ef542225080581cc10f039e7a960371c22174e7891
5
5
  SHA512:
6
- metadata.gz: a3a8ab7da803667329851ed7ea9f05671c5ada593a6250f6dd880e3a58361690cbd9aee652ad9664f017b83708e801d0d186c02d21f174309aaddeba878cfd4f
7
- data.tar.gz: df176e7c898dfd3d1df49107fdcf7cff30e9307a9d2f36e215fc927fe6d7d56ece4c3807e617452e0d6f5c448f4afbf7d9bba01f1fe0c4aa51836db6a9170b73
6
+ metadata.gz: d2bebaf3939fd7958b8e64fbe0cf27a397734093dda12143d5ee5fce28efc66cb199260b4e6e2f907e135f62be418df4952ec188478e1f1a6683fedcdd7527e1
7
+ data.tar.gz: 74a3f24690f3871be28af866deb5913e664ef71d8ae194e88d1f4883c09415dfa81430267fa8db42bd71b48709ee7229edf6315a00029d32c8bdbb4ee0f36720
data/.rubocop.yml CHANGED
@@ -1,5 +1,5 @@
1
1
  AllCops:
2
- TargetRubyVersion: 2.7
2
+ TargetRubyVersion: 3.0
3
3
 
4
4
  Style/StringLiterals:
5
5
  Enabled: false
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- 2.7.6
1
+ 3.0.6
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- rails-annotate-solargraph (0.5.4)
4
+ rails-annotate-solargraph (0.5.5)
5
5
  parser (~> 3)
6
6
  rails (>= 5.0, < 8.0)
7
7
  yard
@@ -9,67 +9,67 @@ PATH
9
9
  GEM
10
10
  remote: https://rubygems.org/
11
11
  specs:
12
- actioncable (7.0.3.1)
13
- actionpack (= 7.0.3.1)
14
- activesupport (= 7.0.3.1)
12
+ actioncable (7.0.6)
13
+ actionpack (= 7.0.6)
14
+ activesupport (= 7.0.6)
15
15
  nio4r (~> 2.0)
16
16
  websocket-driver (>= 0.6.1)
17
- actionmailbox (7.0.3.1)
18
- actionpack (= 7.0.3.1)
19
- activejob (= 7.0.3.1)
20
- activerecord (= 7.0.3.1)
21
- activestorage (= 7.0.3.1)
22
- activesupport (= 7.0.3.1)
17
+ actionmailbox (7.0.6)
18
+ actionpack (= 7.0.6)
19
+ activejob (= 7.0.6)
20
+ activerecord (= 7.0.6)
21
+ activestorage (= 7.0.6)
22
+ activesupport (= 7.0.6)
23
23
  mail (>= 2.7.1)
24
24
  net-imap
25
25
  net-pop
26
26
  net-smtp
27
- actionmailer (7.0.3.1)
28
- actionpack (= 7.0.3.1)
29
- actionview (= 7.0.3.1)
30
- activejob (= 7.0.3.1)
31
- activesupport (= 7.0.3.1)
27
+ actionmailer (7.0.6)
28
+ actionpack (= 7.0.6)
29
+ actionview (= 7.0.6)
30
+ activejob (= 7.0.6)
31
+ activesupport (= 7.0.6)
32
32
  mail (~> 2.5, >= 2.5.4)
33
33
  net-imap
34
34
  net-pop
35
35
  net-smtp
36
36
  rails-dom-testing (~> 2.0)
37
- actionpack (7.0.3.1)
38
- actionview (= 7.0.3.1)
39
- activesupport (= 7.0.3.1)
40
- rack (~> 2.0, >= 2.2.0)
37
+ actionpack (7.0.6)
38
+ actionview (= 7.0.6)
39
+ activesupport (= 7.0.6)
40
+ rack (~> 2.0, >= 2.2.4)
41
41
  rack-test (>= 0.6.3)
42
42
  rails-dom-testing (~> 2.0)
43
43
  rails-html-sanitizer (~> 1.0, >= 1.2.0)
44
- actiontext (7.0.3.1)
45
- actionpack (= 7.0.3.1)
46
- activerecord (= 7.0.3.1)
47
- activestorage (= 7.0.3.1)
48
- activesupport (= 7.0.3.1)
44
+ actiontext (7.0.6)
45
+ actionpack (= 7.0.6)
46
+ activerecord (= 7.0.6)
47
+ activestorage (= 7.0.6)
48
+ activesupport (= 7.0.6)
49
49
  globalid (>= 0.6.0)
50
50
  nokogiri (>= 1.8.5)
51
- actionview (7.0.3.1)
52
- activesupport (= 7.0.3.1)
51
+ actionview (7.0.6)
52
+ activesupport (= 7.0.6)
53
53
  builder (~> 3.1)
54
54
  erubi (~> 1.4)
55
55
  rails-dom-testing (~> 2.0)
56
56
  rails-html-sanitizer (~> 1.1, >= 1.2.0)
57
- activejob (7.0.3.1)
58
- activesupport (= 7.0.3.1)
57
+ activejob (7.0.6)
58
+ activesupport (= 7.0.6)
59
59
  globalid (>= 0.3.6)
60
- activemodel (7.0.3.1)
61
- activesupport (= 7.0.3.1)
62
- activerecord (7.0.3.1)
63
- activemodel (= 7.0.3.1)
64
- activesupport (= 7.0.3.1)
65
- activestorage (7.0.3.1)
66
- actionpack (= 7.0.3.1)
67
- activejob (= 7.0.3.1)
68
- activerecord (= 7.0.3.1)
69
- activesupport (= 7.0.3.1)
60
+ activemodel (7.0.6)
61
+ activesupport (= 7.0.6)
62
+ activerecord (7.0.6)
63
+ activemodel (= 7.0.6)
64
+ activesupport (= 7.0.6)
65
+ activestorage (7.0.6)
66
+ actionpack (= 7.0.6)
67
+ activejob (= 7.0.6)
68
+ activerecord (= 7.0.6)
69
+ activesupport (= 7.0.6)
70
70
  marcel (~> 1.0)
71
71
  mini_mime (>= 1.1.0)
72
- activesupport (7.0.3.1)
72
+ activesupport (7.0.6)
73
73
  concurrent-ruby (~> 1.0, >= 1.0.2)
74
74
  i18n (>= 1.6, < 2)
75
75
  minitest (>= 5.1)
@@ -79,48 +79,46 @@ GEM
79
79
  benchmark (0.2.0)
80
80
  builder (3.2.4)
81
81
  byebug (11.1.3)
82
- concurrent-ruby (1.1.10)
82
+ concurrent-ruby (1.2.2)
83
83
  crass (1.0.6)
84
+ date (3.3.3)
84
85
  diff-lcs (1.5.0)
85
- digest (3.1.0)
86
86
  e2mmap (0.1.0)
87
- erubi (1.11.0)
87
+ erubi (1.12.0)
88
88
  git (1.10.2)
89
89
  rchardet (~> 1.8)
90
- globalid (1.0.0)
90
+ globalid (1.1.0)
91
91
  activesupport (>= 5.0)
92
- i18n (1.12.0)
92
+ i18n (1.14.1)
93
93
  concurrent-ruby (~> 1.0)
94
94
  jaro_winkler (1.5.4)
95
95
  kramdown (2.3.2)
96
96
  rexml
97
97
  kramdown-parser-gfm (1.1.0)
98
98
  kramdown (~> 2.0)
99
- loofah (2.18.0)
99
+ loofah (2.21.3)
100
100
  crass (~> 1.0.2)
101
- nokogiri (>= 1.5.9)
102
- mail (2.7.1)
101
+ nokogiri (>= 1.12.0)
102
+ mail (2.8.1)
103
103
  mini_mime (>= 0.1.1)
104
+ net-imap
105
+ net-pop
106
+ net-smtp
104
107
  marcel (1.0.2)
105
108
  method_source (1.0.0)
106
109
  mini_mime (1.1.2)
107
110
  mini_portile2 (2.8.0)
108
111
  minitest (5.15.0)
109
- net-imap (0.2.3)
110
- digest
112
+ net-imap (0.3.6)
113
+ date
111
114
  net-protocol
112
- strscan
113
- net-pop (0.1.1)
114
- digest
115
+ net-pop (0.1.2)
115
116
  net-protocol
117
+ net-protocol (0.2.1)
116
118
  timeout
117
- net-protocol (0.1.3)
118
- timeout
119
- net-smtp (0.3.1)
120
- digest
119
+ net-smtp (0.3.3)
121
120
  net-protocol
122
- timeout
123
- nio4r (2.5.8)
121
+ nio4r (2.5.9)
124
122
  nokogiri (1.13.4)
125
123
  mini_portile2 (~> 2.8.0)
126
124
  racc (~> 1.4)
@@ -130,31 +128,32 @@ GEM
130
128
  parser (3.1.1.0)
131
129
  ast (~> 2.4.1)
132
130
  racc (1.6.0)
133
- rack (2.2.4)
134
- rack-test (2.0.2)
131
+ rack (2.2.7)
132
+ rack-test (2.1.0)
135
133
  rack (>= 1.3)
136
- rails (7.0.3.1)
137
- actioncable (= 7.0.3.1)
138
- actionmailbox (= 7.0.3.1)
139
- actionmailer (= 7.0.3.1)
140
- actionpack (= 7.0.3.1)
141
- actiontext (= 7.0.3.1)
142
- actionview (= 7.0.3.1)
143
- activejob (= 7.0.3.1)
144
- activemodel (= 7.0.3.1)
145
- activerecord (= 7.0.3.1)
146
- activestorage (= 7.0.3.1)
147
- activesupport (= 7.0.3.1)
134
+ rails (7.0.6)
135
+ actioncable (= 7.0.6)
136
+ actionmailbox (= 7.0.6)
137
+ actionmailer (= 7.0.6)
138
+ actionpack (= 7.0.6)
139
+ actiontext (= 7.0.6)
140
+ actionview (= 7.0.6)
141
+ activejob (= 7.0.6)
142
+ activemodel (= 7.0.6)
143
+ activerecord (= 7.0.6)
144
+ activestorage (= 7.0.6)
145
+ activesupport (= 7.0.6)
148
146
  bundler (>= 1.15.0)
149
- railties (= 7.0.3.1)
150
- rails-dom-testing (2.0.3)
151
- activesupport (>= 4.2.0)
147
+ railties (= 7.0.6)
148
+ rails-dom-testing (2.1.1)
149
+ activesupport (>= 5.0.0)
150
+ minitest
152
151
  nokogiri (>= 1.6)
153
- rails-html-sanitizer (1.4.3)
154
- loofah (~> 2.3)
155
- railties (7.0.3.1)
156
- actionpack (= 7.0.3.1)
157
- activesupport (= 7.0.3.1)
152
+ rails-html-sanitizer (1.5.0)
153
+ loofah (~> 2.19, >= 2.19.1)
154
+ railties (7.0.6)
155
+ actionpack (= 7.0.6)
156
+ activesupport (= 7.0.6)
158
157
  method_source
159
158
  rake (>= 12.2)
160
159
  thor (~> 1.0)
@@ -194,20 +193,19 @@ GEM
194
193
  tilt (~> 2.0)
195
194
  yard (~> 0.9, >= 0.9.24)
196
195
  sqlite3 (1.4.2)
197
- strscan (3.0.4)
198
196
  thor (1.2.1)
199
197
  tilt (2.0.10)
200
- timeout (0.3.0)
201
- tzinfo (2.0.5)
198
+ timeout (0.4.0)
199
+ tzinfo (2.0.6)
202
200
  concurrent-ruby (~> 1.0)
203
201
  unicode-display_width (2.1.0)
204
202
  webrick (1.7.0)
205
- websocket-driver (0.7.5)
203
+ websocket-driver (0.7.6)
206
204
  websocket-extensions (>= 0.1.0)
207
205
  websocket-extensions (0.1.5)
208
206
  yard (0.9.27)
209
207
  webrick (~> 1.7.0)
210
- zeitwerk (2.6.0)
208
+ zeitwerk (2.6.9)
211
209
 
212
210
  PLATFORMS
213
211
  arm64-darwin-20
@@ -17,8 +17,11 @@ module Rails
17
17
 
18
18
  # @param val [Symbol]
19
19
  def annotation_position=(val)
20
- raise Error, "`annotation_position` is incorrect! Got `#{val.inspect}`, expected a member of `#{ANNOTATION_POSITIONS.inspect}`" \
21
- unless ANNOTATION_POSITIONS.include?(val)
20
+ unless ANNOTATION_POSITIONS.include?(val)
21
+ raise Error,
22
+ "`annotation_position` is incorrect! Got `#{val.inspect}`, " \
23
+ "expected a member of `#{ANNOTATION_POSITIONS.inspect}`"
24
+ end
22
25
 
23
26
  @annotation_position = val
24
27
  end
@@ -9,7 +9,8 @@ module Rails
9
9
  using TerminalColors::Refinement
10
10
 
11
11
  # @return [Regexp]
12
- 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
12
+ MAGIC_COMMENT_REGEXP =
13
+ /(^#\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))/
13
14
 
14
15
  # @return [Hash{Symbol => String}]
15
16
  TYPE_MAP = {
@@ -86,7 +87,12 @@ module Rails
86
87
  # @param klass [Class]
87
88
  def initialize(klass)
88
89
  @klass = klass
89
- @file_name = CONFIG.schema_file? ? SCHEMA_RAILS_PATH : ::File.join(::Rails.root, MODEL_DIR, "#{klass.to_s.underscore}.rb")
90
+ @file_name =
91
+ if CONFIG.schema_file?
92
+ SCHEMA_RAILS_PATH
93
+ else
94
+ ::File.join(::Rails.root, MODEL_DIR, "#{klass.to_s.underscore}.rb")
95
+ end
90
96
  end
91
97
 
92
98
  # @return [String]
@@ -104,10 +110,11 @@ module Rails
104
110
  self.class.annotation_regexp(@klass)
105
111
  end
106
112
 
107
- # @param :write [Boolean]
113
+ # @param write [Boolean]
108
114
  # @return [String] New file content.
109
115
  def annotate(write: true)
110
116
  old_content, file_content = remove_annotation write: false
117
+ return old_content if @klass.abstract_class
111
118
 
112
119
  if CONFIG.annotation_position == :top
113
120
  magic_comments = file_content.scan(MAGIC_COMMENT_REGEXP).flatten.compact.join
@@ -125,7 +132,7 @@ module Rails
125
132
  new_file_content
126
133
  end
127
134
 
128
- # @param :write [Boolean]
135
+ # @param write [Boolean]
129
136
  # @return [Array<String>] Old file content followed by new content.
130
137
  def remove_annotation(write: true)
131
138
  return ['', ''] unless ::File.exist?(@file_name)
@@ -69,6 +69,7 @@ module Rails
69
69
  end
70
70
  end
71
71
  end
72
+
72
73
  end
73
74
  end
74
75
  end
@@ -3,7 +3,7 @@
3
3
  module Rails
4
4
  module Annotate
5
5
  module Solargraph
6
- VERSION = '0.5.4'
6
+ VERSION = '0.5.5'
7
7
  end
8
8
  end
9
9
  end
@@ -61,11 +61,31 @@ module Rails
61
61
 
62
62
  # @return [Array<ActiveRecord::Base>]
63
63
  def model_classes
64
- @model_classes ||= (::ApplicationRecord rescue ::ActiveRecord::Base).subclasses.sort_by(&:name)
64
+ @model_classes ||= begin
65
+ base_abstract_class = begin
66
+ ::ApplicationRecord
67
+ rescue
68
+ ::ActiveRecord::Base
69
+ end
70
+
71
+ extract_subclasses(base_abstract_class).sort_by(&:name)
72
+ end
65
73
  end
66
74
 
67
75
  private
68
76
 
77
+ # @param klass [Class]
78
+ # @return [Array<Class>]
79
+ def extract_subclasses(klass)
80
+ result = []
81
+ klass.subclasses.each do |k|
82
+ result << k
83
+ result.concat(extract_subclasses(k))
84
+ end
85
+
86
+ result
87
+ end
88
+
69
89
  include TerminalColors
70
90
 
71
91
  def create_schema_file
@@ -12,7 +12,7 @@ Gem::Specification.new do |spec|
12
12
  spec.description = "Annotate ActiveRecord models with schema comments formatted in YARD that are compatible with Solargraph."
13
13
  spec.homepage = "https://gitlab.com/mateuszdrewniak/rails-annotate-solargraph"
14
14
  spec.license = "MIT"
15
- spec.required_ruby_version = ">= 2.7.0"
15
+ spec.required_ruby_version = ">= 3.0.0"
16
16
 
17
17
  spec.metadata["homepage_uri"] = spec.homepage
18
18
  spec.metadata["source_code_uri"] = "https://gitlab.com/mateuszdrewniak/rails-annotate-solargraph"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rails-annotate-solargraph
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.4
4
+ version: 0.5.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mateusz Drewniak
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-08-12 00:00:00.000000000 Z
11
+ date: 2023-07-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -108,14 +108,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
108
108
  requirements:
109
109
  - - ">="
110
110
  - !ruby/object:Gem::Version
111
- version: 2.7.0
111
+ version: 3.0.0
112
112
  required_rubygems_version: !ruby/object:Gem::Requirement
113
113
  requirements:
114
114
  - - ">="
115
115
  - !ruby/object:Gem::Version
116
116
  version: '0'
117
117
  requirements: []
118
- rubygems_version: 3.1.6
118
+ rubygems_version: 3.2.33
119
119
  signing_key:
120
120
  specification_version: 4
121
121
  summary: Annotate ActiveRecord models with schema comments formatted in YARD that