annotaterb 4.0.0.beta.1 → 4.0.0
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/README.md +91 -1
- data/VERSION +1 -1
- data/lib/annotate_rb/parser.rb +1 -1
- data/lib/generators/annotate_rb/install/USAGE +7 -0
- data/lib/generators/annotate_rb/install/install_generator.rb +14 -0
- metadata +7 -7
- data/lib/generators/annotate_rb/USAGE +0 -4
- data/lib/generators/annotate_rb/install_generator.rb +0 -15
- /data/lib/generators/annotate_rb/{templates/auto_annotate_models.rake → install/templates/annotate_rb.rake} +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: af9f792c5cb7386482abff5b7fb151dd000785316e0849139795ce473d48d076
|
4
|
+
data.tar.gz: 3d96f0869c4fa6616570bd1e9d077c962e56f59be4437496fc0cd0e428b5f3e3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8cf8cb1fe5183a9f814272173f8af849499789790a87c63fa15de25a561c249490c7fefc8605c69464298923c14d6349d29ece493ab35c22e37466a0707e27b1
|
7
|
+
data.tar.gz: 0e43bbc446a18dd28c08c68bda96e3acfe58b427e3d5d16f0836a713456629280dcc9eb67781013e1bf5a8c621cb3068b8e2058fb82267cc3a6e115805f64fad
|
data/README.md
CHANGED
@@ -1,8 +1,11 @@
|
|
1
1
|
## AnnotateRb
|
2
2
|
### forked from the [Annotate aka AnnotateModels gem](https://github.com/ctran/annotate_models)
|
3
3
|
|
4
|
+
A Ruby Gem that adds annotations to your Rails models and route files.
|
5
|
+
|
4
6
|
----------
|
5
7
|
[](https://github.com/drwl/annotaterb/actions/workflows/ci.yml)
|
8
|
+
[](https://badge.fury.io/rb/annotaterb)
|
6
9
|
|
7
10
|
Adds comments summarizing the model schema or routes in your:
|
8
11
|
|
@@ -57,8 +60,10 @@ $ bin/rails g annotate_rb:install
|
|
57
60
|
This will copy a rake task into your Rails project's `lib/tasks` directory that will hook into the Rails project rake tasks, automatically running AnnotateRb after database migration rake tasks.
|
58
61
|
|
59
62
|
## Migrating from the annotate gem
|
63
|
+
The old [annotate gem](https://github.com/ctran/annotate_models) relied on environment variables and hardcoded values in rake files for configuration. AnnotateRb is different. It reads from an optional configuration yml file and options from the CLI to function.
|
60
64
|
|
61
|
-
|
65
|
+
* Remove the following files `lib/tasks/annotate_models.rake`, `lib/tasks/annotate_models_migrate.rake`, `lib/tasks/annotate_routes.rake`.
|
66
|
+
* Run the generator install command above.
|
62
67
|
|
63
68
|
## Usage
|
64
69
|
|
@@ -67,10 +72,95 @@ AnnotateRb has a CLI that you can use to add or remove annotations.
|
|
67
72
|
```sh
|
68
73
|
# To show the CLI options
|
69
74
|
$ bundle exec annotaterb
|
75
|
+
|
76
|
+
Usage: annotaterb [command] [options]
|
77
|
+
|
78
|
+
Commands:
|
79
|
+
models [options]
|
80
|
+
routes [options]
|
81
|
+
help
|
82
|
+
version
|
83
|
+
|
84
|
+
Options:
|
85
|
+
-v, --version Display the version..
|
86
|
+
-h, --help You're looking at it.
|
87
|
+
|
88
|
+
Annotate model options:
|
89
|
+
Usage: annotaterb models [options]
|
90
|
+
|
91
|
+
-a, --active-admin Annotate active_admin models
|
92
|
+
--show-migration Include the migration version number in the annotation
|
93
|
+
-k, --show-foreign-keys List the table's foreign key constraints in the annotation
|
94
|
+
--ck, --complete-foreign-keys
|
95
|
+
Complete foreign key names in the annotation
|
96
|
+
-i, --show-indexes List the table's database indexes in the annotation
|
97
|
+
-s, --simple-indexes Concat the column's related indexes in the annotation
|
98
|
+
--hide-limit-column-types VALUES
|
99
|
+
don't show limit for given column types, separated by commas (i.e., `integer,boolean,text`)
|
100
|
+
--hide-default-column-types VALUES
|
101
|
+
don't show default for given column types, separated by commas (i.e., `json,jsonb,hstore`)
|
102
|
+
--ignore-unknown-models don't display warnings for bad model files
|
103
|
+
-I, --ignore-columns REGEX don't annotate columns that match a given REGEX (i.e., `annotate -I '^(id|updated_at|created_at)'`
|
104
|
+
--with-comment include database comments in model annotations
|
105
|
+
|
106
|
+
Annotate routes options:
|
107
|
+
Usage: annotaterb routes [options]
|
108
|
+
|
109
|
+
--ignore-routes REGEX don't annotate routes that match a given REGEX (i.e., `annotate -I '(mobile|resque|pghero)'`
|
110
|
+
--timestamp Include timestamp in (routes) annotation
|
111
|
+
--w, --wrapper STR Wrap annotation with the text passed as parameter.
|
112
|
+
If --w option is used, the same text will be used as opening and closing
|
113
|
+
--wo, --wrapper-open STR Annotation wrapper opening.
|
114
|
+
--wc, --wrapper-close STR Annotation wrapper closing
|
115
|
+
|
116
|
+
Command options:
|
117
|
+
Additional options that work for annotating models and routes
|
118
|
+
|
119
|
+
--additional-file-patterns path1,path2,path3
|
120
|
+
Additional file paths or globs to annotate, separated by commas (e.g. `/foo/bar/%model_name%/*.rb,/baz/%model_name%.rb`)
|
121
|
+
-d, --delete Remove annotations from all model files or the routes.rb file
|
122
|
+
--model-dir dir Annotate model files stored in dir rather than app/models, separate multiple dirs with commas
|
123
|
+
--root-dir dir Annotate files stored within root dir projects, separate multiple dirs with commas
|
124
|
+
--ignore-model-subdirects Ignore subdirectories of the models directory
|
125
|
+
--sort Sort columns alphabetically, rather than in creation order
|
126
|
+
--classified-sort Sort columns alphabetically, but first goes id, then the rest columns, then the timestamp columns and then the association columns
|
127
|
+
-R, --require path Additional file to require before loading models, may be used multiple times
|
128
|
+
-e [tests,fixtures,factories,serializers],
|
129
|
+
--exclude Do not annotate fixtures, test files, factories, and/or serializers
|
130
|
+
-f [bare|rdoc|yard|markdown], Render Schema Information as plain/RDoc/Yard/Markdown
|
131
|
+
--format
|
132
|
+
-p [before|top|after|bottom], Place the annotations at the top (before) or the bottom (after) of the model/test/fixture/factory/route/serializer file(s)
|
133
|
+
--position
|
134
|
+
--pc, --position-in-class [before|top|after|bottom]
|
135
|
+
Place the annotations at the top (before) or the bottom (after) of the model file
|
136
|
+
--pf, --position-in-factory [before|top|after|bottom]
|
137
|
+
Place the annotations at the top (before) or the bottom (after) of any factory files
|
138
|
+
--px, --position-in-fixture [before|top|after|bottom]
|
139
|
+
Place the annotations at the top (before) or the bottom (after) of any fixture files
|
140
|
+
--pt, --position-in-test [before|top|after|bottom]
|
141
|
+
Place the annotations at the top (before) or the bottom (after) of any test files
|
142
|
+
--pr, --position-in-routes [before|top|after|bottom]
|
143
|
+
Place the annotations at the top (before) or the bottom (after) of the routes.rb file
|
144
|
+
--ps, --position-in-serializer [before|top|after|bottom]
|
145
|
+
Place the annotations at the top (before) or the bottom (after) of the serializer files
|
146
|
+
--force Force new annotations even if there are no changes.
|
147
|
+
--debug Prints the options and outputs messages to make it easier to debug.
|
148
|
+
--frozen Do not allow to change annotations. Exits non-zero if there are going to be changes to files.
|
149
|
+
--trace If unable to annotate a file, print the full stack trace, not just the exception message.
|
70
150
|
```
|
71
151
|
|
72
152
|
## Configuration
|
73
153
|
|
154
|
+
### Storing default options
|
155
|
+
Previously in the [Annotate](https://github.com/ctran/annotate_models) you could pass options through the CLI or store them as environment variables. Annotaterb removes dependency on the environment variables and instead can read values from a `.annotaterb.yml` file stored in the Rails project root.
|
156
|
+
|
157
|
+
```yml
|
158
|
+
# .annotaterb.yml
|
159
|
+
|
160
|
+
position: after
|
161
|
+
```
|
162
|
+
|
163
|
+
Annotaterb reads first from the configuration file, if it exists, then merges it with any options passed into the CLI.
|
74
164
|
|
75
165
|
### How to skip annotating a particular model
|
76
166
|
If you want to always skip annotations on a particular model, add this string
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
4.0.0
|
1
|
+
4.0.0
|
data/lib/annotate_rb/parser.rb
CHANGED
@@ -78,7 +78,7 @@ module AnnotateRb
|
|
78
78
|
# TODO: Should raise or alert user that multiple commands were selected but only 1 command will be ran
|
79
79
|
@options[:command] = map[@commands.first]
|
80
80
|
else # None
|
81
|
-
@options[:command] =
|
81
|
+
@options[:command] = map[:help]
|
82
82
|
end
|
83
83
|
end
|
84
84
|
|
@@ -0,0 +1,14 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
require 'annotate_rb'
|
3
|
+
|
4
|
+
module AnnotateRb
|
5
|
+
module Generators
|
6
|
+
class InstallGenerator < ::Rails::Generators::Base
|
7
|
+
source_root File.expand_path('templates', __dir__)
|
8
|
+
|
9
|
+
def copy_task
|
10
|
+
copy_file "annotate_rb.rake", "lib/tasks/annotate_rb.rake"
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: annotaterb
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.0.0
|
4
|
+
version: 4.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrew W. Lee
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-05-03 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Annotates Rails/ActiveRecord Models, routes, fixtures, and others based
|
14
14
|
on the database schema.
|
@@ -63,9 +63,9 @@ files:
|
|
63
63
|
- lib/annotate_rb/route_annotator/removal_processor.rb
|
64
64
|
- lib/annotate_rb/runner.rb
|
65
65
|
- lib/annotate_rb/tasks/annotate_models_migrate.rake
|
66
|
-
- lib/generators/annotate_rb/USAGE
|
67
|
-
- lib/generators/annotate_rb/install_generator.rb
|
68
|
-
- lib/generators/annotate_rb/templates/
|
66
|
+
- lib/generators/annotate_rb/install/USAGE
|
67
|
+
- lib/generators/annotate_rb/install/install_generator.rb
|
68
|
+
- lib/generators/annotate_rb/install/templates/annotate_rb.rake
|
69
69
|
homepage: https://github.com/drwl/annotaterb
|
70
70
|
licenses:
|
71
71
|
- BSD-2-Clause
|
@@ -85,9 +85,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
85
85
|
version: 2.7.0
|
86
86
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
87
87
|
requirements:
|
88
|
-
- - "
|
88
|
+
- - ">="
|
89
89
|
- !ruby/object:Gem::Version
|
90
|
-
version:
|
90
|
+
version: '0'
|
91
91
|
requirements: []
|
92
92
|
rubygems_version: 3.2.33
|
93
93
|
signing_key:
|
@@ -1,15 +0,0 @@
|
|
1
|
-
require 'annotate_rb'
|
2
|
-
|
3
|
-
module AnnotateRb
|
4
|
-
module Generators
|
5
|
-
class InstallGenerator < Rails::Generators::Base
|
6
|
-
desc 'Copy annotaterb rakefiles for automatic annotation of models'
|
7
|
-
source_root File.expand_path('templates', __dir__)
|
8
|
-
|
9
|
-
def copy_tasks
|
10
|
-
# Copies the rake task into Rails project's lib/tasks directory
|
11
|
-
template 'auto_annotate_models.rake', 'lib/tasks/auto_annotate_models.rake'
|
12
|
-
end
|
13
|
-
end
|
14
|
-
end
|
15
|
-
end
|
File without changes
|