annot8 1.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 +7 -0
- data/AUTHORS.md +34 -0
- data/CHANGELOG.md +341 -0
- data/LICENSE.txt +55 -0
- data/README.md +331 -0
- data/RELEASE.md +19 -0
- data/annot8.gemspec +32 -0
- data/bin/annotate +31 -0
- data/lib/annotate/active_record_patch.rb +11 -0
- data/lib/annotate/annotate_models/file_patterns.rb +129 -0
- data/lib/annotate/annotate_models.rb +1005 -0
- data/lib/annotate/annotate_routes/header_generator.rb +117 -0
- data/lib/annotate/annotate_routes/helpers.rb +71 -0
- data/lib/annotate/annotate_routes.rb +121 -0
- data/lib/annotate/constants.rb +30 -0
- data/lib/annotate/helpers.rb +33 -0
- data/lib/annotate/parser.rb +317 -0
- data/lib/annotate/tasks.rb +8 -0
- data/lib/annotate/version.rb +7 -0
- data/lib/annotate.rb +152 -0
- data/lib/generators/annotate/USAGE +4 -0
- data/lib/generators/annotate/install_generator.rb +17 -0
- data/lib/generators/annotate/templates/auto_annotate_models.rake +63 -0
- data/lib/tasks/annotate_models.rake +79 -0
- data/lib/tasks/annotate_models_migrate.rake +65 -0
- data/lib/tasks/annotate_routes.rake +34 -0
- data/potato.md +41 -0
- metadata +120 -0
@@ -0,0 +1,8 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
require 'rake'
|
5
|
+
|
6
|
+
# Make tasks visible for Rails also when used as gem.
|
7
|
+
Dir[File.join(File.dirname(__FILE__), '..', 'tasks', '**/*.rake')].each { |rake| load rake }
|
8
|
+
Dir[File.join(File.dirname(__FILE__), '..', '..', 'tasks', '**/*.rake')].each { |rake| load rake }
|
data/lib/annotate.rb
ADDED
@@ -0,0 +1,152 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
4
|
+
require 'annotate/version'
|
5
|
+
require 'annotate/annotate_models'
|
6
|
+
require 'annotate/annotate_routes'
|
7
|
+
require 'annotate/constants'
|
8
|
+
require 'annotate/helpers'
|
9
|
+
|
10
|
+
begin
|
11
|
+
# ActiveSupport 3.x...
|
12
|
+
require 'active_support/hash_with_indifferent_access'
|
13
|
+
require 'active_support/core_ext/object/blank'
|
14
|
+
rescue StandardError
|
15
|
+
# ActiveSupport 2.x...
|
16
|
+
require 'active_support/core_ext/hash/indifferent_access'
|
17
|
+
require 'active_support/core_ext/blank'
|
18
|
+
end
|
19
|
+
|
20
|
+
# Defines the Annotate module
|
21
|
+
module Annotate # rubocop:disable Metrics/ModuleLength
|
22
|
+
##
|
23
|
+
# Set default values that can be overridden via environment variables.
|
24
|
+
#
|
25
|
+
def self.set_defaults(options = {})
|
26
|
+
return if @has_set_defaults
|
27
|
+
|
28
|
+
@has_set_defaults = true
|
29
|
+
|
30
|
+
options = ActiveSupport::HashWithIndifferentAccess.new(options)
|
31
|
+
|
32
|
+
Constants::ALL_ANNOTATE_OPTIONS.flatten.each do |key|
|
33
|
+
if options.key?(key)
|
34
|
+
default_value = if options[key].is_a?(Array)
|
35
|
+
options[key].join(',')
|
36
|
+
else
|
37
|
+
options[key]
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
default_value = ENV[key.to_s] unless ENV[key.to_s].blank?
|
42
|
+
ENV[key.to_s] = default_value.nil? ? nil : default_value.to_s
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
##
|
47
|
+
# TODO: what is the difference between this and set_defaults?
|
48
|
+
#
|
49
|
+
def self.setup_options(options = {})
|
50
|
+
Constants::POSITION_OPTIONS.each do |key|
|
51
|
+
options[key] = Annotate::Helpers.fallback(ENV.fetch(key.to_s, nil), ENV.fetch('position', nil), 'before')
|
52
|
+
end
|
53
|
+
Constants::FLAG_OPTIONS.each do |key|
|
54
|
+
options[key] = Annotate::Helpers.true?(ENV.fetch(key.to_s, nil))
|
55
|
+
end
|
56
|
+
Constants::OTHER_OPTIONS.each do |key|
|
57
|
+
options[key] = ENV[key.to_s].blank? ? nil : ENV.fetch(key.to_s, nil)
|
58
|
+
end
|
59
|
+
Constants::PATH_OPTIONS.each do |key|
|
60
|
+
options[key] = ENV[key.to_s].blank? ? [] : ENV[key.to_s].split(',')
|
61
|
+
end
|
62
|
+
|
63
|
+
options[:additional_file_patterns] ||= []
|
64
|
+
if options[:additional_file_patterns].is_a?(String)
|
65
|
+
options[:additional_file_patterns] =
|
66
|
+
options[:additional_file_patterns].split(',')
|
67
|
+
end
|
68
|
+
options[:model_dir] = ['app/models'] if options[:model_dir].empty?
|
69
|
+
|
70
|
+
options[:wrapper_open] ||= options[:wrapper]
|
71
|
+
options[:wrapper_close] ||= options[:wrapper]
|
72
|
+
|
73
|
+
# These were added in 2.7.0 but so this is to revert to old behavior by default
|
74
|
+
options[:exclude_scaffolds] = Annotate::Helpers.true?(ENV.fetch('exclude_scaffolds', 'true'))
|
75
|
+
options[:exclude_controllers] = Annotate::Helpers.true?(ENV.fetch('exclude_controllers', 'true'))
|
76
|
+
options[:exclude_helpers] = Annotate::Helpers.true?(ENV.fetch('exclude_helpers', 'true'))
|
77
|
+
|
78
|
+
options
|
79
|
+
end
|
80
|
+
|
81
|
+
def self.load_tasks
|
82
|
+
return if @tasks_loaded
|
83
|
+
|
84
|
+
Dir[File.join(File.dirname(__FILE__), 'tasks', '**/*.rake')].each do |rake|
|
85
|
+
load rake
|
86
|
+
end
|
87
|
+
|
88
|
+
@tasks_loaded = true
|
89
|
+
end
|
90
|
+
|
91
|
+
def self.eager_load(options)
|
92
|
+
load_requires(options)
|
93
|
+
require 'annotate/active_record_patch'
|
94
|
+
|
95
|
+
if defined?(Rails::Application)
|
96
|
+
if Rails.version.split('.').first.to_i < 3
|
97
|
+
Rails.configuration.eager_load_paths.each do |load_path|
|
98
|
+
matcher = /\A#{Regexp.escape(load_path)}(.*)\.rb\Z/
|
99
|
+
Dir.glob("#{load_path}/**/*.rb").each do |file|
|
100
|
+
require_dependency file.sub(matcher, '\1')
|
101
|
+
end
|
102
|
+
end
|
103
|
+
else
|
104
|
+
klass = Rails::Application.send(:subclasses).first
|
105
|
+
klass.eager_load!
|
106
|
+
end
|
107
|
+
else
|
108
|
+
options[:model_dir].each do |dir|
|
109
|
+
FileList["#{dir}/**/*.rb"].each do |fname|
|
110
|
+
require File.expand_path(fname)
|
111
|
+
end
|
112
|
+
end
|
113
|
+
end
|
114
|
+
end
|
115
|
+
|
116
|
+
def self.bootstrap_rake
|
117
|
+
begin
|
118
|
+
require 'rake/dsl_definition'
|
119
|
+
rescue StandardError => e
|
120
|
+
# We might just be on an old version of Rake...
|
121
|
+
warn e.message
|
122
|
+
exit e.status_code
|
123
|
+
end
|
124
|
+
require 'rake'
|
125
|
+
|
126
|
+
load './Rakefile' if File.exist?('./Rakefile')
|
127
|
+
begin
|
128
|
+
Rake::Task[:environment].invoke
|
129
|
+
rescue StandardError
|
130
|
+
nil
|
131
|
+
end
|
132
|
+
unless defined?(Rails)
|
133
|
+
# Not in a Rails project, so time to load up the parts of
|
134
|
+
# ActiveSupport we need.
|
135
|
+
require 'active_support'
|
136
|
+
require 'active_support/core_ext/class/subclasses'
|
137
|
+
require 'active_support/core_ext/string/inflections'
|
138
|
+
end
|
139
|
+
|
140
|
+
load_tasks
|
141
|
+
Rake::Task[:set_annotation_options].invoke
|
142
|
+
end
|
143
|
+
|
144
|
+
class << self
|
145
|
+
private
|
146
|
+
|
147
|
+
def load_requires(options)
|
148
|
+
options[:require].count > 0 &&
|
149
|
+
options[:require].each { |path| require path }
|
150
|
+
end
|
151
|
+
end
|
152
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'annotate'
|
4
|
+
|
5
|
+
module Annotate
|
6
|
+
module Generators
|
7
|
+
class InstallGenerator < Rails::Generators::Base
|
8
|
+
desc 'Copy annotate_models rakefiles for automatic annotation'
|
9
|
+
source_root File.expand_path('templates', __dir__)
|
10
|
+
|
11
|
+
# copy rake tasks
|
12
|
+
def copy_tasks
|
13
|
+
template 'auto_annotate_models.rake', 'lib/tasks/auto_annotate_models.rake'
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,63 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# NOTE: only doing this in development as some production environments (Heroku)
|
4
|
+
# NOTE: are sensitive to local FS writes, and besides -- it's just not proper
|
5
|
+
# NOTE: to have a dev-mode tool do its thing in production.
|
6
|
+
if Rails.env.development?
|
7
|
+
require 'annotate'
|
8
|
+
task :set_annotation_options do
|
9
|
+
# You can override any of these by setting an environment variable of the
|
10
|
+
# same name.
|
11
|
+
Annotate.set_defaults(
|
12
|
+
'active_admin' => 'false',
|
13
|
+
'additional_file_patterns' => [],
|
14
|
+
'routes' => 'false',
|
15
|
+
'models' => 'true',
|
16
|
+
'position_in_routes' => 'before',
|
17
|
+
'position_in_class' => 'before',
|
18
|
+
'position_in_test' => 'before',
|
19
|
+
'position_in_fixture' => 'before',
|
20
|
+
'position_in_factory' => 'before',
|
21
|
+
'position_in_serializer' => 'before',
|
22
|
+
'show_check_constraints' => 'false',
|
23
|
+
'show_foreign_keys' => 'true',
|
24
|
+
'show_complete_foreign_keys' => 'false',
|
25
|
+
'show_indexes' => 'true',
|
26
|
+
'simple_indexes' => 'false',
|
27
|
+
'model_dir' => 'app/models',
|
28
|
+
'root_dir' => '',
|
29
|
+
'include_version' => 'false',
|
30
|
+
'require' => '',
|
31
|
+
'exclude_tests' => 'false',
|
32
|
+
'exclude_fixtures' => 'false',
|
33
|
+
'exclude_factories' => 'false',
|
34
|
+
'exclude_serializers' => 'false',
|
35
|
+
'exclude_scaffolds' => 'true',
|
36
|
+
'exclude_controllers' => 'true',
|
37
|
+
'exclude_helpers' => 'true',
|
38
|
+
'exclude_sti_subclasses' => 'false',
|
39
|
+
'ignore_model_sub_dir' => 'false',
|
40
|
+
'ignore_columns' => nil,
|
41
|
+
'ignore_routes' => nil,
|
42
|
+
'ignore_unknown_models' => 'false',
|
43
|
+
'hide_limit_column_types' => '<%= AnnotateModels::NO_LIMIT_COL_TYPES.join(",") %>',
|
44
|
+
'hide_default_column_types' => '<%= AnnotateModels::NO_DEFAULT_COL_TYPES.join(",") %>',
|
45
|
+
'skip_on_db_migrate' => 'false',
|
46
|
+
'format_bare' => 'true',
|
47
|
+
'format_rdoc' => 'false',
|
48
|
+
'format_yard' => 'false',
|
49
|
+
'format_markdown' => 'false',
|
50
|
+
'sort' => 'false',
|
51
|
+
'force' => 'false',
|
52
|
+
'frozen' => 'false',
|
53
|
+
'classified_sort' => 'true',
|
54
|
+
'trace' => 'false',
|
55
|
+
'wrapper_open' => nil,
|
56
|
+
'wrapper_close' => nil,
|
57
|
+
'with_comment' => 'true',
|
58
|
+
'with_comment_column' => 'false'
|
59
|
+
)
|
60
|
+
end
|
61
|
+
|
62
|
+
Annotate.load_tasks
|
63
|
+
end
|
@@ -0,0 +1,79 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
annotate_lib = File.expand_path(File.dirname(__FILE__, 2))
|
4
|
+
|
5
|
+
unless ENV['is_cli']
|
6
|
+
task :set_annotation_options
|
7
|
+
task annotate_models: :set_annotation_options
|
8
|
+
end
|
9
|
+
|
10
|
+
desc 'Add schema information (as comments) to model and fixture files'
|
11
|
+
task annotate_models: :environment do
|
12
|
+
require "#{annotate_lib}/annotate/annotate_models"
|
13
|
+
require "#{annotate_lib}/annotate/active_record_patch"
|
14
|
+
|
15
|
+
options = { is_rake: true }
|
16
|
+
ENV['position'] = options[:position] = Annotate::Helpers.fallback(ENV.fetch('position', nil), 'before')
|
17
|
+
options[:additional_file_patterns] = ENV['additional_file_patterns'] ? ENV['additional_file_patterns'].split(',') : []
|
18
|
+
options[:position_in_class] =
|
19
|
+
Annotate::Helpers.fallback(ENV.fetch('position_in_class', nil), ENV.fetch('position', nil))
|
20
|
+
options[:position_in_fixture] =
|
21
|
+
Annotate::Helpers.fallback(ENV.fetch('position_in_fixture', nil), ENV.fetch('position', nil))
|
22
|
+
options[:position_in_factory] =
|
23
|
+
Annotate::Helpers.fallback(ENV.fetch('position_in_factory', nil), ENV.fetch('position', nil))
|
24
|
+
options[:position_in_test] =
|
25
|
+
Annotate::Helpers.fallback(ENV.fetch('position_in_test', nil), ENV.fetch('position', nil))
|
26
|
+
options[:position_in_serializer] =
|
27
|
+
Annotate::Helpers.fallback(ENV.fetch('position_in_serializer', nil), ENV.fetch('position', nil))
|
28
|
+
options[:show_check_constraints] = Annotate::Helpers.true?(ENV.fetch('show_check_constraints', nil))
|
29
|
+
options[:show_foreign_keys] = Annotate::Helpers.true?(ENV.fetch('show_foreign_keys', nil))
|
30
|
+
options[:show_complete_foreign_keys] = Annotate::Helpers.true?(ENV.fetch('show_complete_foreign_keys', nil))
|
31
|
+
options[:show_indexes] = Annotate::Helpers.true?(ENV.fetch('show_indexes', nil))
|
32
|
+
options[:simple_indexes] = Annotate::Helpers.true?(ENV.fetch('simple_indexes', nil))
|
33
|
+
options[:model_dir] = ENV['model_dir'] ? ENV['model_dir'].split(',') : ['app/models']
|
34
|
+
options[:root_dir] = ENV.fetch('root_dir', nil)
|
35
|
+
options[:include_version] = Annotate::Helpers.true?(ENV.fetch('include_version', nil))
|
36
|
+
options[:require] = ENV['require'] ? ENV['require'].split(',') : []
|
37
|
+
options[:exclude_tests] = Annotate::Helpers.true?(ENV.fetch('exclude_tests', nil))
|
38
|
+
options[:exclude_factories] = Annotate::Helpers.true?(ENV.fetch('exclude_factories', nil))
|
39
|
+
options[:exclude_fixtures] = Annotate::Helpers.true?(ENV.fetch('exclude_fixtures', nil))
|
40
|
+
options[:exclude_serializers] = Annotate::Helpers.true?(ENV.fetch('exclude_serializers', nil))
|
41
|
+
options[:exclude_scaffolds] = Annotate::Helpers.true?(ENV.fetch('exclude_scaffolds', nil))
|
42
|
+
options[:exclude_controllers] = Annotate::Helpers.true?(ENV.fetch('exclude_controllers', 'true'))
|
43
|
+
options[:exclude_helpers] = Annotate::Helpers.true?(ENV.fetch('exclude_helpers', 'true'))
|
44
|
+
options[:exclude_sti_subclasses] = Annotate::Helpers.true?(ENV.fetch('exclude_sti_subclasses', nil))
|
45
|
+
options[:ignore_model_sub_dir] = Annotate::Helpers.true?(ENV.fetch('ignore_model_sub_dir', nil))
|
46
|
+
options[:format_bare] = Annotate::Helpers.true?(ENV.fetch('format_bare', nil))
|
47
|
+
options[:format_rdoc] = Annotate::Helpers.true?(ENV.fetch('format_rdoc', nil))
|
48
|
+
options[:format_yard] = Annotate::Helpers.true?(ENV.fetch('format_yard', nil))
|
49
|
+
options[:format_markdown] = Annotate::Helpers.true?(ENV.fetch('format_markdown', nil))
|
50
|
+
options[:sort] = Annotate::Helpers.true?(ENV.fetch('sort', nil))
|
51
|
+
options[:force] = Annotate::Helpers.true?(ENV.fetch('force', nil))
|
52
|
+
options[:frozen] = Annotate::Helpers.true?(ENV.fetch('frozen', nil))
|
53
|
+
options[:classified_sort] = Annotate::Helpers.true?(ENV.fetch('classified_sort', nil))
|
54
|
+
options[:trace] = Annotate::Helpers.true?(ENV.fetch('trace', nil))
|
55
|
+
options[:wrapper_open] = Annotate::Helpers.fallback(ENV.fetch('wrapper_open', nil), ENV.fetch('wrapper', nil))
|
56
|
+
options[:wrapper_close] = Annotate::Helpers.fallback(ENV.fetch('wrapper_close', nil), ENV.fetch('wrapper', nil))
|
57
|
+
options[:ignore_columns] = ENV.fetch('ignore_columns', nil)
|
58
|
+
options[:ignore_routes] = ENV.fetch('ignore_routes', nil)
|
59
|
+
options[:hide_limit_column_types] = Annotate::Helpers.fallback(ENV.fetch('hide_limit_column_types', nil), '')
|
60
|
+
options[:hide_default_column_types] = Annotate::Helpers.fallback(ENV.fetch('hide_default_column_types', nil), '')
|
61
|
+
options[:with_comment] = Annotate::Helpers.true?(ENV.fetch('with_comment', nil))
|
62
|
+
options[:with_comment_column] = Annotate::Helpers.true?(ENV.fetch('with_comment_column', nil))
|
63
|
+
options[:ignore_unknown_models] = Annotate::Helpers.true?(ENV.fetch('ignore_unknown_models', 'false'))
|
64
|
+
|
65
|
+
AnnotateModels.do_annotations(options)
|
66
|
+
end
|
67
|
+
|
68
|
+
desc 'Remove schema information from model and fixture files'
|
69
|
+
task remove_annotation: :environment do
|
70
|
+
require "#{annotate_lib}/annotate/annotate_models"
|
71
|
+
require "#{annotate_lib}/annotate/active_record_patch"
|
72
|
+
|
73
|
+
options = { is_rake: true }
|
74
|
+
options[:model_dir] = ENV.fetch('model_dir', nil)
|
75
|
+
options[:root_dir] = ENV.fetch('root_dir', nil)
|
76
|
+
options[:require] = ENV['require'] ? ENV['require'].split(',') : []
|
77
|
+
options[:trace] = Annotate::Helpers.true?(ENV.fetch('trace', nil))
|
78
|
+
AnnotateModels.remove_annotations(options)
|
79
|
+
end
|
@@ -0,0 +1,65 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# These tasks are added to the project if you install annotate as a Rails plugin.
|
4
|
+
# (They are not used to build annotate itself.)
|
5
|
+
|
6
|
+
# Append annotations to Rake tasks for ActiveRecord, so annotate automatically gets
|
7
|
+
# run after doing db:migrate.
|
8
|
+
|
9
|
+
migration_tasks = %w[db:migrate db:migrate:up db:migrate:down db:migrate:reset db:migrate:redo db:rollback]
|
10
|
+
if defined?(Rails::Application) && Rails.version.split('.').first.to_i >= 6
|
11
|
+
require 'active_record'
|
12
|
+
|
13
|
+
databases = ActiveRecord::Tasks::DatabaseTasks.setup_initial_database_yaml
|
14
|
+
|
15
|
+
ActiveRecord::Tasks::DatabaseTasks.for_each(databases) do |spec_name|
|
16
|
+
migration_tasks.concat(%w[db:migrate db:migrate:up db:migrate:down].map { |task| "#{task}:#{spec_name}" })
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
migration_tasks.each do |task|
|
21
|
+
next unless Rake::Task.task_defined?(task)
|
22
|
+
|
23
|
+
Rake::Task[task].enhance do
|
24
|
+
Rake::Task[Rake.application.top_level_tasks.last].enhance do
|
25
|
+
annotation_options_task = if Rake::Task.task_defined?('app:set_annotation_options')
|
26
|
+
'app:set_annotation_options'
|
27
|
+
else
|
28
|
+
'set_annotation_options'
|
29
|
+
end
|
30
|
+
Rake::Task[annotation_options_task].invoke
|
31
|
+
Annotate::Migration.update_annotations
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
module Annotate
|
37
|
+
class Migration
|
38
|
+
@@working = false
|
39
|
+
|
40
|
+
def self.update_annotations
|
41
|
+
return if @@working || Annotate::Helpers.skip_on_migration?
|
42
|
+
|
43
|
+
@@working = true
|
44
|
+
|
45
|
+
update_models if Annotate::Helpers.include_models?
|
46
|
+
update_routes if Annotate::Helpers.include_routes?
|
47
|
+
end
|
48
|
+
|
49
|
+
def self.update_models
|
50
|
+
if Rake::Task.task_defined?('annotate_models')
|
51
|
+
Rake::Task['annotate_models'].invoke
|
52
|
+
elsif Rake::Task.task_defined?('app:annotate_models')
|
53
|
+
Rake::Task['app:annotate_models'].invoke
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
def self.update_routes
|
58
|
+
if Rake::Task.task_defined?('annotate_routes')
|
59
|
+
Rake::Task['annotate_routes'].invoke
|
60
|
+
elsif Rake::Task.task_defined?('app:annotate_routes')
|
61
|
+
Rake::Task['app:annotate_routes'].invoke
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
annotate_lib = File.expand_path(File.dirname(__FILE__, 2))
|
4
|
+
|
5
|
+
unless ENV['is_cli']
|
6
|
+
task :set_annotation_options
|
7
|
+
task annotate_routes: :set_annotation_options
|
8
|
+
end
|
9
|
+
|
10
|
+
desc 'Adds the route map to routes.rb'
|
11
|
+
task annotate_routes: :environment do
|
12
|
+
require "#{annotate_lib}/annotate/annotate_routes"
|
13
|
+
|
14
|
+
options = {}
|
15
|
+
ENV['position'] = options[:position] = Annotate::Helpers.fallback(ENV.fetch('position', nil), 'before')
|
16
|
+
options[:position_in_routes] =
|
17
|
+
Annotate::Helpers.fallback(ENV.fetch('position_in_routes', nil), ENV.fetch('position', nil))
|
18
|
+
options[:ignore_routes] = Annotate::Helpers.fallback(ENV.fetch('ignore_routes', nil), nil)
|
19
|
+
options[:require] = ENV['require'] ? ENV['require'].split(',') : []
|
20
|
+
options[:frozen] = Annotate::Helpers.true?(ENV.fetch('frozen', nil))
|
21
|
+
options[:wrapper_open] = Annotate::Helpers.fallback(ENV.fetch('wrapper_open', nil), ENV.fetch('wrapper', nil))
|
22
|
+
options[:wrapper_close] = Annotate::Helpers.fallback(ENV.fetch('wrapper_close', nil), ENV.fetch('wrapper', nil))
|
23
|
+
AnnotateRoutes.do_annotations(options)
|
24
|
+
end
|
25
|
+
|
26
|
+
desc 'Removes the route map from routes.rb'
|
27
|
+
task remove_routes: :environment do
|
28
|
+
annotate_lib = File.expand_path(File.dirname(__FILE__, 2))
|
29
|
+
require "#{annotate_lib}/annotate/annotate_routes"
|
30
|
+
|
31
|
+
options = {}
|
32
|
+
options[:require] = ENV['require'] ? ENV['require'].split(',') : []
|
33
|
+
AnnotateRoutes.remove_annotations(options)
|
34
|
+
end
|
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
ADDED
@@ -0,0 +1,120 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: annot8
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Alex Chaffee
|
8
|
+
- Cuong Tran
|
9
|
+
- Marcos Piccinini
|
10
|
+
- Turadg Aleahmad
|
11
|
+
- Jon Frisby
|
12
|
+
- Benjamin Dunkley
|
13
|
+
bindir: bin
|
14
|
+
cert_chain: []
|
15
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
16
|
+
dependencies:
|
17
|
+
- !ruby/object:Gem::Dependency
|
18
|
+
name: activerecord
|
19
|
+
requirement: !ruby/object:Gem::Requirement
|
20
|
+
requirements:
|
21
|
+
- - ">="
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: 8.0.0
|
24
|
+
- - "<"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '9'
|
27
|
+
type: :runtime
|
28
|
+
prerelease: false
|
29
|
+
version_requirements: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 8.0.0
|
34
|
+
- - "<"
|
35
|
+
- !ruby/object:Gem::Version
|
36
|
+
version: '9'
|
37
|
+
- !ruby/object:Gem::Dependency
|
38
|
+
name: rake
|
39
|
+
requirement: !ruby/object:Gem::Requirement
|
40
|
+
requirements:
|
41
|
+
- - ">="
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: '10.4'
|
44
|
+
- - "<"
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: '14.0'
|
47
|
+
type: :runtime
|
48
|
+
prerelease: false
|
49
|
+
version_requirements: !ruby/object:Gem::Requirement
|
50
|
+
requirements:
|
51
|
+
- - ">="
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '10.4'
|
54
|
+
- - "<"
|
55
|
+
- !ruby/object:Gem::Version
|
56
|
+
version: '14.0'
|
57
|
+
description: Annotates Rails/ActiveRecord Models, routes, fixtures, and others based
|
58
|
+
on the database schema. This fork of the "annotate" gemis built for Rails 8 and
|
59
|
+
Ruby 3.2.2+
|
60
|
+
email:
|
61
|
+
- ben@chemica.co.uk
|
62
|
+
executables:
|
63
|
+
- annotate
|
64
|
+
extensions: []
|
65
|
+
extra_rdoc_files:
|
66
|
+
- CHANGELOG.md
|
67
|
+
- README.md
|
68
|
+
files:
|
69
|
+
- AUTHORS.md
|
70
|
+
- CHANGELOG.md
|
71
|
+
- LICENSE.txt
|
72
|
+
- README.md
|
73
|
+
- RELEASE.md
|
74
|
+
- annot8.gemspec
|
75
|
+
- bin/annotate
|
76
|
+
- lib/annotate.rb
|
77
|
+
- lib/annotate/active_record_patch.rb
|
78
|
+
- lib/annotate/annotate_models.rb
|
79
|
+
- lib/annotate/annotate_models/file_patterns.rb
|
80
|
+
- lib/annotate/annotate_routes.rb
|
81
|
+
- lib/annotate/annotate_routes/header_generator.rb
|
82
|
+
- lib/annotate/annotate_routes/helpers.rb
|
83
|
+
- lib/annotate/constants.rb
|
84
|
+
- lib/annotate/helpers.rb
|
85
|
+
- lib/annotate/parser.rb
|
86
|
+
- lib/annotate/tasks.rb
|
87
|
+
- lib/annotate/version.rb
|
88
|
+
- lib/generators/annotate/USAGE
|
89
|
+
- lib/generators/annotate/install_generator.rb
|
90
|
+
- lib/generators/annotate/templates/auto_annotate_models.rake
|
91
|
+
- lib/tasks/annotate_models.rake
|
92
|
+
- lib/tasks/annotate_models_migrate.rake
|
93
|
+
- lib/tasks/annotate_routes.rake
|
94
|
+
- potato.md
|
95
|
+
homepage: https://github.com/chemica/annotate_models
|
96
|
+
licenses:
|
97
|
+
- Ruby
|
98
|
+
metadata:
|
99
|
+
bug_tracker_uri: https://github.com/chemica/annotate_models/issues/
|
100
|
+
source_code_uri: https://github.com/chemica/annotate_models.git
|
101
|
+
rubygems_mfa_required: 'true'
|
102
|
+
rdoc_options: []
|
103
|
+
require_paths:
|
104
|
+
- lib
|
105
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
106
|
+
requirements:
|
107
|
+
- - ">="
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: 3.2.2
|
110
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
111
|
+
requirements:
|
112
|
+
- - ">="
|
113
|
+
- !ruby/object:Gem::Version
|
114
|
+
version: '0'
|
115
|
+
requirements: []
|
116
|
+
rubygems_version: 3.6.9
|
117
|
+
specification_version: 4
|
118
|
+
summary: Annotates Rails Models, routes, fixtures, and others based on the database
|
119
|
+
schema.
|
120
|
+
test_files: []
|