annotate 3.0.2 → 3.2.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -4,7 +4,20 @@
4
4
  # Append annotations to Rake tasks for ActiveRecord, so annotate automatically gets
5
5
  # run after doing db:migrate.
6
6
 
7
- %w(db:migrate db:migrate:up db:migrate:down db:migrate:reset db:migrate:redo db:rollback).each do |task|
7
+ migration_tasks = %w(db:migrate db:migrate:up db:migrate:down db:migrate:reset db:migrate:redo db:rollback)
8
+ if defined?(Rails::Application) && Rails.version.split('.').first.to_i >= 6
9
+ require 'active_record'
10
+
11
+ databases = ActiveRecord::Tasks::DatabaseTasks.setup_initial_database_yaml
12
+
13
+ ActiveRecord::Tasks::DatabaseTasks.for_each(databases) do |spec_name|
14
+ migration_tasks.concat(%w(db:migrate db:migrate:up db:migrate:down).map { |task| "#{task}:#{spec_name}" })
15
+ end
16
+ end
17
+
18
+ migration_tasks.each do |task|
19
+ next unless Rake::Task.task_defined?(task)
20
+
8
21
  Rake::Task[task].enhance do
9
22
  Rake::Task[Rake.application.top_level_tasks.last].enhance do
10
23
  annotation_options_task = if Rake::Task.task_defined?('app:set_annotation_options')
@@ -23,11 +36,11 @@ module Annotate
23
36
  @@working = false
24
37
 
25
38
  def self.update_annotations
26
- unless @@working || Annotate.skip_on_migration?
39
+ unless @@working || Annotate::Helpers.skip_on_migration?
27
40
  @@working = true
28
41
 
29
- self.update_models if Annotate.include_models?
30
- self.update_routes if Annotate.include_routes?
42
+ self.update_models if Annotate::Helpers.include_models?
43
+ self.update_routes if Annotate::Helpers.include_routes?
31
44
  end
32
45
  end
33
46
 
@@ -1,15 +1,21 @@
1
+ annotate_lib = File.expand_path(File.dirname(File.dirname(__FILE__)))
2
+
3
+ unless ENV['is_cli']
4
+ task :set_annotation_options
5
+ task annotate_routes: :set_annotation_options
6
+ end
7
+
1
8
  desc "Adds the route map to routes.rb"
2
9
  task :annotate_routes => :environment do
3
- annotate_lib = File.expand_path(File.dirname(File.dirname(__FILE__)))
4
10
  require "#{annotate_lib}/annotate/annotate_routes"
5
11
 
6
12
  options={}
7
- ENV['position'] = options[:position] = Annotate.fallback(ENV['position'], 'before')
8
- options[:position_in_routes] = Annotate.fallback(ENV['position_in_routes'], ENV['position'])
9
- options[:ignore_routes] = Annotate.fallback(ENV['ignore_routes'], nil)
13
+ ENV['position'] = options[:position] = Annotate::Helpers.fallback(ENV['position'], 'before')
14
+ options[:position_in_routes] = Annotate::Helpers.fallback(ENV['position_in_routes'], ENV['position'])
15
+ options[:ignore_routes] = Annotate::Helpers.fallback(ENV['ignore_routes'], nil)
10
16
  options[:require] = ENV['require'] ? ENV['require'].split(',') : []
11
- options[:wrapper_open] = Annotate.fallback(ENV['wrapper_open'], ENV['wrapper'])
12
- options[:wrapper_close] = Annotate.fallback(ENV['wrapper_close'], ENV['wrapper'])
17
+ options[:wrapper_open] = Annotate::Helpers.fallback(ENV['wrapper_open'], ENV['wrapper'])
18
+ options[:wrapper_close] = Annotate::Helpers.fallback(ENV['wrapper_close'], ENV['wrapper'])
13
19
  AnnotateRoutes.do_annotations(options)
14
20
  end
15
21
 
data/potato.md ADDED
@@ -0,0 +1,41 @@
1
+ Colons can be used to align columns.
2
+
3
+ | Tables | Are | Cool |
4
+ | ------------- |:-------------:| -----:|
5
+ | col 3 is | right-aligned | $1600 |
6
+ | col 2 is | centered | $12 |
7
+ | zebra stripes | are neat | $1 |
8
+
9
+ There must be at least 3 dashes separating each header cell.
10
+ The outer pipes (|) are optional, and you don't need to make the
11
+ raw Markdown line up prettily. You can also use inline Markdown.
12
+
13
+ Markdown | Less | Pretty
14
+ --- | --- | ---
15
+ *Still* | `renders` | **nicely**
16
+ 1 | 2 | 3
17
+
18
+
19
+ ## Route Map
20
+
21
+  Prefix | Verb | URI Pattern | Controller#Action
22
+ --------- | ---------- | --------------- | --------------------
23
+ myaction1 | GET | /url1(.:format) | mycontroller1#action
24
+ myaction2 | POST | /url2(.:format) | mycontroller2#action
25
+  myaction3 | DELETE-GET | /url3(.:format) | mycontroller3#action \n")
26
+
27
+
28
+
29
+ Table name: `users`
30
+
31
+ ### Columns
32
+
33
+ Name | Type | Attributes
34
+ ----------------------- | ------------------ | ---------------------------
35
+ **`id`** | `integer` | `not null, primary key`
36
+ **`foreign_thing_id`** | `integer` | `not null`
37
+
38
+ ### Foreign Keys
39
+
40
+ * `fk_rails_...` (_ON DELETE => on_delete_value ON UPDATE => on_update_value_):
41
+ * **`foreign_thing_id => foreign_things.id`**
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: annotate
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.2
4
+ version: 3.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alex Chaffee
@@ -12,7 +12,7 @@ authors:
12
12
  autorequire:
13
13
  bindir: bin
14
14
  cert_chain: []
15
- date: 2019-09-29 00:00:00.000000000 Z
15
+ date: 2022-02-10 00:00:00.000000000 Z
16
16
  dependencies:
17
17
  - !ruby/object:Gem::Dependency
18
18
  name: rake
@@ -23,7 +23,7 @@ dependencies:
23
23
  version: '10.4'
24
24
  - - "<"
25
25
  - !ruby/object:Gem::Version
26
- version: '13.0'
26
+ version: '14.0'
27
27
  type: :runtime
28
28
  prerelease: false
29
29
  version_requirements: !ruby/object:Gem::Requirement
@@ -33,7 +33,7 @@ dependencies:
33
33
  version: '10.4'
34
34
  - - "<"
35
35
  - !ruby/object:Gem::Version
36
- version: '13.0'
36
+ version: '14.0'
37
37
  - !ruby/object:Gem::Dependency
38
38
  name: activerecord
39
39
  requirement: !ruby/object:Gem::Requirement
@@ -43,7 +43,7 @@ dependencies:
43
43
  version: '3.2'
44
44
  - - "<"
45
45
  - !ruby/object:Gem::Version
46
- version: '7.0'
46
+ version: '8.0'
47
47
  type: :runtime
48
48
  prerelease: false
49
49
  version_requirements: !ruby/object:Gem::Requirement
@@ -53,7 +53,7 @@ dependencies:
53
53
  version: '3.2'
54
54
  - - "<"
55
55
  - !ruby/object:Gem::Version
56
- version: '7.0'
56
+ version: '8.0'
57
57
  description: Annotates Rails/ActiveRecord Models, routes, fixtures, and others based
58
58
  on the database schema.
59
59
  email:
@@ -66,22 +66,25 @@ executables:
66
66
  - annotate
67
67
  extensions: []
68
68
  extra_rdoc_files:
69
- - README.rdoc
70
- - CHANGELOG.rdoc
71
- - TODO.rdoc
69
+ - README.md
70
+ - CHANGELOG.md
72
71
  files:
73
- - AUTHORS.rdoc
74
- - CHANGELOG.rdoc
72
+ - AUTHORS.md
73
+ - CHANGELOG.md
75
74
  - LICENSE.txt
76
- - README.rdoc
77
- - TODO.rdoc
75
+ - README.md
76
+ - RELEASE.md
78
77
  - annotate.gemspec
79
78
  - bin/annotate
80
79
  - lib/annotate.rb
81
80
  - lib/annotate/active_record_patch.rb
82
81
  - lib/annotate/annotate_models.rb
82
+ - lib/annotate/annotate_models/file_patterns.rb
83
83
  - lib/annotate/annotate_routes.rb
84
+ - lib/annotate/annotate_routes/header_generator.rb
85
+ - lib/annotate/annotate_routes/helpers.rb
84
86
  - lib/annotate/constants.rb
87
+ - lib/annotate/helpers.rb
85
88
  - lib/annotate/parser.rb
86
89
  - lib/annotate/tasks.rb
87
90
  - lib/annotate/version.rb
@@ -91,10 +94,13 @@ files:
91
94
  - lib/tasks/annotate_models.rake
92
95
  - lib/tasks/annotate_models_migrate.rake
93
96
  - lib/tasks/annotate_routes.rake
94
- homepage: http://github.com/ctran/annotate_models
97
+ - potato.md
98
+ homepage: https://github.com/ctran/annotate_models
95
99
  licenses:
96
100
  - Ruby
97
- metadata: {}
101
+ metadata:
102
+ bug_tracker_uri: https://github.com/ctran/annotate_models/issues/
103
+ source_code_uri: https://github.com/ctran/annotate_models.git
98
104
  post_install_message:
99
105
  rdoc_options: []
100
106
  require_paths:
@@ -103,15 +109,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
103
109
  requirements:
104
110
  - - ">="
105
111
  - !ruby/object:Gem::Version
106
- version: 2.2.0
112
+ version: 2.4.0
107
113
  required_rubygems_version: !ruby/object:Gem::Requirement
108
114
  requirements:
109
115
  - - ">="
110
116
  - !ruby/object:Gem::Version
111
117
  version: '0'
112
118
  requirements: []
113
- rubyforge_project:
114
- rubygems_version: 2.7.7
119
+ rubygems_version: 3.3.7
115
120
  signing_key:
116
121
  specification_version: 4
117
122
  summary: Annotates Rails Models, routes, fixtures, and others based on the database
data/CHANGELOG.rdoc DELETED
@@ -1,238 +0,0 @@
1
- == 3.0.2
2
- * Fixes `LoadError` due to gemspec not referencing `parser.rb`, issue #657 (#660)
3
- * Changes `--additional_file_patterns` to use dashes `--additional-file-patterns` for consistency (#649)
4
- * Refactor: moving constants into `constants.rb` (#653)
5
-
6
- == 3.0.1
7
- * Skipped as an official release, used the 3.0.1 patch for setting up Github Actions (#619)
8
-
9
- == 3.0.0
10
- * Added `--models` CLI option fixing issue #563 (#647)
11
- * Added `--additional_file_patterns` option for additional file patterns (#633) #636) #637)
12
- * Refactored CLI parser (#646)
13
- * Fixed BigDecimal.new deprecation warning (#634)
14
- * Fixed annotations for columns with long data types (#622)
15
- * Made methods private in AnnotateRoutes (#598)
16
-
17
- See https://github.com/ctran/annotate_models/releases/tag/v3.0.0
18
-
19
- == 2.7.5
20
- See https://github.com/ctran/annotate_models/releases/tag/v2.7.5
21
-
22
- == 2.7.3
23
- See https://github.com/ctran/annotate_models/releases/tag/v2.7.3
24
-
25
- == 2.7.2
26
- See https://github.com/ctran/annotate_models/releases/tag/v2.7.2
27
-
28
- == 2.7.1
29
- See https://github.com/ctran/annotate_models/releases/tag/v2.7.1
30
-
31
- == 2.7.0
32
- See https://github.com/ctran/annotate_models/releases/tag/v2.7.0
33
-
34
- == 2.6.9
35
- * Support foreigh key (#241)
36
- * Check if model has skip tag in annotate_model_file (#167)
37
- * Fix issue where serializer-related flags weren't being honored (#246)
38
- * Prefer SQL column type over normalized AR type (#231)
39
-
40
- == 2.6.8
41
- * Nothing annotated unless options[:model_dir] is specified, #234
42
-
43
- == 2.6.7
44
- * Nothing annotated unless options[:model_dir] is specified, #234
45
-
46
- == 2.6.6
47
- * Makes it possible to wrap annotations, #225
48
- * Fix single model generation, #214
49
- * Fix default value for Rails 4.2, #212
50
- * Don't crash on inherited models in subdirectories, #232
51
- * Process model_dir in rake task, #197
52
-
53
- == 2.6.4
54
- * Skip "models/concerns", #194
55
- * Fix #173 where annotate says "Nothing to annotate" in rails 4.2
56
- * Display an error message if not run from the root of the project, #186
57
- * Support rails 4.0 new default test directory, #182
58
- * Add an option to show timestamp in routes "-timestamp", #136
59
- * Skip plain ruby objects if they have the same class name as an ActiveRecord object, #121
60
-
61
- == 2.6.3
62
- * Fix bug of annotate position in routes (#158)
63
-
64
- == 2.6.2
65
- * Retain the current annotate block unless --force is specified
66
- * Always load models, since they may not be autoloaded by Rails
67
- * The pg array type is now detected (see #158)
68
-
69
- == 2.6.0.beta2
70
-
71
- * support for composite_primary_keys (garysweaver)
72
- * bug fix for annotate_one_file (vlado)
73
-
74
- == 2.6.0.beta1
75
-
76
- * It's now possible to use Annotate in standalone ActiveRecord (non-Rails)
77
- projects again.
78
- * Adding note that Markdown is actually MultiMarkdown, and recommending the use
79
- of the `kramdown` engine for parsing it.
80
- * Improved Markdown formatting considerably.
81
- * Bugfix: Needed to use inline-code tag for column and table names, otherwise
82
- underscores would cause havok with the formatting.
83
- * Bugfix: Markdown syntax was incorrect (can't have trailing spaces before the
84
- closing marker for an emphasis tag).
85
- * Bugfix: Remove-annotations wasn't properly finding test/spec files, and
86
- wasn't even looking for FactoryGirl factories under the new naming
87
- convention.
88
- * Bugfix: Load the Rakefile from the current directory, not the first Rakefile
89
- in our load path.
90
- * Added support for new FactoryGirl naming convention.
91
- * Fix behavior of route annotations in newer versions of Rake that don't spit
92
- out the CWD as their first line of output.
93
- * Overhauled integration testing system to be much easier to work with, better
94
- compartmentalized, and so forth -- at the cost that you must be using RVM to
95
- utilize it. (It'll spit out appropriate pending messages if you don't.)
96
- Also includes a mode for "tinkering" by hand with a scenario, and won't let
97
- you run it through rspect if the repo is in a dirty state. Added appropriate
98
- rake tasks to help with all of this.
99
- * Routes can now be appended, pre-pended, or removed -- and do sane things in
100
- all cases.
101
- * Expose all `position_*` variables as CLI params.
102
- * Make `ENV ['position']` work as a default for all the `ENV ['position_*']`
103
- variables.
104
- * Make rake tasks more resilient to unusual circumstances / code loading
105
- behavior.
106
- * Resolve annotate vs. annotate_models ambiguity once and for all by settling
107
- on `annotate_models` _and_ `annotate_routes`. This avoids a name collision
108
- with RMagick while not needlessly overloading the term.
109
- * Fixed that schema kept prepending additional newlines
110
- * Updates to make annotate smarter about when to touch a model
111
- * Recognize column+type, and don't change a file unless the column+type
112
- combination of the new schema are different than that of the old (i.e., don't
113
- regenerate if columns happen to be in a different order. That's just how life
114
- is sometimes)
115
- * Change annotate to use options hash instead of ENV.
116
-
117
- == 2.5.0
118
-
119
- * Works better with Rails 3
120
- * Bugfix: schema kept prepending additional newlines
121
- * Updates to make annotate smarter about when to touch a model
122
- * Recognize column+type, and don't change a file unless the column+type combination of the new schema are different than that of the old (i.e., don't regenerate if columns happen to be in a different order. That's just how life is sometimes.)
123
- * Grab old specification even if it has \r\n as line endings rather than pure \ns
124
- * Various warning and specification fixes
125
- * Fix "no such file to load -- annotate/annotate_models (MissingSourceFile)"
126
- error (require statements in tasks now use full path to lib files)
127
- * warn about macros, to mitigate when we're included during a production run,
128
- not just a rakefile run -- possibly at the expense of too much noise
129
- * Adding rake as a runtime dependency
130
- * If the schema is already in the model file, it will be replaced into the same
131
- location. If it didn't previously exist, it'll be placed according to the
132
- "position", as before.
133
- * Allow task loading from Rakefile for gems (plugin installation already
134
- auto-detects).
135
- * Add skip_on_db_migrate option as well for people that don't want it
136
- * Fix options parsing to convert strings to proper booleans
137
- * Add support for Fabrication fabricators
138
- * Leave magic encoding comment intact
139
- * Fix issue #14 - RuntimeError: Already memoized
140
- * Count a model as 'annotated' if any of its tests/fixtures are annotated
141
- * Support FactoryGirl
142
- * Support :change migrations (Rails 3.1)
143
- * Allow models with non-standard capitalization
144
- * Widen type column so we can handle longtexts with chopping things off.
145
- * Skip trying to get list of models from commandline when running via Rake (was
146
- preventing the use of multiple rake tasks in one command if one of them was
147
- db:migrate).
148
- * Add ability to skip annotations for a model by adding
149
- '# -*- SkipSchemaAnnotations' anywhere in the file.
150
- * Don't show column limits for integer and boolean types.
151
- * Add sorting for columns and indexes. (Helpful for out-of-order migration
152
- execution. Use --sort if you want this.)
153
- * Annotate unit tests in subfolders.
154
- * Add generator to install rakefile that automatically annotates on db:migrate.
155
- * Correct Gemfile to clarify which environments need which gems.
156
- * Add an .rvmrc to facilitate clean development.
157
- * Refactor out ActiveRecord monkey-patch to permit extending without
158
- side-effects.
159
- * Use ObjectSpace to locate models to facilitate handling of models with
160
- non-standard capitalization.
161
- Note that this still requires that the inflector be configured to understand
162
- the special case.
163
- * Shore up test cases a bit.
164
- * Merge against many of the older branches on Github whose functionality is
165
- already reflected to reduce confusion about what is and is not implemented
166
- here.
167
- * Accept String or Symbol for :position (et al) options.
168
- * Add RDoc output formatting as an option.
169
- * Add Markdown output formatting as an option.
170
- * Add option to force annotation regeneration.
171
- * Add new configuration option for controlling where info is placed in
172
- fixtures/factories.
173
- * Fix for models without tables.
174
- * Fix gemspec generation now that Jeweler looks at Gemfile.
175
- * Fix warning: `NOTE: Gem::Specification#default_executable= is deprecated with
176
- no replacement. It will be removed on or after 2011-10-01.`
177
- * Fix handling of files with no trailing newline when putting annotations at
178
- the end of the file.
179
- * Now works on tables with no primary key.
180
- * --format=markdown option
181
- * --trace option to help debug "Unable to annotate" errors
182
- * "Table name" annotation (if table name is different from model name)
183
- * "Human name" annotation (enabling translation to non-English locales)
184
- * Fix JRuby ObjectSpace compatibility bug (https://github.com/ctran/annotate_models/pull/85)
185
- * Fix FactoryGirl compatibility bug (https://github.com/ctran/annotate_models/pull/82)
186
-
187
- == 2.4.2 2009-11-21
188
-
189
- * Annotates (spec|test)/factories/<model>_factory.rb files
190
-
191
- == 2.4.1 2009-11-20
192
-
193
- * Annotates thoughtbot's factory_girl factories (test/factories/<model>_factory.rb)
194
- * Move default annotation position back to top
195
-
196
- == 2.4.0 2009-12-13
197
-
198
- * Incorporated lots of patches from the Github community, including support for
199
- Blueprints fixtures
200
- * Several bug fixes
201
-
202
- == 2.1 2009-10-18
203
-
204
- * New options
205
- * -R to require additional files before loading the models
206
- * -i to show database indexes in annotations
207
- * -e to exclude annotating tests or fixtures
208
- * -m to include the migration version number in the annotation
209
- * --model-dir to annotate model files stored a different place than app/models
210
- * Ignore unknown macros ('acts_as_whatever')
211
-
212
- == 2.0 2009-02-03
213
-
214
- * Add annotate_models plugin fork additions
215
- * Annotates Rspec and Test Unit models
216
- * Annotates Object Daddy exemplars
217
- * Annotates geometrical columns
218
- * Add AnnotateRoutes rake task
219
- * Up gem structure to newgem defaults
220
-
221
- == 1.0.4 2008-09-04
222
-
223
- * Only update modified models since last run, thanks to sant0sk1
224
-
225
- == 1.0.3 2008-05-02
226
-
227
- * Add misc changes from Dustin Sallings and Henrik N
228
- * Remove trailing whitespace
229
- * More intuitive info messages
230
- * Update README file with update-to-date example
231
-
232
- == 1.0.2 2008-03-22
233
-
234
- * Add contributions from Michael Bumann (http://github.com/bumi)
235
- * added an option "position" to choose to put the annotation,
236
- * spec/fixtures now also get annotated
237
- * added a task to remove the annotations
238
- * these options can be specified from command line as -d and -p [before|after]
data/TODO.rdoc DELETED
@@ -1,11 +0,0 @@
1
- == TODO
2
-
3
- - clean up history
4
- - change default position back to "top" for all annotations
5
- - change 'exclude' to 'only' (double negatives are not unconfusing)
6
-
7
- == TODO (proposed)
8
-
9
- - push two identical gems, named 'annotate' and 'annotate_models'
10
- - supply two binaries, named 'annotate' and 'annotate_models', since there's already a unix tool named 'annotate'
11
- - test EVERYTHING