Skip to content

Commit 7b9aafc

Browse files
committed
Add annotation gem
1 parent bb1315e commit 7b9aafc

File tree

3 files changed

+59
-0
lines changed

3 files changed

+59
-0
lines changed

Gemfile

+1
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ group :development do
3838
# Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
3939
gem 'spring'
4040
gem 'spring-watcher-listen', '~> 2.0.0'
41+
gem 'annotate'
4142
end
4243

4344

Gemfile.lock

+4
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,9 @@ GEM
4242
i18n (>= 0.7, < 2)
4343
minitest (~> 5.1)
4444
tzinfo (~> 1.1)
45+
annotate (2.7.4)
46+
activerecord (>= 3.2, < 6.0)
47+
rake (>= 10.4, < 13.0)
4548
arel (9.0.0)
4649
bootsnap (1.3.2)
4750
msgpack (~> 1.0)
@@ -133,6 +136,7 @@ PLATFORMS
133136
ruby
134137

135138
DEPENDENCIES
139+
annotate
136140
bootsnap (>= 1.1.0)
137141
byebug
138142
listen (>= 3.0.5, < 3.2)

lib/tasks/auto_annotate_models.rake

+54
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
# NOTE: only doing this in development as some production environments (Heroku)
2+
# NOTE: are sensitive to local FS writes, and besides -- it's just not proper
3+
# NOTE: to have a dev-mode tool do its thing in production.
4+
if Rails.env.development?
5+
require 'annotate'
6+
task :set_annotation_options do
7+
# You can override any of these by setting an environment variable of the
8+
# same name.
9+
Annotate.set_defaults(
10+
'routes' => 'false',
11+
'position_in_routes' => 'before',
12+
'position_in_class' => 'before',
13+
'position_in_test' => 'before',
14+
'position_in_fixture' => 'before',
15+
'position_in_factory' => 'before',
16+
'position_in_serializer' => 'before',
17+
'show_foreign_keys' => 'true',
18+
'show_complete_foreign_keys' => 'false',
19+
'show_indexes' => 'true',
20+
'simple_indexes' => 'false',
21+
'model_dir' => 'app/models',
22+
'root_dir' => '',
23+
'include_version' => 'false',
24+
'require' => '',
25+
'exclude_tests' => 'false',
26+
'exclude_fixtures' => 'false',
27+
'exclude_factories' => 'false',
28+
'exclude_serializers' => 'false',
29+
'exclude_scaffolds' => 'true',
30+
'exclude_controllers' => 'true',
31+
'exclude_helpers' => 'true',
32+
'exclude_sti_subclasses' => 'false',
33+
'ignore_model_sub_dir' => 'false',
34+
'ignore_columns' => nil,
35+
'ignore_routes' => nil,
36+
'ignore_unknown_models' => 'false',
37+
'hide_limit_column_types' => 'integer,boolean',
38+
'hide_default_column_types' => 'json,jsonb,hstore',
39+
'skip_on_db_migrate' => 'false',
40+
'format_bare' => 'true',
41+
'format_rdoc' => 'false',
42+
'format_markdown' => 'false',
43+
'sort' => 'false',
44+
'force' => 'false',
45+
'classified_sort' => 'true',
46+
'trace' => 'false',
47+
'wrapper_open' => nil,
48+
'wrapper_close' => nil,
49+
'with_comment' => true
50+
)
51+
end
52+
53+
Annotate.load_tasks
54+
end

0 commit comments

Comments
 (0)