annotaterb 4.1.1 → 4.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +68 -0
- data/VERSION +1 -1
- data/exe/annotaterb +7 -7
- data/lib/annotate_rb/active_record_patch.rb +2 -0
- data/lib/annotate_rb/commands/annotate_models.rb +0 -1
- data/lib/annotate_rb/commands/annotate_routes.rb +0 -1
- data/lib/annotate_rb/commands/print_help.rb +0 -1
- data/lib/annotate_rb/commands/print_version.rb +0 -1
- data/lib/annotate_rb/commands.rb +4 -4
- data/lib/annotate_rb/config_finder.rb +1 -1
- data/lib/annotate_rb/config_loader.rb +2 -2
- data/lib/annotate_rb/core.rb +3 -3
- data/lib/annotate_rb/helper.rb +16 -0
- data/lib/annotate_rb/model_annotator/{annotation_generator.rb → annotation_builder.rb} +18 -14
- data/lib/annotate_rb/model_annotator/annotation_decider.rb +10 -12
- data/lib/annotate_rb/model_annotator/annotation_diff.rb +1 -1
- data/lib/annotate_rb/model_annotator/annotation_diff_generator.rb +9 -9
- data/lib/annotate_rb/model_annotator/annotation_pattern_generator.rb +3 -3
- data/lib/annotate_rb/model_annotator/annotator.rb +12 -53
- data/lib/annotate_rb/model_annotator/column_annotation/annotation_builder.rb +135 -0
- data/lib/annotate_rb/model_annotator/column_annotation/attributes_builder.rb +104 -0
- data/lib/annotate_rb/model_annotator/column_annotation/column_wrapper.rb +103 -0
- data/lib/annotate_rb/model_annotator/column_annotation/type_builder.rb +54 -0
- data/lib/annotate_rb/model_annotator/column_annotation.rb +12 -0
- data/lib/annotate_rb/model_annotator/file_builder.rb +58 -0
- data/lib/annotate_rb/model_annotator/file_components.rb +78 -0
- data/lib/annotate_rb/model_annotator/file_name_resolver.rb +3 -3
- data/lib/annotate_rb/model_annotator/foreign_key_annotation/annotation_builder.rb +57 -0
- data/lib/annotate_rb/model_annotator/foreign_key_annotation.rb +9 -0
- data/lib/annotate_rb/model_annotator/index_annotation/annotation_builder.rb +113 -0
- data/lib/annotate_rb/model_annotator/index_annotation.rb +9 -0
- data/lib/annotate_rb/model_annotator/magic_comment_parser.rb +32 -0
- data/lib/annotate_rb/model_annotator/model_class_getter.rb +6 -6
- data/lib/annotate_rb/model_annotator/model_files_getter.rb +12 -10
- data/lib/annotate_rb/model_annotator/model_wrapper.rb +44 -37
- data/lib/annotate_rb/model_annotator/pattern_getter.rb +142 -10
- data/lib/annotate_rb/model_annotator/project_annotation_remover.rb +65 -0
- data/lib/annotate_rb/model_annotator/project_annotator.rb +63 -0
- data/lib/annotate_rb/model_annotator/related_files_list_builder.rb +16 -18
- data/lib/annotate_rb/model_annotator/single_file_annotation_remover.rb +37 -0
- data/lib/annotate_rb/model_annotator/single_file_annotator.rb +49 -0
- data/lib/annotate_rb/model_annotator/{file_annotator_instruction.rb → single_file_annotator_instruction.rb} +2 -2
- data/lib/annotate_rb/model_annotator/single_file_remove_annotation_instruction.rb +15 -0
- data/lib/annotate_rb/model_annotator.rb +25 -26
- data/lib/annotate_rb/options.rb +20 -25
- data/lib/annotate_rb/parser.rb +150 -142
- data/lib/annotate_rb/rake_bootstrapper.rb +8 -8
- data/lib/annotate_rb/route_annotator/annotation_processor.rb +7 -8
- data/lib/annotate_rb/route_annotator/annotator.rb +2 -2
- data/lib/annotate_rb/route_annotator/base_processor.rb +3 -3
- data/lib/annotate_rb/route_annotator/header_generator.rb +15 -15
- data/lib/annotate_rb/route_annotator/helper.rb +9 -9
- data/lib/annotate_rb/route_annotator/removal_processor.rb +4 -4
- data/lib/annotate_rb/route_annotator.rb +6 -6
- data/lib/annotate_rb/runner.rb +0 -4
- data/lib/annotate_rb/tasks/annotate_models_migrate.rake +5 -5
- data/lib/annotate_rb.rb +19 -19
- data/lib/generators/annotate_rb/install/install_generator.rb +3 -2
- data/lib/generators/annotate_rb/install/templates/annotate_rb.rake +1 -1
- metadata +22 -16
- data/lib/annotate_rb/model_annotator/column_annotation_builder.rb +0 -92
- data/lib/annotate_rb/model_annotator/column_attributes_builder.rb +0 -102
- data/lib/annotate_rb/model_annotator/column_type_builder.rb +0 -51
- data/lib/annotate_rb/model_annotator/column_wrapper.rb +0 -84
- data/lib/annotate_rb/model_annotator/constants.rb +0 -22
- data/lib/annotate_rb/model_annotator/file_annotation_remover.rb +0 -25
- data/lib/annotate_rb/model_annotator/file_annotator.rb +0 -77
- data/lib/annotate_rb/model_annotator/file_patterns.rb +0 -129
- data/lib/annotate_rb/model_annotator/foreign_key_annotation_builder.rb +0 -55
- data/lib/annotate_rb/model_annotator/helper.rb +0 -107
- data/lib/annotate_rb/model_annotator/index_annotation_builder.rb +0 -74
- data/lib/annotate_rb/model_annotator/model_file_annotator.rb +0 -55
@@ -0,0 +1,15 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module AnnotateRb
|
4
|
+
module ModelAnnotator
|
5
|
+
# A plain old Ruby object (PORO) that contains all necessary information for SingleFileAnnotationRemover
|
6
|
+
class SingleFileRemoveAnnotationInstruction
|
7
|
+
def initialize(file, options = {})
|
8
|
+
@file = file # Path to file
|
9
|
+
@options = options
|
10
|
+
end
|
11
|
+
|
12
|
+
attr_reader :file, :options
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -2,31 +2,30 @@
|
|
2
2
|
|
3
3
|
module AnnotateRb
|
4
4
|
module ModelAnnotator
|
5
|
-
autoload :Annotator,
|
6
|
-
autoload :
|
7
|
-
autoload :
|
8
|
-
autoload :
|
9
|
-
autoload :
|
10
|
-
autoload :
|
11
|
-
autoload :
|
12
|
-
autoload :
|
13
|
-
autoload :
|
14
|
-
autoload :
|
15
|
-
autoload :
|
16
|
-
autoload :
|
17
|
-
autoload :
|
18
|
-
autoload :
|
19
|
-
autoload :
|
20
|
-
autoload :
|
21
|
-
autoload :
|
22
|
-
autoload :
|
23
|
-
autoload :
|
24
|
-
autoload :
|
25
|
-
autoload :
|
26
|
-
autoload :
|
27
|
-
autoload :
|
28
|
-
autoload :
|
29
|
-
autoload :
|
30
|
-
autoload :AnnotationDiff, 'annotate_rb/model_annotator/annotation_diff'
|
5
|
+
autoload :Annotator, "annotate_rb/model_annotator/annotator"
|
6
|
+
autoload :PatternGetter, "annotate_rb/model_annotator/pattern_getter"
|
7
|
+
autoload :BadModelFileError, "annotate_rb/model_annotator/bad_model_file_error"
|
8
|
+
autoload :FileNameResolver, "annotate_rb/model_annotator/file_name_resolver"
|
9
|
+
autoload :SingleFileAnnotationRemover, "annotate_rb/model_annotator/single_file_annotation_remover"
|
10
|
+
autoload :AnnotationPatternGenerator, "annotate_rb/model_annotator/annotation_pattern_generator"
|
11
|
+
autoload :ModelClassGetter, "annotate_rb/model_annotator/model_class_getter"
|
12
|
+
autoload :ModelFilesGetter, "annotate_rb/model_annotator/model_files_getter"
|
13
|
+
autoload :SingleFileAnnotator, "annotate_rb/model_annotator/single_file_annotator"
|
14
|
+
autoload :ModelWrapper, "annotate_rb/model_annotator/model_wrapper"
|
15
|
+
autoload :AnnotationBuilder, "annotate_rb/model_annotator/annotation_builder"
|
16
|
+
autoload :ColumnAnnotation, "annotate_rb/model_annotator/column_annotation"
|
17
|
+
autoload :IndexAnnotation, "annotate_rb/model_annotator/index_annotation"
|
18
|
+
autoload :ForeignKeyAnnotation, "annotate_rb/model_annotator/foreign_key_annotation"
|
19
|
+
autoload :RelatedFilesListBuilder, "annotate_rb/model_annotator/related_files_list_builder"
|
20
|
+
autoload :AnnotationDecider, "annotate_rb/model_annotator/annotation_decider"
|
21
|
+
autoload :SingleFileAnnotatorInstruction, "annotate_rb/model_annotator/single_file_annotator_instruction"
|
22
|
+
autoload :SingleFileRemoveAnnotationInstruction, "annotate_rb/model_annotator/single_file_remove_annotation_instruction"
|
23
|
+
autoload :AnnotationDiffGenerator, "annotate_rb/model_annotator/annotation_diff_generator"
|
24
|
+
autoload :AnnotationDiff, "annotate_rb/model_annotator/annotation_diff"
|
25
|
+
autoload :FileBuilder, "annotate_rb/model_annotator/file_builder"
|
26
|
+
autoload :MagicCommentParser, "annotate_rb/model_annotator/magic_comment_parser"
|
27
|
+
autoload :FileComponents, "annotate_rb/model_annotator/file_components"
|
28
|
+
autoload :ProjectAnnotator, "annotate_rb/model_annotator/project_annotator"
|
29
|
+
autoload :ProjectAnnotationRemover, "annotate_rb/model_annotator/project_annotation_remover"
|
31
30
|
end
|
32
31
|
end
|
data/lib/annotate_rb/options.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require
|
3
|
+
require "forwardable"
|
4
4
|
|
5
5
|
module AnnotateRb
|
6
6
|
# Used to hold all of the options when annotating models and routes.
|
@@ -16,12 +16,13 @@ module AnnotateRb
|
|
16
16
|
|
17
17
|
POSITION_OPTIONS = {
|
18
18
|
position: nil, # ModelAnnotator, RouteAnnotator
|
19
|
+
position_in_additional_file_patterns: nil, # ModelAnnotator
|
19
20
|
position_in_class: nil, # ModelAnnotator
|
20
|
-
position_in_factory: nil, #
|
21
|
-
position_in_fixture: nil, #
|
21
|
+
position_in_factory: nil, # ModelAnnotator
|
22
|
+
position_in_fixture: nil, # ModelAnnotator
|
22
23
|
position_in_routes: nil, # RouteAnnotator
|
23
|
-
position_in_serializer: nil, #
|
24
|
-
position_in_test: nil
|
24
|
+
position_in_serializer: nil, # ModelAnnotator
|
25
|
+
position_in_test: nil # ModelAnnotator
|
25
26
|
}.freeze
|
26
27
|
|
27
28
|
FLAG_OPTIONS = {
|
@@ -50,7 +51,7 @@ module AnnotateRb
|
|
50
51
|
sort: false, # ModelAnnotator
|
51
52
|
timestamp: false, # RouteAnnotator
|
52
53
|
trace: false, # ModelAnnotator, but is part of Core
|
53
|
-
with_comment: true
|
54
|
+
with_comment: true # ModelAnnotator
|
54
55
|
}.freeze
|
55
56
|
|
56
57
|
OTHER_OPTIONS = {
|
@@ -59,10 +60,10 @@ module AnnotateRb
|
|
59
60
|
debug: false, # Core
|
60
61
|
|
61
62
|
# ModelAnnotator
|
62
|
-
hide_default_column_types:
|
63
|
+
hide_default_column_types: "",
|
63
64
|
|
64
65
|
# ModelAnnotator
|
65
|
-
hide_limit_column_types:
|
66
|
+
hide_limit_column_types: "",
|
66
67
|
|
67
68
|
ignore_columns: nil, # ModelAnnotator
|
68
69
|
ignore_routes: nil, # RouteAnnotator
|
@@ -73,26 +74,20 @@ module AnnotateRb
|
|
73
74
|
target_action: :do_annotations, # Core; Possible values: :do_annotations, :remove_annotations
|
74
75
|
wrapper: nil, # ModelAnnotator, RouteAnnotator
|
75
76
|
wrapper_close: nil, # ModelAnnotator, RouteAnnotator
|
76
|
-
wrapper_open: nil
|
77
|
+
wrapper_open: nil # ModelAnnotator, RouteAnnotator
|
77
78
|
}.freeze
|
78
79
|
|
79
80
|
PATH_OPTIONS = {
|
80
81
|
additional_file_patterns: [], # ModelAnnotator
|
81
|
-
model_dir: [
|
82
|
+
model_dir: ["app/models"], # ModelAnnotator
|
82
83
|
require: [], # Core
|
83
|
-
root_dir: [
|
84
|
+
root_dir: [""] # Core; Old model Annotate code depends on it being empty when not provided another value
|
84
85
|
# `root_dir` can also be a string but should get converted into an array with that string as the sole element when
|
85
86
|
# that happens.
|
86
87
|
}.freeze
|
87
88
|
|
88
89
|
DEFAULT_OPTIONS = {}.merge(POSITION_OPTIONS, FLAG_OPTIONS, OTHER_OPTIONS, PATH_OPTIONS).freeze
|
89
90
|
|
90
|
-
POSITION_OPTION_KEYS = [
|
91
|
-
:position,
|
92
|
-
:position_in_class,
|
93
|
-
:position_in_routes,
|
94
|
-
].freeze
|
95
|
-
|
96
91
|
FLAG_OPTION_KEYS = [
|
97
92
|
:classified_sort,
|
98
93
|
:exclude_controllers,
|
@@ -118,7 +113,7 @@ module AnnotateRb
|
|
118
113
|
:sort,
|
119
114
|
:timestamp,
|
120
115
|
:trace,
|
121
|
-
:with_comment
|
116
|
+
:with_comment
|
122
117
|
].freeze
|
123
118
|
|
124
119
|
OTHER_OPTION_KEYS = [
|
@@ -136,21 +131,21 @@ module AnnotateRb
|
|
136
131
|
:target_action,
|
137
132
|
:wrapper,
|
138
133
|
:wrapper_close,
|
139
|
-
:wrapper_open
|
134
|
+
:wrapper_open
|
140
135
|
].freeze
|
141
136
|
|
142
137
|
PATH_OPTION_KEYS = [
|
143
138
|
:additional_file_patterns,
|
144
139
|
:model_dir,
|
145
140
|
:require,
|
146
|
-
:root_dir
|
141
|
+
:root_dir
|
147
142
|
].freeze
|
148
143
|
|
149
144
|
ALL_OPTION_KEYS = [
|
150
|
-
|
145
|
+
POSITION_OPTIONS.keys, FLAG_OPTION_KEYS, OTHER_OPTION_KEYS, PATH_OPTION_KEYS
|
151
146
|
].flatten.freeze
|
152
147
|
|
153
|
-
POSITION_DEFAULT =
|
148
|
+
POSITION_DEFAULT = "before"
|
154
149
|
|
155
150
|
# Want this to be read only after initializing
|
156
151
|
def_delegator :@options, :[]
|
@@ -175,8 +170,8 @@ module AnnotateRb
|
|
175
170
|
# 1) Use the value if it's defined
|
176
171
|
# 2) Use value from :position if it's defined
|
177
172
|
# 3) Use default
|
178
|
-
|
179
|
-
@options[key] =
|
173
|
+
POSITION_OPTIONS.keys.each do |key|
|
174
|
+
@options[key] = Helper.fallback(
|
180
175
|
@options[key], @options[:position], POSITION_DEFAULT
|
181
176
|
)
|
182
177
|
end
|
@@ -184,7 +179,7 @@ module AnnotateRb
|
|
184
179
|
# Unpack path options if we're passed in a String
|
185
180
|
PATH_OPTION_KEYS.each do |key|
|
186
181
|
if @options[key].is_a?(String)
|
187
|
-
@options[key] = @options[key].split(
|
182
|
+
@options[key] = @options[key].split(",").map(&:strip).reject(&:empty?)
|
188
183
|
end
|
189
184
|
end
|
190
185
|
|