annotate 2.7.4 → 3.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/{AUTHORS.rdoc → AUTHORS.md} +2 -2
- data/CHANGELOG.md +326 -0
- data/{README.rdoc → README.md} +153 -98
- data/RELEASE.md +19 -0
- data/annotate.gemspec +7 -26
- data/bin/annotate +7 -187
- data/lib/annotate.rb +23 -82
- data/lib/annotate/annotate_models.rb +184 -83
- data/lib/annotate/annotate_routes.rb +111 -167
- data/lib/annotate/annotate_routes/helpers.rb +69 -0
- data/lib/annotate/constants.rb +38 -0
- data/lib/annotate/helpers.rb +30 -0
- data/lib/annotate/parser.rb +303 -0
- data/lib/annotate/version.rb +1 -1
- data/lib/generators/annotate/templates/auto_annotate_models.rake +45 -40
- data/lib/tasks/annotate_models.rake +37 -33
- data/lib/tasks/annotate_models_migrate.rake +14 -16
- data/lib/tasks/annotate_routes.rake +5 -5
- data/potato.md +41 -0
- metadata +21 -16
- data/CHANGELOG.rdoc +0 -220
- data/TODO.rdoc +0 -11
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 14932a4a189792b68c9d85c63313d0d60322ca22fed18a7a4a00edd47348743a
|
4
|
+
data.tar.gz: 351b61b7b3eac94f1ce6d8a86e1630bbbf6c0920cacfe46319163a86bc189887
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a717f48aff793ea4566fca6919eb4fe85b1545fe93b0bece91c5a9507cbb87fe14aa35ac520e618e98f8db92fe11010a8fe8653802b25b83b24590467e5d64f1
|
7
|
+
data.tar.gz: d13aab072e5e3901788f4aff809e08f3d28ac24cf0eed4187b0e5c0f98008f3c95a7553b58c4f50705f2f42729e96a05a57631356715953bb7d29531e4365fbd
|
data/{AUTHORS.rdoc → AUTHORS.md}
RENAMED
@@ -1,4 +1,4 @@
|
|
1
|
-
|
1
|
+
## Authors
|
2
2
|
|
3
3
|
- Original code by: Dave Thomas -- Pragmatic Programmers, LLC <http://agilewebdevelopment.com/plugins/annotate_models>
|
4
4
|
- Overhauled by: Alex Chaffee <http://alexch.github.com> alex@stinky.com
|
@@ -6,7 +6,7 @@
|
|
6
6
|
- Maintained by: Alex Chaffee and Cuong Tran
|
7
7
|
- Homepage: http://github.com/ctran/annotate_models
|
8
8
|
|
9
|
-
With help from:
|
9
|
+
### With help from:
|
10
10
|
|
11
11
|
- Jack Danger - http://github.com/JackDanger
|
12
12
|
- Michael Bumann - http://github.com/bumi
|
data/CHANGELOG.md
ADDED
@@ -0,0 +1,326 @@
|
|
1
|
+
## 3.1.1
|
2
|
+
Changes
|
3
|
+
- Bump required ruby version to >= 2.4 [#772](https://github.com/ctran/annotate_models/pull/772)
|
4
|
+
- [Revert #677] Fix column default annotations [#768](https://github.com/ctran/annotate_models/pull/768)
|
5
|
+
|
6
|
+
Project Improvements
|
7
|
+
- Refactor by adding AnnotateRoutes::Helpers [#770](https://github.com/ctran/annotate_models/pull/770)
|
8
|
+
- Bump puma from 4.3.1 to 4.3.3 in /spec/integration/rails_6.0.2.1 [#771](https://github.com/ctran/annotate_models/pull/771)
|
9
|
+
- Bump puma from 3.12.2 to 4.3.3 in /spec/integration/rails_5.2.4.1 [#769](https://github.com/ctran/annotate_models/pull/769)
|
10
|
+
- Bump nokogiri from 1.10.7 to 1.10.8 in /spec/integration/rails_5.2.4.1 [#766](https://github.com/ctran/annotate_models/pull/766)
|
11
|
+
- Bump nokogiri from 1.10.7 to 1.10.8 in /spec/integration/rails_6.0.2.1 [#765](https://github.com/ctran/annotate_models/pull/765)
|
12
|
+
- Refactor test cases of AnnotateRoutes [#760](https://github.com/ctran/annotate_models/pull/760)
|
13
|
+
- Rename FactoryGirl -> FactoryBot comment [#759](https://github.com/ctran/annotate_models/pull/759)
|
14
|
+
|
15
|
+
## 3.1.0
|
16
|
+
Changes
|
17
|
+
- Fix new lines after comments for rubocop compatibility [#757](https://github.com/ctran/annotate_models/pull/757)
|
18
|
+
- Fix messages from AnnotateRoutes [#737](https://github.com/ctran/annotate_models/pull/737)
|
19
|
+
- Support YARD notation [#724](https://github.com/ctran/annotate_models/pull/724)
|
20
|
+
- Refactor AnnotateRoutes.routes_file_exist? [#716](https://github.com/ctran/annotate_models/pull/716)
|
21
|
+
- Refactor namespace Annotate [#719](https://github.com/ctran/annotate_models/pull/719)
|
22
|
+
- Add columns managed by Globalize gem [#602](https://github.com/ctran/annotate_models/pull/602)
|
23
|
+
|
24
|
+
Bug Fixes
|
25
|
+
- Fix additional_file_patterns parsing [#756](https://github.com/ctran/annotate_models/pull/756)
|
26
|
+
- Fix typo in README [#752](https://github.com/ctran/annotate_models/pull/752)
|
27
|
+
- Fix bin/annotate NoMethodError [#745](https://github.com/ctran/annotate_models/pull/745)
|
28
|
+
- Fix README for YARD format [#740](https://github.com/ctran/annotate_models/pull/740)
|
29
|
+
- Fix constant names that were not renamed in #721 [#739](https://github.com/ctran/annotate_models/pull/739)
|
30
|
+
- Replace soft-deprecated constant `HashWithIndifferentAccess` to `ActiveSupport::HashWithIndifferentAccess` [#699](https://github.com/ctran/annotate_models/pull/699)
|
31
|
+
- [Fix #570](https://github.com/ctran/annotate_models/issues/570) Change of foreign key should be considered as a column change
|
32
|
+
- [Fix #430](https://github.com/ctran/annotate_models/issues/430) Handle columns from activerecord-postgis-adapter [#694](https://github.com/ctran/annotate_models/pull/694)
|
33
|
+
- Add ActiveAdmin option to template [#693](https://github.com/ctran/annotate_models/pull/693)
|
34
|
+
- Fix foreign key issue with Rails 6 and Sqlite3 [#695](https://github.com/ctran/annotate_models/pull/695)
|
35
|
+
- Fix Serializers Test Directory [#625](https://github.com/ctran/annotate_models/pull/625)
|
36
|
+
- [Fix #624](https://github.com/ctran/annotate_models/issues/624) Correct default values for columns when ActiveRecord::Enum is used [#677](https://github.com/ctran/annotate_models/pull/677)
|
37
|
+
- [Fix #675](https://github.com/ctran/annotate_models/issues/675) Correct indentation for double-byte characters [#676](https://github.com/ctran/annotate_models/pull/676)
|
38
|
+
- FIX: Ensure only one line is around the annotation [#669](https://github.com/ctran/annotate_models/pull/669)
|
39
|
+
- Fix shifted when format_markdown option enabled and used non-ascii [#650](https://github.com/ctran/annotate_models/pull/650)
|
40
|
+
|
41
|
+
Project improvements
|
42
|
+
- Refactor RSpec for AnnotateModels - structuralize test cases [#755](https://github.com/ctran/annotate_models/pull/755)
|
43
|
+
- Refactor test cases of AnnotateRoutes as for Rake versions [#754](https://github.com/ctran/annotate_models/pull/754)
|
44
|
+
- Add integration tests to project [#747](https://github.com/ctran/annotate_models/pull/747)
|
45
|
+
- Refactor test cases for AnnotateRoutes.remove_annotations [#748](https://github.com/ctran/annotate_models/pull/748)
|
46
|
+
- Refactor RSpec for AnnotateModels - with Globalize gem [#749](https://github.com/ctran/annotate_models/pull/749)
|
47
|
+
- Fixed CHANGELOG.md to add link to each PR [#751](https://github.com/ctran/annotate_models/pull/751)
|
48
|
+
- Delete integration test fixtures [#746](https://github.com/ctran/annotate_models/pull/746)
|
49
|
+
- Remove remaining integration test files [#744](https://github.com/ctran/annotate_models/pull/744)
|
50
|
+
- Remove unworking integration tests [#725](https://github.com/ctran/annotate_models/pull/725)
|
51
|
+
- Refactor Annotate::Parser [#742](https://github.com/ctran/annotate_models/pull/742)
|
52
|
+
- Refactor RSpec for AnnotateModels (4) - AnnotateModels.get_schema_info (without custom options) [#735](https://github.com/ctran/annotate_models/pull/735)
|
53
|
+
- Refactor RSpec for AnnotateRoutes (1) [#736](https://github.com/ctran/annotate_models/pull/736)
|
54
|
+
- Refactor AnnotateRoutes.rewrite_contents [#734](https://github.com/ctran/annotate_models/pull/734)
|
55
|
+
- AnnotateModels.get_schema_info (with custom options) [#732](https://github.com/ctran/annotate_models/pull/732)
|
56
|
+
- Fix typo in RSpec of AnnotateModels [#731](https://github.com/ctran/annotate_models/pull/731)
|
57
|
+
- Remove AnnotateRoutes.rewrite_contents_with_header [#730](https://github.com/ctran/annotate_models/pull/730)
|
58
|
+
- Refactor AnnotateRoutes.annotate_routes and .rewrite_contents_with_header [#729](https://github.com/ctran/annotate_models/pull/729)
|
59
|
+
- Refactor AnnotateModels::Parser [#728](https://github.com/ctran/annotate_models/pull/728)
|
60
|
+
- Remove invalid document of AnnotateRoutes.rewrite_contents [#727](https://github.com/ctran/annotate_models/pull/727)
|
61
|
+
- Refactor RSpec for AnnotateModels (1) [#726](https://github.com/ctran/annotate_models/pull/726)
|
62
|
+
- Refactor AnnotateModels::Helpers [#723](https://github.com/ctran/annotate_models/pull/723)
|
63
|
+
- Refactor AnnotateRoutes.remove_annotations [#715](https://github.com/ctran/annotate_models/pull/715)
|
64
|
+
- Fix AnnotateRoutes.extract_magic_comments_from_array [#712](https://github.com/ctran/annotate_models/pull/712)
|
65
|
+
- Rename FactoryGirl to FactoryBot [#721](https://github.com/ctran/annotate_models/pull/721)
|
66
|
+
- Refactor AnnotateRoutes.header [#714](https://github.com/ctran/annotate_models/pull/714)
|
67
|
+
- Freeze constant AnnotateRoutes::HEADER_ROW [#713](https://github.com/ctran/annotate_models/pull/713)
|
68
|
+
- Add constants MAGIC_COMMENT_MATCHER [#711](https://github.com/ctran/annotate_models/pull/711)
|
69
|
+
- Rename method and variable of AnnotateRoutes for readability [#709](https://github.com/ctran/annotate_models/pull/709)
|
70
|
+
- Refactor lib/annotate.rb [#707](https://github.com/ctran/annotate_models/pull/707)
|
71
|
+
- Delete TODO.md [#700](https://github.com/ctran/annotate_models/pull/700)
|
72
|
+
- Tidy README [#701](https://github.com/ctran/annotate_models/pull/701)
|
73
|
+
- Convert documentation files to Markdown [#697](https://github.com/ctran/annotate_models/pull/697)
|
74
|
+
- Upgrade and fix CI [#698](https://github.com/ctran/annotate_models/pull/698)
|
75
|
+
- Add upgrade instructions to README [#687](https://github.com/ctran/annotate_models/pull/687)
|
76
|
+
- Fix Github release action [#682](https://github.com/ctran/annotate_models/pull/682)
|
77
|
+
|
78
|
+
## 3.0.3
|
79
|
+
- Use a less error-prone way of specifying gem files [#662](https://github.com/ctran/annotate_models/pull/662)
|
80
|
+
- Update rake requirement from `>= 10.4, < 13.0` to `>= 10.4, < 14.0` [#659](https://github.com/ctran/annotate_models/pull/659)
|
81
|
+
- Bump nokogiri from 1.6.6.2 to 1.10.4 in /spec/integration/rails_4.2.0 [#655](https://github.com/ctran/annotate_models/pull/655)
|
82
|
+
- Default annotate models to true in config generated by `rails g annotate:install` [#671](https://github.com/ctran/annotate_models/pull/671)
|
83
|
+
- Bump loofah from 2.3.0 to 2.3.1 in /spec/integration/rails_4.2.0 [#681](https://github.com/ctran/annotate_models/pull/681)
|
84
|
+
|
85
|
+
## 3.0.2
|
86
|
+
- Fixes `LoadError` due to gemspec not referencing `parser.rb`, issue [#657](https://github.com/ctran/annotate_models/issues/657) [#660](https://github.com/ctran/annotate_models/pull/660)
|
87
|
+
- Changes `--additional_file_patterns` to use dashes `--additional-file-patterns` for consistency [#649](https://github.com/ctran/annotate_models/pull/649)
|
88
|
+
- Refactor: moving constants into `constants.rb` [#653](https://github.com/ctran/annotate_models/pull/653)
|
89
|
+
|
90
|
+
## 3.0.1
|
91
|
+
- Skipped as an official release, used the 3.0.1 patch for setting up Github Actions [#619](https://github.com/ctran/annotate_models/pull/619)
|
92
|
+
|
93
|
+
## 3.0.0
|
94
|
+
- **Breaking:** when option `models` is not set - models will not be annotated by default.
|
95
|
+
|
96
|
+
Add `'models'=>'true'` to your config manually or use `--models` option if using CLI.
|
97
|
+
|
98
|
+
- Added `--models` CLI option fixing issue [#563](https://github.com/ctran/annotate_models/issues/563) [#647](https://github.com/ctran/annotate_models/pull/647)
|
99
|
+
- Added `--additional_file_patterns` option for additional file patterns [#633](https://github.com/ctran/annotate_models/pull/633) [#636](https://github.com/ctran/annotate_models/pull/636) [#637](https://github.com/ctran/annotate_models/pull/637)
|
100
|
+
- Refactored CLI parser [#646](https://github.com/ctran/annotate_models/pull/646)
|
101
|
+
- Fixed `BigDecimal.new` deprecation warning [#634](https://github.com/ctran/annotate_models/pull/634)
|
102
|
+
- Fixed annotations for columns with long data types [#622](https://github.com/ctran/annotate_models/pull/622)
|
103
|
+
- Made methods private in AnnotateRoutes [#598](https://github.com/ctran/annotate_models/pull/598)
|
104
|
+
|
105
|
+
See https://github.com/ctran/annotate_models/releases/tag/v3.0.0
|
106
|
+
|
107
|
+
## 2.7.5
|
108
|
+
See https://github.com/ctran/annotate_models/releases/tag/v2.7.5
|
109
|
+
|
110
|
+
## 2.7.3
|
111
|
+
See https://github.com/ctran/annotate_models/releases/tag/v2.7.3
|
112
|
+
|
113
|
+
## 2.7.2
|
114
|
+
See https://github.com/ctran/annotate_models/releases/tag/v2.7.2
|
115
|
+
|
116
|
+
## 2.7.1
|
117
|
+
See https://github.com/ctran/annotate_models/releases/tag/v2.7.1
|
118
|
+
|
119
|
+
## 2.7.0
|
120
|
+
See https://github.com/ctran/annotate_models/releases/tag/v2.7.0
|
121
|
+
|
122
|
+
## 2.6.9
|
123
|
+
- Support foreigh key [#241](https://github.com/ctran/annotate_models/pull/241)
|
124
|
+
- Check if model has skip tag in annotate_model_file [#167](https://github.com/ctran/annotate_models/pull/167)
|
125
|
+
- Fix issue where serializer-related flags weren't being honored [#246](https://github.com/ctran/annotate_models/issues/246)
|
126
|
+
- Prefer SQL column type over normalized AR type [#231](https://github.com/ctran/annotate_models/issues/231)
|
127
|
+
|
128
|
+
## 2.6.8
|
129
|
+
- Nothing annotated unless `options[:model_dir]` is specified, [#234](https://github.com/ctran/annotate_models/pull/234)
|
130
|
+
|
131
|
+
## 2.6.7
|
132
|
+
- Nothing annotated unless `options[:model_dir]` is specified, [#234](https://github.com/ctran/annotate_models/pull/234)
|
133
|
+
|
134
|
+
## 2.6.6
|
135
|
+
- Makes it possible to wrap annotations, [#225](https://github.com/ctran/annotate_models/pull/225)
|
136
|
+
- Fix single model generation, [#214](https://github.com/ctran/annotate_models/pull/214)
|
137
|
+
- Fix default value for Rails 4.2, [#212](https://github.com/ctran/annotate_models/issues/212)
|
138
|
+
- Don't crash on inherited models in subdirectories, [#232](https://github.com/ctran/annotate_models/issues/232)
|
139
|
+
- Process model_dir in rake task, [#197](https://github.com/ctran/annotate_models/pull/197)
|
140
|
+
|
141
|
+
## 2.6.4
|
142
|
+
- Skip "models/concerns", [#194](https://github.com/ctran/annotate_models/pull/194)
|
143
|
+
- Fix [#173](https://github.com/ctran/annotate_models/issues/173) where annotate says "Nothing to annotate" in rails 4.2
|
144
|
+
- Display an error message if not run from the root of the project, [#186](https://github.com/ctran/annotate_models/pull/186)
|
145
|
+
- Support rails 4.0 new default test directory, [#182](https://github.com/ctran/annotate_models/issues/182)
|
146
|
+
- Add an option to show timestamp in routes "-timestamp", [#136](https://github.com/ctran/annotate_models/issues/136)
|
147
|
+
- Skip plain ruby objects if they have the same class name as an ActiveRecord object, [#121](https://github.com/ctran/annotate_models/issues/121)
|
148
|
+
|
149
|
+
## 2.6.3
|
150
|
+
- Fix bug of annotate position in routes [#158](https://github.com/ctran/annotate_models/issues/158)
|
151
|
+
|
152
|
+
## 2.6.2
|
153
|
+
- Retain the current annotate block unless --force is specified
|
154
|
+
- Always load models, since they may not be autoloaded by Rails
|
155
|
+
- The pg array type is now detected (see [#158](https://github.com/ctran/annotate_models/pull/158))
|
156
|
+
|
157
|
+
## 2.6.0.beta2
|
158
|
+
- support for composite_primary_keys (garysweaver)
|
159
|
+
- bug fix for annotate_one_file (vlado)
|
160
|
+
|
161
|
+
|
162
|
+
## 2.6.0.beta1
|
163
|
+
|
164
|
+
- It's now possible to use Annotate in standalone ActiveRecord (non-Rails) projects again.
|
165
|
+
- Adding note that Markdown is actually MultiMarkdown, and recommending the use
|
166
|
+
of the `kramdown` engine for parsing it.
|
167
|
+
- Improved Markdown formatting considerably.
|
168
|
+
- Bugfix: Needed to use inline-code tag for column and table names,
|
169
|
+
otherwise underscores would cause havok with the formatting.
|
170
|
+
- Bugfix: Markdown syntax was incorrect
|
171
|
+
(can't have trailing spaces before the closing marker for an emphasis tag).
|
172
|
+
- Bugfix: Remove-annotations wasn't properly finding test/spec files,
|
173
|
+
and wasn't even looking for FactoryGirl factories under the new naming convention.
|
174
|
+
- Bugfix: Load the Rakefile from the current directory, not the first
|
175
|
+
Rakefile in our load path.
|
176
|
+
- Added support for new FactoryGirl naming convention.
|
177
|
+
- Fix behavior of route annotations in newer versions of Rake that don't
|
178
|
+
spit out the CWD as their first line of output.
|
179
|
+
- Overhauled integration testing system to be much easier to work with,
|
180
|
+
better compartmentalized, and so forth -- at the cost that you must be
|
181
|
+
using RVM to utilize it. (It'll spit out appropriate pending messages if
|
182
|
+
you don't.) Also includes a mode for "tinkering" by hand with a scenario,
|
183
|
+
and won't let you run it through rspect if the repo is in a dirty state.
|
184
|
+
Added appropriate rake tasks to help with all of this.
|
185
|
+
- Routes can now be appended, pre-pended, or removed -- and do sane things in all cases.
|
186
|
+
- Expose all `position_*` variables as CLI params.
|
187
|
+
- Make `ENV ['position']` work as a default for all the `ENV ['position_*']` variables.
|
188
|
+
- Make rake tasks more resilient to unusual circumstances / code loading behavior.
|
189
|
+
- Resolve annotate vs. annotate_models ambiguity once and for all by
|
190
|
+
settling on `annotate_models` *and* `annotate_routes`. This avoids a name
|
191
|
+
collision with RMagick while not needlessly overloading the term.
|
192
|
+
- Fixed that schema kept prepending additional newlines
|
193
|
+
- Updates to make annotate smarter about when to touch a model
|
194
|
+
- Recognize column+type, and don't change a file unless the column+type
|
195
|
+
combination of the new schema are different than that of the old (i.e.,
|
196
|
+
don't regenerate if columns happen to be in a different order. That's just
|
197
|
+
how life is sometimes)
|
198
|
+
- Change annotate to use options hash instead of ENV.
|
199
|
+
|
200
|
+
|
201
|
+
## 2.5.0
|
202
|
+
|
203
|
+
- Works better with Rails 3
|
204
|
+
- Bugfix: schema kept prepending additional newlines
|
205
|
+
- Updates to make annotate smarter about when to touch a model
|
206
|
+
- Recognize column+type, and don't change a file unless the column+type
|
207
|
+
combination of the new schema are different than that of the old (i.e.,
|
208
|
+
don't regenerate if columns happen to be in a different order. That's just
|
209
|
+
how life is sometimes.)
|
210
|
+
- Grab old specification even if it has `\r\n` as line endings rather than pure `\n`s
|
211
|
+
- Various warning and specification fixes
|
212
|
+
- Fix "no such file to load -- annotate/annotate_models (MissingSourceFile)"
|
213
|
+
error (require statements in tasks now use full path to lib files)
|
214
|
+
- warn about macros, to mitigate when we're included during a production
|
215
|
+
run, not just a rakefile run -- possibly at the expense of too much noise
|
216
|
+
- Adding rake as a runtime dependency
|
217
|
+
- If the schema is already in the model file, it will be replaced into the same location.
|
218
|
+
If it didn't previously exist, it'll be placed according to the "position", as before.
|
219
|
+
- Allow task loading from Rakefile for gems (plugin installation already auto-detects).
|
220
|
+
- Add skip_on_db_migrate option as well for people that don't want it
|
221
|
+
- Fix options parsing to convert strings to proper booleans
|
222
|
+
- Add support for Fabrication fabricators
|
223
|
+
- Leave magic encoding comment intact
|
224
|
+
- Fix issue #14 - RuntimeError: Already memoized
|
225
|
+
- Count a model as 'annotated' if any of its tests/fixtures are annotated
|
226
|
+
- Support FactoryGirl
|
227
|
+
- Support :change migrations (Rails 3.1)
|
228
|
+
- Allow models with non-standard capitalization
|
229
|
+
- Widen type column so we can handle longtexts with chopping things off.
|
230
|
+
- Skip trying to get list of models from commandline when running via Rake
|
231
|
+
(was preventing the use of multiple rake tasks in one command if one of them was `db:migrate`).
|
232
|
+
- Add ability to skip annotations for a model by adding
|
233
|
+
`# -*- SkipSchemaAnnotations` anywhere in the file.
|
234
|
+
- Don't show column limits for integer and boolean types.
|
235
|
+
- Add sorting for columns and indexes.
|
236
|
+
(Helpful for out-of-order migration execution. Use `--sort` if you want this.)
|
237
|
+
- Annotate unit tests in subfolders.
|
238
|
+
- Add generator to install rakefile that automatically annotates on `db:migrate`.
|
239
|
+
- Correct Gemfile to clarify which environments need which gems.
|
240
|
+
- Add an .rvmrc to facilitate clean development.
|
241
|
+
- Refactor out ActiveRecord monkey-patch to permit extending without side-effects.
|
242
|
+
- Use ObjectSpace to locate models to facilitate handling of models with
|
243
|
+
non-standard capitalization.
|
244
|
+
Note that this still requires that the inflector be configured to understand
|
245
|
+
the special case.
|
246
|
+
- Shore up test cases a bit.
|
247
|
+
- Merge against many of the older branches on Github whose functionality is
|
248
|
+
already reflected to reduce confusion about what is and is not implemented here.
|
249
|
+
- Accept String or Symbol for :position (et al) options.
|
250
|
+
- Add RDoc output formatting as an option.
|
251
|
+
- Add Markdown output formatting as an option.
|
252
|
+
- Add option to force annotation regeneration.
|
253
|
+
- Add new configuration option for controlling where info is placed in
|
254
|
+
fixtures/factories.
|
255
|
+
- Fix for models without tables.
|
256
|
+
- Fix gemspec generation now that Jeweler looks at Gemfile.
|
257
|
+
- Fix warning: `NOTE: Gem::Specification#default_executable= is deprecated
|
258
|
+
with no replacement. It will be removed on or after 2011-10-01.`
|
259
|
+
- Fix handling of files with no trailing newline when putting annotations at
|
260
|
+
the end of the file.
|
261
|
+
- Now works on tables with no primary key.
|
262
|
+
- `--format=markdown` option
|
263
|
+
- `--trace` option to help debug "Unable to annotate" errors
|
264
|
+
- "Table name" annotation (if table name is different from model name)
|
265
|
+
- "Human name" annotation (enabling translation to non-English locales)
|
266
|
+
- Fix JRuby ObjectSpace compatibility bug (https://github.com/ctran/annotate_models/pull/85)
|
267
|
+
- Fix FactoryGirl compatibility bug (https://github.com/ctran/annotate_models/pull/82)
|
268
|
+
|
269
|
+
|
270
|
+
## 2.4.2 2009-11-21
|
271
|
+
- Annotates `(spec|test)/factories/<model>_factory.rb` files
|
272
|
+
|
273
|
+
## 2.4.1 2009-11-20
|
274
|
+
|
275
|
+
- Annotates thoughtbot's factory_girl factories (`test/factories/<model>_factory.rb`)
|
276
|
+
- Move default annotation position back to top
|
277
|
+
|
278
|
+
|
279
|
+
## 2.4.0 2009-12-13
|
280
|
+
- Incorporated lots of patches from the Github community,
|
281
|
+
including support for Blueprints fixtures
|
282
|
+
- Several bug fixes
|
283
|
+
|
284
|
+
## 2.1 2009-10-18
|
285
|
+
|
286
|
+
- New options
|
287
|
+
- `-R` to require additional files before loading the models
|
288
|
+
- `-i` to show database indexes in annotations
|
289
|
+
- `-e` to exclude annotating tests or fixtures
|
290
|
+
- `-m` to include the migration version number in the annotation
|
291
|
+
- `--model-dir` to annotate model files stored a different place than `app/models`
|
292
|
+
|
293
|
+
- Ignore unknown macros ('acts_as_whatever')
|
294
|
+
|
295
|
+
|
296
|
+
## 2.0 2009-02-03
|
297
|
+
|
298
|
+
- Add annotate_models plugin fork additions
|
299
|
+
- Annotates Rspec and Test Unit models
|
300
|
+
- Annotates Object Daddy exemplars
|
301
|
+
- Annotates geometrical columns
|
302
|
+
|
303
|
+
- Add AnnotateRoutes rake task
|
304
|
+
- Up gem structure to newgem defaults
|
305
|
+
|
306
|
+
|
307
|
+
## 1.0.4 2008-09-04
|
308
|
+
|
309
|
+
- Only update modified models since last run, thanks to sant0sk1
|
310
|
+
|
311
|
+
## 1.0.3 2008-05-02
|
312
|
+
|
313
|
+
- Add misc changes from Dustin Sallings and Henrik N
|
314
|
+
- Remove trailing whitespace
|
315
|
+
- More intuitive info messages
|
316
|
+
- Update README file with update-to-date example
|
317
|
+
|
318
|
+
## 1.0.2 2008-03-22
|
319
|
+
|
320
|
+
- Add contributions from Michael Bumann (http://github.com/bumi)
|
321
|
+
- added an option "position" to choose to put the annotation,
|
322
|
+
- spec/fixtures now also get annotated
|
323
|
+
- added a task to remove the annotations
|
324
|
+
- these options can be specified from command line as `-d` and `-p [before|after]`
|
325
|
+
|
326
|
+
|
data/{README.rdoc → README.md}
RENAMED
@@ -1,15 +1,14 @@
|
|
1
|
-
|
1
|
+
## Annotate (aka AnnotateModels)
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
3
|
+
[![Gem Version](https://badge.fury.io/rb/annotate.svg)](http://badge.fury.io/rb/annotate)
|
4
|
+
[![Downloads count](https://img.shields.io/gem/dt/annotate.svg?style=flat)](https://rubygems.org/gems/annotate)
|
5
|
+
[![Build status](https://travis-ci.org/ctran/annotate_models.svg?branch=develop)](https://travis-ci.org/ctran/annotate_models)
|
6
|
+
[![CI Status](https://github.com/ctran/annotate_models/workflows/CI/badge.svg)](https://github.com/ctran/annotate_models/actions?workflow=CI)
|
7
|
+
[![Coveralls](https://coveralls.io/repos/ctran/annotate_models/badge.svg?branch=develop)](https://coveralls.io/r/ctran/annotate_models?branch=develop)
|
8
|
+
[![Maintenability](https://codeclimate.com/github/ctran/annotate_models/badges/gpa.svg)](https://codeclimate.com/github/ctran/annotate_models)
|
9
|
+
[![Inline docs](http://inch-ci.org/github/ctran/annotate_models.svg?branch=develop)](http://inch-ci.org/github/ctran/annotate_models)
|
10
10
|
|
11
|
-
Add a comment summarizing the current schema to the top or bottom of each of
|
12
|
-
your...
|
11
|
+
Add a comment summarizing the current schema to the top or bottom of each of your...
|
13
12
|
|
14
13
|
- ActiveRecord models
|
15
14
|
- Fixture files
|
@@ -17,53 +16,85 @@ your...
|
|
17
16
|
- Object Daddy exemplars
|
18
17
|
- Machinist blueprints
|
19
18
|
- Fabrication fabricators
|
20
|
-
- Thoughtbot's factory_bot factories, i.e. the (spec|test)/factories/<model>_factory.rb files
|
21
|
-
- routes.rb file (for Rails projects)
|
19
|
+
- Thoughtbot's factory_bot factories, i.e. the `(spec|test)/factories/<model>_factory.rb` files
|
20
|
+
- `routes.rb` file (for Rails projects)
|
21
|
+
|
22
22
|
|
23
23
|
The schema comment looks like this:
|
24
24
|
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
25
|
+
```ruby
|
26
|
+
# == Schema Info
|
27
|
+
#
|
28
|
+
# Table name: line_items
|
29
|
+
#
|
30
|
+
# id :integer(11) not null, primary key
|
31
|
+
# quantity :integer(11) not null
|
32
|
+
# product_id :integer(11) not null
|
33
|
+
# unit_price :float
|
34
|
+
# order_id :integer(11)
|
35
|
+
#
|
36
|
+
|
37
|
+
class LineItem < ActiveRecord::Base
|
38
|
+
belongs_to :product
|
39
|
+
. . .
|
40
|
+
```
|
41
|
+
|
42
|
+
It also annotates geometrical columns, `geom` type and `srid`,
|
43
|
+
when using `SpatialAdapter`, `PostgisAdapter` or `PostGISAdapter`:
|
44
|
+
|
45
|
+
```ruby
|
46
|
+
# == Schema Info
|
47
|
+
#
|
48
|
+
# Table name: trips
|
49
|
+
#
|
50
|
+
# local :geometry point, 4326
|
51
|
+
# path :geometry line_string, 4326
|
52
|
+
```
|
53
|
+
|
54
|
+
Also, if you pass the `-r` option, it'll annotate `routes.rb` with the output of `rake routes`.
|
35
55
|
|
36
|
-
class LineItem < ActiveRecord::Base
|
37
|
-
belongs_to :product
|
38
|
-
. . .
|
39
56
|
|
40
|
-
|
41
|
-
+SpatialAdapter+, +PostgisAdapter+ or +PostGISAdapter+:
|
57
|
+
## Upgrading to 3.X and annotate models not working?
|
42
58
|
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
# local :geometry point, 4326
|
48
|
-
# path :geometry line_string, 4326
|
59
|
+
In versions 2.7.X the annotate gem defaulted to annotating models if no arguments were passed in.
|
60
|
+
The annotate gem by default would not allow for routes and models to be annotated together.
|
61
|
+
A [change was added in #647](https://github.com/ctran/annotate_models/pull/647).
|
62
|
+
You [can read more here](https://github.com/ctran/annotate_models/issues/663).
|
49
63
|
|
50
|
-
|
51
|
-
<code>rake routes</code>.
|
64
|
+
There are a few ways of fixing this:
|
52
65
|
|
66
|
+
- If using CLI explicitly pass in models flag using `--models`
|
53
67
|
|
54
|
-
|
68
|
+
OR
|
69
|
+
|
70
|
+
a) Running `rails g annotate:install` will overwrite your defaults with the annotating `models` option set to `'true'`.
|
71
|
+
|
72
|
+
b) In `lib/tasks/auto_annotate_models.rake` add the `models` key-value option:
|
73
|
+
|
74
|
+
```ruby
|
75
|
+
Annotate.set_defaults(
|
76
|
+
...
|
77
|
+
'models' => 'true',
|
78
|
+
...
|
79
|
+
```
|
80
|
+
|
81
|
+
## Install
|
55
82
|
|
56
83
|
Into Gemfile from rubygems.org:
|
57
84
|
|
58
|
-
|
59
|
-
|
60
|
-
|
85
|
+
```ruby
|
86
|
+
group :development do
|
87
|
+
gem 'annotate'
|
88
|
+
end
|
89
|
+
```
|
61
90
|
|
62
91
|
Into Gemfile from Github:
|
63
92
|
|
64
|
-
|
65
|
-
|
66
|
-
|
93
|
+
```ruby
|
94
|
+
group :development do
|
95
|
+
gem 'annotate', git: 'https://github.com/ctran/annotate_models.git'
|
96
|
+
end
|
97
|
+
```
|
67
98
|
|
68
99
|
Into environment gems from rubygems.org:
|
69
100
|
|
@@ -76,12 +107,11 @@ Into environment gems from Github checkout:
|
|
76
107
|
rake build
|
77
108
|
gem install pkg/annotate-*.gem
|
78
109
|
|
110
|
+
## Usage
|
79
111
|
|
80
|
-
|
81
|
-
|
82
|
-
(If you used the Gemfile install, prefix the below commands with <code>bundle exec</code>.)
|
112
|
+
(If you used the Gemfile install, prefix the below commands with `bundle exec`.)
|
83
113
|
|
84
|
-
|
114
|
+
### Usage in Rails
|
85
115
|
|
86
116
|
To annotate all your models, tests, fixtures, and factories:
|
87
117
|
|
@@ -90,11 +120,11 @@ To annotate all your models, tests, fixtures, and factories:
|
|
90
120
|
|
91
121
|
To annotate just your models, tests, and factories:
|
92
122
|
|
93
|
-
annotate --exclude fixtures
|
123
|
+
annotate --models --exclude fixtures
|
94
124
|
|
95
125
|
To annotate just your models:
|
96
126
|
|
97
|
-
annotate --
|
127
|
+
annotate --models
|
98
128
|
|
99
129
|
To annotate routes.rb:
|
100
130
|
|
@@ -108,26 +138,28 @@ To remove routes.rb annotations:
|
|
108
138
|
|
109
139
|
annotate --routes --delete
|
110
140
|
|
111
|
-
To automatically annotate every time you run
|
141
|
+
To automatically annotate every time you run `db:migrate`,
|
142
|
+
either run `rails g annotate:install`
|
143
|
+
or add `Annotate.load_tasks` to your `Rakefile`.
|
112
144
|
|
113
|
-
|
145
|
+
See the [configuration in Rails](#configuration-in-rails) section for more info.
|
114
146
|
|
115
|
-
|
116
|
-
probably need to explicitly set one or more +--require+ option(s), and/or one
|
117
|
-
or more +--model-dir+ options to inform annotate about the structure of your
|
118
|
-
project and help it bootstrap and load the relevant code.
|
147
|
+
### Usage Outside of Rails
|
119
148
|
|
149
|
+
Everything above applies, except that `--routes` is not meaningful,
|
150
|
+
and you will probably need to explicitly set one or more `--require` option(s), and/or one or more `--model-dir` options
|
151
|
+
to inform `annotate` about the structure of your project and help it bootstrap and load the relevant code.
|
120
152
|
|
121
|
-
|
153
|
+
## Configuration
|
122
154
|
|
123
155
|
If you want to always skip annotations on a particular model, add this string
|
124
156
|
anywhere in the file:
|
125
157
|
|
126
158
|
# -*- SkipSchemaAnnotations
|
127
159
|
|
128
|
-
|
160
|
+
### Configuration in Rails
|
129
161
|
|
130
|
-
To generate a configuration file (in the form of a
|
162
|
+
To generate a configuration file (in the form of a `.rake` file), to set
|
131
163
|
default options:
|
132
164
|
|
133
165
|
rails g annotate:install
|
@@ -135,7 +167,7 @@ default options:
|
|
135
167
|
Edit this file to control things like output format, where annotations are
|
136
168
|
added (top or bottom of file), and in which artifacts.
|
137
169
|
|
138
|
-
The generated rakefile
|
170
|
+
The generated rakefile `lib/tasks/auto_annotate_models.rake` also contains
|
139
171
|
`Annotate.load_tasks`. This adds a few rake tasks which duplicate command-line
|
140
172
|
functionality:
|
141
173
|
|
@@ -144,26 +176,30 @@ functionality:
|
|
144
176
|
rake remove_annotation # Remove schema information from model and fixture files
|
145
177
|
|
146
178
|
By default, once you've generated a configuration file, annotate will be
|
147
|
-
executed whenever you run
|
148
|
-
If you want to disable this behavior permanently,
|
149
|
-
change:
|
179
|
+
executed whenever you run `rake db:migrate` (but only in development mode).
|
180
|
+
If you want to disable this behavior permanently,
|
181
|
+
edit the `.rake` file and change:
|
150
182
|
|
183
|
+
```ruby
|
151
184
|
'skip_on_db_migrate' => 'false',
|
185
|
+
```
|
152
186
|
|
153
187
|
To:
|
154
188
|
|
189
|
+
```ruby
|
155
190
|
'skip_on_db_migrate' => 'true',
|
191
|
+
```
|
156
192
|
|
157
|
-
If you want to run
|
193
|
+
If you want to run `rake db:migrate` as a one-off without running annotate,
|
158
194
|
you can do so with a simple environment variable, instead of editing the
|
159
|
-
|
195
|
+
`.rake` file:
|
160
196
|
|
161
197
|
ANNOTATE_SKIP_ON_DB_MIGRATE=1 rake db:migrate
|
162
198
|
|
163
|
-
|
164
|
-
== Options
|
199
|
+
## Options
|
165
200
|
|
166
201
|
Usage: annotate [options] [model_file]*
|
202
|
+
--additional-file-patterns Additional file paths or globs to annotate, separated by commas (e.g. `/foo/bar/%model_name%/*.rb,/baz/%model_name%.rb`)
|
167
203
|
-d, --delete Remove annotations from all model files or the routes.rb file
|
168
204
|
-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)
|
169
205
|
--position
|
@@ -184,6 +220,7 @@ you can do so with a simple environment variable, instead of editing the
|
|
184
220
|
--wo, --wrapper-open STR Annotation wrapper opening.
|
185
221
|
--wc, --wrapper-close STR Annotation wrapper closing
|
186
222
|
-r, --routes Annotate routes.rb with the output of 'rake routes'
|
223
|
+
--models Annotate ActiveRecord models
|
187
224
|
-a, --active-admin Annotate active_admin models
|
188
225
|
-v, --version Show the current version of this gem
|
189
226
|
-m, --show-migration Include the migration version number in the annotation
|
@@ -200,77 +237,95 @@ you can do so with a simple environment variable, instead of editing the
|
|
200
237
|
-R, --require path Additional file to require before loading models, may be used multiple times
|
201
238
|
-e [tests,fixtures,factories,serializers],
|
202
239
|
--exclude Do not annotate fixtures, test files, factories, and/or serializers
|
203
|
-
-f [bare|rdoc|markdown],
|
240
|
+
-f [bare|rdoc|yard|markdown], Render Schema Infomation as plain/RDoc/YARD/Markdown
|
204
241
|
--format
|
205
242
|
--force Force new annotations even if there are no changes.
|
243
|
+
--frozen Do not allow to change annotations. Exits non-zero if there are going to be changes to files.
|
206
244
|
--timestamp Include timestamp in (routes) annotation
|
207
245
|
--trace If unable to annotate a file, print the full stack trace, not just the exception message.
|
208
|
-
-I, --ignore-columns REGEX don't annotate columns that match a given REGEX (
|
209
|
-
--ignore-routes REGEX don't annotate routes that match a given REGEX (
|
246
|
+
-I, --ignore-columns REGEX don't annotate columns that match a given REGEX (e.g. `annotate -I '^(id|updated_at|created_at)'`)
|
247
|
+
--ignore-routes REGEX don't annotate routes that match a given REGEX (e.g. `annotate -I '(mobile|resque|pghero)'`)_
|
210
248
|
--hide-limit-column-types VALUES
|
211
|
-
don't show limit for given column types, separated by commas (
|
249
|
+
don't show limit for given column types, separated by commas (e.g. `integer,boolean,text`)
|
212
250
|
--hide-default-column-types VALUES
|
213
|
-
don't show default for given column types, separated by commas (
|
251
|
+
don't show default for given column types, separated by commas (e.g. `json,jsonb,hstore`)
|
214
252
|
--ignore-unknown-models don't display warnings for bad model files
|
215
253
|
--with-comment include database comments in model annotations
|
216
254
|
|
255
|
+
### Option: `additional_file_patterns`
|
256
|
+
|
257
|
+
CLI: `--additional-file-patterns`<br>
|
258
|
+
Ruby: `:additional_file_patterns`
|
259
|
+
|
260
|
+
Provide additional paths for the gem to annotate. These paths can include
|
261
|
+
globs. It is recommended to use absolute paths. Here are some examples:
|
262
|
+
|
263
|
+
* `/app/lib/decorates/%MODEL_NAME%/*.rb`
|
264
|
+
* `/app/lib/forms/%PLURALIZED_MODEL_NAME%/**/*.rb`
|
265
|
+
* `/app/lib/forms/%TABLE_NAME%/*.rb`
|
266
|
+
|
217
267
|
|
268
|
+
The appropriate model will be inferred using the `%*%` syntax, annotating any
|
269
|
+
matching files. It works with existing filename resolutions (options for which
|
270
|
+
can be found in the `resolve_filename` method of `annotate_models.rb`).
|
218
271
|
|
219
|
-
|
272
|
+
When using in a Rails config, you can use the following:
|
273
|
+
|
274
|
+
`File.join(Rails.application.root,
|
275
|
+
'app/lib/forms/%PLURALIZED_MODEL_NAME%/***/**.rb')`
|
276
|
+
|
277
|
+
## Sorting
|
220
278
|
|
221
279
|
By default, columns will be sorted in database order (i.e. the order in which
|
222
280
|
migrations were run).
|
223
281
|
|
224
|
-
If you prefer to sort alphabetically so that the results of
|
225
|
-
|
226
|
-
use +--sort+.
|
282
|
+
If you prefer to sort alphabetically so that the results of annotation are
|
283
|
+
consistent regardless of what order migrations are executed in, use `--sort`.
|
227
284
|
|
228
|
-
|
229
|
-
== Markdown
|
285
|
+
## Markdown
|
230
286
|
|
231
287
|
The format produced is actually MultiMarkdown, making use of the syntax
|
232
|
-
extension for tables. It's recommended you use
|
233
|
-
you want to use this format. If you're using
|
234
|
-
specify a format of markdown with
|
235
|
-
your
|
288
|
+
extension for tables. It's recommended you use `kramdown` as your parser if
|
289
|
+
you want to use this format. If you're using `yard` to generate
|
290
|
+
documentation, specify a format of markdown with `kramdown` as the provider by
|
291
|
+
adding this to your `.yardopts` file:
|
236
292
|
|
237
293
|
--markup markdown
|
238
294
|
--markup-provider kramdown
|
239
295
|
|
240
|
-
Be sure to add this to your
|
241
|
-
|
242
|
-
gem 'kramdown', :groups => [:development], :require => false
|
296
|
+
Be sure to add this to your `Gemfile` as well:
|
243
297
|
|
298
|
+
gem 'kramdown', groups => [:development], require => false
|
244
299
|
|
245
|
-
|
300
|
+
## WARNING
|
246
301
|
|
247
|
-
|
302
|
+
**Don't add text after an automatically-created comment block.** This tool
|
248
303
|
will blow away the initial/final comment block in your models if it looks like
|
249
304
|
it was previously added by this gem.
|
250
305
|
|
251
|
-
Be sure to check the changes that this tool makes! If you are using Git,
|
252
|
-
|
306
|
+
Be sure to check the changes that this tool makes! If you are using Git, you
|
307
|
+
may simply check your project's status after running `annotate`:
|
253
308
|
|
254
309
|
$ git status
|
255
310
|
|
256
311
|
If you are not using a VCS (like Git, Subversion or similar), please tread
|
257
312
|
extra carefully, and consider using one.
|
258
313
|
|
259
|
-
|
314
|
+
## Links
|
260
315
|
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
316
|
+
* Factory Bot: http://github.com/thoughtbot/factory_bot
|
317
|
+
* Object Daddy: http://github.com/flogic/object_daddy
|
318
|
+
* Machinist: http://github.com/notahat/machinist
|
319
|
+
* Fabrication: http://github.com/paulelliott/fabrication
|
320
|
+
* SpatialAdapter: http://github.com/pdeffendol/spatial_adapter
|
321
|
+
* PostgisAdapter: http://github.com/nofxx/postgis_adapter
|
322
|
+
* PostGISAdapter: https://github.com/dazuma/activerecord-postgis-adapter
|
268
323
|
|
269
324
|
|
270
|
-
|
325
|
+
## License
|
271
326
|
|
272
327
|
Released under the same license as Ruby. No Support. No Warranty.
|
273
328
|
|
274
|
-
|
329
|
+
## Authors
|
275
330
|
|
276
|
-
|
331
|
+
[See AUTHORS.md](AUTHORS.md).
|