From 96e5b91835e1207227aa2bea98f50c9f403ae882 Mon Sep 17 00:00:00 2001 From: Colin Darie Date: Thu, 24 May 2018 14:00:26 +0200 Subject: [PATCH] Setup models & routes annotations --- Gemfile | 4 ++- Gemfile.lock | 4 +++ config/routes.rb | 12 +++++++ lib/tasks/auto_annotate_models.rake | 54 +++++++++++++++++++++++++++++ 4 files changed, 73 insertions(+), 1 deletion(-) create mode 100644 lib/tasks/auto_annotate_models.rake diff --git a/Gemfile b/Gemfile index 28188de..c82704a 100644 --- a/Gemfile +++ b/Gemfile @@ -46,8 +46,10 @@ group :development do gem 'spring' gem 'spring-watcher-listen', '~> 2.0.0' - gem 'capistrano-rails' gem 'rubocop', '~> 0.56.0', require: false + gem 'annotate', require: false + + gem 'capistrano-rails' gem "capistrano", "~> 3.10", require: false gem "capistrano-rbenv", require: false gem 'capistrano3-puma', require: false diff --git a/Gemfile.lock b/Gemfile.lock index 23ce554..ce54755 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -46,6 +46,9 @@ GEM public_suffix (>= 2.0.2, < 4.0) airbrussh (1.3.0) sshkit (>= 1.6.1, != 1.7.0) + annotate (2.7.3) + activerecord (>= 3.2, < 6.0) + rake (>= 10.4, < 13.0) archive-zip (0.11.0) io-like (~> 0.3.0) arel (9.0.0) @@ -236,6 +239,7 @@ PLATFORMS ruby DEPENDENCIES + annotate bcrypt (~> 3.1.7) bootsnap (>= 1.1.0) byebug diff --git a/config/routes.rb b/config/routes.rb index e4ef981..1203ed0 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,3 +1,15 @@ +# == Route Map +# +# Prefix Verb URI Pattern Controller#Action +# root GET / pages#home +# rails_service_blob GET /rails/active_storage/blobs/:signed_id/*filename(.:format) active_storage/blobs#show +# rails_blob_representation GET /rails/active_storage/representations/:signed_blob_id/:variation_key/*filename(.:format) active_storage/representations#show +# rails_disk_service GET /rails/active_storage/disk/:encoded_key/*filename(.:format) active_storage/disk#show +# update_rails_disk_service PUT /rails/active_storage/disk/:encoded_token(.:format) active_storage/disk#update +# rails_direct_uploads POST /rails/active_storage/direct_uploads(.:format) active_storage/direct_uploads#create + +# In order to update the route map above, +# run `bundle exec annotate -r` after modifying this file Rails.application.routes.draw do # For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html root to: "pages#home" diff --git a/lib/tasks/auto_annotate_models.rake b/lib/tasks/auto_annotate_models.rake new file mode 100644 index 0000000..b221470 --- /dev/null +++ b/lib/tasks/auto_annotate_models.rake @@ -0,0 +1,54 @@ +# NOTE: only doing this in development as some production environments (Heroku) +# NOTE: are sensitive to local FS writes, and besides -- it's just not proper +# NOTE: to have a dev-mode tool do its thing in production. +if Rails.env.development? + require 'annotate' + task :set_annotation_options do + # You can override any of these by setting an environment variable of the + # same name. + Annotate.set_defaults( + 'routes' => 'before', + 'position_in_routes' => 'before', + 'position_in_class' => 'before', + 'position_in_test' => 'before', + 'position_in_fixture' => 'before', + 'position_in_factory' => 'before', + 'position_in_serializer' => 'before', + 'show_foreign_keys' => 'true', + 'show_complete_foreign_keys' => 'false', + 'show_indexes' => 'true', + 'simple_indexes' => 'false', + 'model_dir' => 'app/models', + 'root_dir' => '', + 'include_version' => 'false', + 'require' => '', + 'exclude_tests' => 'false', + 'exclude_fixtures' => 'false', + 'exclude_factories' => 'false', + 'exclude_serializers' => 'false', + 'exclude_scaffolds' => 'true', + 'exclude_controllers' => 'true', + 'exclude_helpers' => 'true', + 'exclude_sti_subclasses' => 'false', + 'ignore_model_sub_dir' => 'false', + 'ignore_columns' => nil, + 'ignore_routes' => nil, + 'ignore_unknown_models' => 'false', + 'hide_limit_column_types' => 'integer,boolean', + 'hide_default_column_types' => 'json,jsonb,hstore', + 'skip_on_db_migrate' => 'false', + 'format_bare' => 'true', + 'format_rdoc' => 'false', + 'format_markdown' => 'false', + 'sort' => 'false', + 'force' => 'false', + 'classified_sort' => 'true', + 'trace' => 'false', + 'wrapper_open' => nil, + 'wrapper_close' => nil, + 'with_comment' => true + ) + end + + Annotate.load_tasks +end