annotate 2.7.5 → 3.2.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.
@@ -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: 2.7.5
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-04-27 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,21 +66,26 @@ 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
86
+ - lib/annotate/constants.rb
87
+ - lib/annotate/helpers.rb
88
+ - lib/annotate/parser.rb
84
89
  - lib/annotate/tasks.rb
85
90
  - lib/annotate/version.rb
86
91
  - lib/generators/annotate/USAGE
@@ -89,10 +94,13 @@ files:
89
94
  - lib/tasks/annotate_models.rake
90
95
  - lib/tasks/annotate_models_migrate.rake
91
96
  - lib/tasks/annotate_routes.rake
92
- homepage: http://github.com/ctran/annotate_models
97
+ - potato.md
98
+ homepage: https://github.com/ctran/annotate_models
93
99
  licenses:
94
100
  - Ruby
95
- 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
96
104
  post_install_message:
97
105
  rdoc_options: []
98
106
  require_paths:
@@ -101,14 +109,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
101
109
  requirements:
102
110
  - - ">="
103
111
  - !ruby/object:Gem::Version
104
- version: 2.2.0
112
+ version: 2.4.0
105
113
  required_rubygems_version: !ruby/object:Gem::Requirement
106
114
  requirements:
107
115
  - - ">="
108
116
  - !ruby/object:Gem::Version
109
117
  version: '0'
110
118
  requirements: []
111
- rubygems_version: 3.0.3
119
+ rubygems_version: 3.3.7
112
120
  signing_key:
113
121
  specification_version: 4
114
122
  summary: Annotates Rails Models, routes, fixtures, and others based on the database
data/CHANGELOG.rdoc DELETED
@@ -1,220 +0,0 @@
1
- == 2.7.5
2
- See https://github.com/ctran/annotate_models/releases/tag/v2.7.5
3
-
4
- == 2.7.3
5
- See https://github.com/ctran/annotate_models/releases/tag/v2.7.3
6
-
7
- == 2.7.2
8
- See https://github.com/ctran/annotate_models/releases/tag/v2.7.2
9
-
10
- == 2.7.1
11
- See https://github.com/ctran/annotate_models/releases/tag/v2.7.1
12
-
13
- == 2.7.0
14
- See https://github.com/ctran/annotate_models/releases/tag/v2.7.0
15
-
16
- == 2.6.9
17
- * Support foreigh key (#241)
18
- * Check if model has skip tag in annotate_model_file (#167)
19
- * Fix issue where serializer-related flags weren't being honored (#246)
20
- * Prefer SQL column type over normalized AR type (#231)
21
-
22
- == 2.6.8
23
- * Nothing annotated unless options[:model_dir] is specified, #234
24
-
25
- == 2.6.7
26
- * Nothing annotated unless options[:model_dir] is specified, #234
27
-
28
- == 2.6.6
29
- * Makes it possible to wrap annotations, #225
30
- * Fix single model generation, #214
31
- * Fix default value for Rails 4.2, #212
32
- * Don't crash on inherited models in subdirectories, #232
33
- * Process model_dir in rake task, #197
34
-
35
- == 2.6.4
36
- * Skip "models/concerns", #194
37
- * Fix #173 where annotate says "Nothing to annotate" in rails 4.2
38
- * Display an error message if not run from the root of the project, #186
39
- * Support rails 4.0 new default test directory, #182
40
- * Add an option to show timestamp in routes "-timestamp", #136
41
- * Skip plain ruby objects if they have the same class name as an ActiveRecord object, #121
42
-
43
- == 2.6.3
44
- * Fix bug of annotate position in routes (#158)
45
-
46
- == 2.6.2
47
- * Retain the current annotate block unless --force is specified
48
- * Always load models, since they may not be autoloaded by Rails
49
- * The pg array type is now detected (see #158)
50
-
51
- == 2.6.0.beta2
52
-
53
- * support for composite_primary_keys (garysweaver)
54
- * bug fix for annotate_one_file (vlado)
55
-
56
- == 2.6.0.beta1
57
-
58
- * It's now possible to use Annotate in standalone ActiveRecord (non-Rails)
59
- projects again.
60
- * Adding note that Markdown is actually MultiMarkdown, and recommending the use
61
- of the `kramdown` engine for parsing it.
62
- * Improved Markdown formatting considerably.
63
- * Bugfix: Needed to use inline-code tag for column and table names, otherwise
64
- underscores would cause havok with the formatting.
65
- * Bugfix: Markdown syntax was incorrect (can't have trailing spaces before the
66
- closing marker for an emphasis tag).
67
- * Bugfix: Remove-annotations wasn't properly finding test/spec files, and
68
- wasn't even looking for FactoryGirl factories under the new naming
69
- convention.
70
- * Bugfix: Load the Rakefile from the current directory, not the first Rakefile
71
- in our load path.
72
- * Added support for new FactoryGirl naming convention.
73
- * Fix behavior of route annotations in newer versions of Rake that don't spit
74
- out the CWD as their first line of output.
75
- * Overhauled integration testing system to be much easier to work with, better
76
- compartmentalized, and so forth -- at the cost that you must be using RVM to
77
- utilize it. (It'll spit out appropriate pending messages if you don't.)
78
- Also includes a mode for "tinkering" by hand with a scenario, and won't let
79
- you run it through rspect if the repo is in a dirty state. Added appropriate
80
- rake tasks to help with all of this.
81
- * Routes can now be appended, pre-pended, or removed -- and do sane things in
82
- all cases.
83
- * Expose all `position_*` variables as CLI params.
84
- * Make `ENV ['position']` work as a default for all the `ENV ['position_*']`
85
- variables.
86
- * Make rake tasks more resilient to unusual circumstances / code loading
87
- behavior.
88
- * Resolve annotate vs. annotate_models ambiguity once and for all by settling
89
- on `annotate_models` _and_ `annotate_routes`. This avoids a name collision
90
- with RMagick while not needlessly overloading the term.
91
- * Fixed that schema kept prepending additional newlines
92
- * Updates to make annotate smarter about when to touch a model
93
- * Recognize column+type, and don't change a file unless the column+type
94
- combination of the new schema are different than that of the old (i.e., don't
95
- regenerate if columns happen to be in a different order. That's just how life
96
- is sometimes)
97
- * Change annotate to use options hash instead of ENV.
98
-
99
- == 2.5.0
100
-
101
- * Works better with Rails 3
102
- * Bugfix: schema kept prepending additional newlines
103
- * Updates to make annotate smarter about when to touch a model
104
- * 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.)
105
- * Grab old specification even if it has \r\n as line endings rather than pure \ns
106
- * Various warning and specification fixes
107
- * Fix "no such file to load -- annotate/annotate_models (MissingSourceFile)"
108
- error (require statements in tasks now use full path to lib files)
109
- * warn about macros, to mitigate when we're included during a production run,
110
- not just a rakefile run -- possibly at the expense of too much noise
111
- * Adding rake as a runtime dependency
112
- * If the schema is already in the model file, it will be replaced into the same
113
- location. If it didn't previously exist, it'll be placed according to the
114
- "position", as before.
115
- * Allow task loading from Rakefile for gems (plugin installation already
116
- auto-detects).
117
- * Add skip_on_db_migrate option as well for people that don't want it
118
- * Fix options parsing to convert strings to proper booleans
119
- * Add support for Fabrication fabricators
120
- * Leave magic encoding comment intact
121
- * Fix issue #14 - RuntimeError: Already memoized
122
- * Count a model as 'annotated' if any of its tests/fixtures are annotated
123
- * Support FactoryGirl
124
- * Support :change migrations (Rails 3.1)
125
- * Allow models with non-standard capitalization
126
- * Widen type column so we can handle longtexts with chopping things off.
127
- * Skip trying to get list of models from commandline when running via Rake (was
128
- preventing the use of multiple rake tasks in one command if one of them was
129
- db:migrate).
130
- * Add ability to skip annotations for a model by adding
131
- '# -*- SkipSchemaAnnotations' anywhere in the file.
132
- * Don't show column limits for integer and boolean types.
133
- * Add sorting for columns and indexes. (Helpful for out-of-order migration
134
- execution. Use --sort if you want this.)
135
- * Annotate unit tests in subfolders.
136
- * Add generator to install rakefile that automatically annotates on db:migrate.
137
- * Correct Gemfile to clarify which environments need which gems.
138
- * Add an .rvmrc to facilitate clean development.
139
- * Refactor out ActiveRecord monkey-patch to permit extending without
140
- side-effects.
141
- * Use ObjectSpace to locate models to facilitate handling of models with
142
- non-standard capitalization.
143
- Note that this still requires that the inflector be configured to understand
144
- the special case.
145
- * Shore up test cases a bit.
146
- * Merge against many of the older branches on Github whose functionality is
147
- already reflected to reduce confusion about what is and is not implemented
148
- here.
149
- * Accept String or Symbol for :position (et al) options.
150
- * Add RDoc output formatting as an option.
151
- * Add Markdown output formatting as an option.
152
- * Add option to force annotation regeneration.
153
- * Add new configuration option for controlling where info is placed in
154
- fixtures/factories.
155
- * Fix for models without tables.
156
- * Fix gemspec generation now that Jeweler looks at Gemfile.
157
- * Fix warning: `NOTE: Gem::Specification#default_executable= is deprecated with
158
- no replacement. It will be removed on or after 2011-10-01.`
159
- * Fix handling of files with no trailing newline when putting annotations at
160
- the end of the file.
161
- * Now works on tables with no primary key.
162
- * --format=markdown option
163
- * --trace option to help debug "Unable to annotate" errors
164
- * "Table name" annotation (if table name is different from model name)
165
- * "Human name" annotation (enabling translation to non-English locales)
166
- * Fix JRuby ObjectSpace compatibility bug (https://github.com/ctran/annotate_models/pull/85)
167
- * Fix FactoryGirl compatibility bug (https://github.com/ctran/annotate_models/pull/82)
168
-
169
- == 2.4.2 2009-11-21
170
-
171
- * Annotates (spec|test)/factories/<model>_factory.rb files
172
-
173
- == 2.4.1 2009-11-20
174
-
175
- * Annotates thoughtbot's factory_girl factories (test/factories/<model>_factory.rb)
176
- * Move default annotation position back to top
177
-
178
- == 2.4.0 2009-12-13
179
-
180
- * Incorporated lots of patches from the Github community, including support for
181
- Blueprints fixtures
182
- * Several bug fixes
183
-
184
- == 2.1 2009-10-18
185
-
186
- * New options
187
- * -R to require additional files before loading the models
188
- * -i to show database indexes in annotations
189
- * -e to exclude annotating tests or fixtures
190
- * -m to include the migration version number in the annotation
191
- * --model-dir to annotate model files stored a different place than app/models
192
- * Ignore unknown macros ('acts_as_whatever')
193
-
194
- == 2.0 2009-02-03
195
-
196
- * Add annotate_models plugin fork additions
197
- * Annotates Rspec and Test Unit models
198
- * Annotates Object Daddy exemplars
199
- * Annotates geometrical columns
200
- * Add AnnotateRoutes rake task
201
- * Up gem structure to newgem defaults
202
-
203
- == 1.0.4 2008-09-04
204
-
205
- * Only update modified models since last run, thanks to sant0sk1
206
-
207
- == 1.0.3 2008-05-02
208
-
209
- * Add misc changes from Dustin Sallings and Henrik N
210
- * Remove trailing whitespace
211
- * More intuitive info messages
212
- * Update README file with update-to-date example
213
-
214
- == 1.0.2 2008-03-22
215
-
216
- * Add contributions from Michael Bumann (http://github.com/bumi)
217
- * added an option "position" to choose to put the annotation,
218
- * spec/fixtures now also get annotated
219
- * added a task to remove the annotations
220
- * 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