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 +4 -4
- data/.rubocop.yml +1 -1
- data/.ruby-version +1 -1
- data/Gemfile.lock +83 -85
- data/lib/rails/annotate/solargraph/configuration.rb +5 -2
- data/lib/rails/annotate/solargraph/model.rb +11 -4
- data/lib/rails/annotate/solargraph/terminal_colors.rb +1 -0
- data/lib/rails/annotate/solargraph/version.rb +1 -1
- data/lib/rails/annotate/solargraph.rb +21 -1
- data/rails-annotate-solargraph.gemspec +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 58575ab157cd56c94cd086172ab769ca710e29bd15a72403a0fd0829357bab11
|
|
4
|
+
data.tar.gz: 896fdff02aa40756ecc427ef542225080581cc10f039e7a960371c22174e7891
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: d2bebaf3939fd7958b8e64fbe0cf27a397734093dda12143d5ee5fce28efc66cb199260b4e6e2f907e135f62be418df4952ec188478e1f1a6683fedcdd7527e1
|
|
7
|
+
data.tar.gz: 74a3f24690f3871be28af866deb5913e664ef71d8ae194e88d1f4883c09415dfa81430267fa8db42bd71b48709ee7229edf6315a00029d32c8bdbb4ee0f36720
|
data/.rubocop.yml
CHANGED
data/.ruby-version
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
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
|
+
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.
|
|
13
|
-
actionpack (= 7.0.
|
|
14
|
-
activesupport (= 7.0.
|
|
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.
|
|
18
|
-
actionpack (= 7.0.
|
|
19
|
-
activejob (= 7.0.
|
|
20
|
-
activerecord (= 7.0.
|
|
21
|
-
activestorage (= 7.0.
|
|
22
|
-
activesupport (= 7.0.
|
|
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.
|
|
28
|
-
actionpack (= 7.0.
|
|
29
|
-
actionview (= 7.0.
|
|
30
|
-
activejob (= 7.0.
|
|
31
|
-
activesupport (= 7.0.
|
|
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.
|
|
38
|
-
actionview (= 7.0.
|
|
39
|
-
activesupport (= 7.0.
|
|
40
|
-
rack (~> 2.0, >= 2.2.
|
|
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.
|
|
45
|
-
actionpack (= 7.0.
|
|
46
|
-
activerecord (= 7.0.
|
|
47
|
-
activestorage (= 7.0.
|
|
48
|
-
activesupport (= 7.0.
|
|
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.
|
|
52
|
-
activesupport (= 7.0.
|
|
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.
|
|
58
|
-
activesupport (= 7.0.
|
|
57
|
+
activejob (7.0.6)
|
|
58
|
+
activesupport (= 7.0.6)
|
|
59
59
|
globalid (>= 0.3.6)
|
|
60
|
-
activemodel (7.0.
|
|
61
|
-
activesupport (= 7.0.
|
|
62
|
-
activerecord (7.0.
|
|
63
|
-
activemodel (= 7.0.
|
|
64
|
-
activesupport (= 7.0.
|
|
65
|
-
activestorage (7.0.
|
|
66
|
-
actionpack (= 7.0.
|
|
67
|
-
activejob (= 7.0.
|
|
68
|
-
activerecord (= 7.0.
|
|
69
|
-
activesupport (= 7.0.
|
|
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.
|
|
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.
|
|
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.
|
|
87
|
+
erubi (1.12.0)
|
|
88
88
|
git (1.10.2)
|
|
89
89
|
rchardet (~> 1.8)
|
|
90
|
-
globalid (1.
|
|
90
|
+
globalid (1.1.0)
|
|
91
91
|
activesupport (>= 5.0)
|
|
92
|
-
i18n (1.
|
|
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.
|
|
99
|
+
loofah (2.21.3)
|
|
100
100
|
crass (~> 1.0.2)
|
|
101
|
-
nokogiri (>= 1.
|
|
102
|
-
mail (2.
|
|
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.
|
|
110
|
-
|
|
112
|
+
net-imap (0.3.6)
|
|
113
|
+
date
|
|
111
114
|
net-protocol
|
|
112
|
-
|
|
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-
|
|
118
|
-
timeout
|
|
119
|
-
net-smtp (0.3.1)
|
|
120
|
-
digest
|
|
119
|
+
net-smtp (0.3.3)
|
|
121
120
|
net-protocol
|
|
122
|
-
|
|
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.
|
|
134
|
-
rack-test (2.0
|
|
131
|
+
rack (2.2.7)
|
|
132
|
+
rack-test (2.1.0)
|
|
135
133
|
rack (>= 1.3)
|
|
136
|
-
rails (7.0.
|
|
137
|
-
actioncable (= 7.0.
|
|
138
|
-
actionmailbox (= 7.0.
|
|
139
|
-
actionmailer (= 7.0.
|
|
140
|
-
actionpack (= 7.0.
|
|
141
|
-
actiontext (= 7.0.
|
|
142
|
-
actionview (= 7.0.
|
|
143
|
-
activejob (= 7.0.
|
|
144
|
-
activemodel (= 7.0.
|
|
145
|
-
activerecord (= 7.0.
|
|
146
|
-
activestorage (= 7.0.
|
|
147
|
-
activesupport (= 7.0.
|
|
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.
|
|
150
|
-
rails-dom-testing (2.
|
|
151
|
-
activesupport (>=
|
|
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.
|
|
154
|
-
loofah (~> 2.
|
|
155
|
-
railties (7.0.
|
|
156
|
-
actionpack (= 7.0.
|
|
157
|
-
activesupport (= 7.0.
|
|
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.
|
|
201
|
-
tzinfo (2.0.
|
|
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.
|
|
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.
|
|
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
|
-
|
|
21
|
-
|
|
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 =
|
|
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 =
|
|
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
|
|
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
|
|
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)
|
|
@@ -61,11 +61,31 @@ module Rails
|
|
|
61
61
|
|
|
62
62
|
# @return [Array<ActiveRecord::Base>]
|
|
63
63
|
def model_classes
|
|
64
|
-
@model_classes ||=
|
|
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 = ">=
|
|
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
|
+
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:
|
|
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:
|
|
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.
|
|
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
|