From ce5b729fef1cd8e6d25ce746cbc58b10ffa5f4a4 Mon Sep 17 00:00:00 2001 From: sto Date: Sat, 22 Mar 2025 08:39:40 +0100 Subject: [PATCH] Add annotate_rb gem and annotate all models --- .annotaterb.yml | 58 ++++++++++++++++++++++++++++++++++ Gemfile | 2 ++ Gemfile.lock | 2 ++ app/models/completion.rb | 24 ++++++++++++++ app/models/contest.rb | 20 ++++++++++++ app/models/contestant.rb | 19 +++++++++++ app/models/puzzle.rb | 19 +++++++++++ app/models/session.rb | 19 +++++++++++ app/models/user.rb | 16 ++++++++++ lib/tasks/annotate_rb.rake | 8 +++++ test/fixtures/completions.yml | 24 ++++++++++++++ test/fixtures/contestants.yml | 19 +++++++++++ test/fixtures/contests.yml | 20 ++++++++++++ test/fixtures/puzzles.yml | 19 +++++++++++ test/fixtures/users.yml | 16 ++++++++++ test/models/completion_test.rb | 24 ++++++++++++++ test/models/contest_test.rb | 20 ++++++++++++ test/models/contestant_test.rb | 19 +++++++++++ test/models/puzzle_test.rb | 19 +++++++++++ test/models/user_test.rb | 16 ++++++++++ 20 files changed, 383 insertions(+) create mode 100644 .annotaterb.yml create mode 100644 lib/tasks/annotate_rb.rake diff --git a/.annotaterb.yml b/.annotaterb.yml new file mode 100644 index 0000000..2811be7 --- /dev/null +++ b/.annotaterb.yml @@ -0,0 +1,58 @@ +--- +:position: before +:position_in_additional_file_patterns: before +:position_in_class: before +:position_in_factory: before +:position_in_fixture: before +:position_in_routes: before +:position_in_serializer: before +:position_in_test: before +:classified_sort: true +:exclude_controllers: true +:exclude_factories: false +:exclude_fixtures: false +:exclude_helpers: true +:exclude_scaffolds: true +:exclude_serializers: false +:exclude_sti_subclasses: false +:exclude_tests: false +:force: false +:format_markdown: false +:format_rdoc: false +:format_yard: false +:frozen: false +:ignore_model_sub_dir: false +:ignore_unknown_models: false +:include_version: false +:show_check_constraints: false +:show_complete_foreign_keys: false +:show_foreign_keys: true +:show_indexes: true +:simple_indexes: false +:sort: false +:timestamp: false +:trace: false +:with_comment: true +:with_column_comments: true +:with_table_comments: true +:active_admin: false +:command: +:debug: false +:hide_default_column_types: '' +:hide_limit_column_types: '' +:ignore_columns: +:ignore_routes: +:models: true +:routes: false +:skip_on_db_migrate: false +:target_action: :do_annotations +:wrapper: +:wrapper_close: +:wrapper_open: +:classes_default_to_s: [] +:additional_file_patterns: [] +:model_dir: +- app/models +:require: [] +:root_dir: +- '' diff --git a/Gemfile b/Gemfile index 1aeace1..fbee302 100644 --- a/Gemfile +++ b/Gemfile @@ -58,6 +58,8 @@ end group :development do # Use console on exceptions pages [https://github.com/rails/web-console] gem "web-console" + + gem "annotaterb" end group :test do diff --git a/Gemfile.lock b/Gemfile.lock index ed8a5fa..52da423 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -74,6 +74,7 @@ GEM uri (>= 0.13.1) addressable (2.8.7) public_suffix (>= 2.0.2, < 7.0) + annotaterb (4.14.0) ast (2.4.2) autoprefixer-rails (10.4.19.0) execjs (~> 2) @@ -392,6 +393,7 @@ PLATFORMS x86_64-linux-musl DEPENDENCIES + annotaterb bcrypt (~> 3.1.7) bootsnap bootstrap (~> 5.3.3) diff --git a/app/models/completion.rb b/app/models/completion.rb index cba509d..251c5c8 100644 --- a/app/models/completion.rb +++ b/app/models/completion.rb @@ -1,3 +1,27 @@ +# == Schema Information +# +# Table name: completions +# +# id :integer not null, primary key +# time_seconds :integer +# created_at :datetime not null +# updated_at :datetime not null +# contest_id :integer not null +# contestant_id :integer not null +# puzzle_id :integer not null +# +# Indexes +# +# index_completions_on_contest_id (contest_id) +# index_completions_on_contestant_id (contestant_id) +# index_completions_on_puzzle_id (puzzle_id) +# +# Foreign Keys +# +# contest_id (contest_id => contests.id) +# contestant_id (contestant_id => contestants.id) +# puzzle_id (puzzle_id => puzzles.id) +# class Completion < ApplicationRecord belongs_to :contest belongs_to :contestant diff --git a/app/models/contest.rb b/app/models/contest.rb index a09d78d..044217d 100644 --- a/app/models/contest.rb +++ b/app/models/contest.rb @@ -1,3 +1,23 @@ +# == Schema Information +# +# Table name: contests +# +# id :integer not null, primary key +# allow_registration :boolean default(FALSE) +# name :string +# team :boolean default(FALSE) +# created_at :datetime not null +# updated_at :datetime not null +# user_id :integer not null +# +# Indexes +# +# index_contests_on_user_id (user_id) +# +# Foreign Keys +# +# user_id (user_id => users.id) +# class Contest < ApplicationRecord belongs_to :user diff --git a/app/models/contestant.rb b/app/models/contestant.rb index 7519a5a..7540ccd 100644 --- a/app/models/contestant.rb +++ b/app/models/contestant.rb @@ -1,3 +1,22 @@ +# == Schema Information +# +# Table name: contestants +# +# id :integer not null, primary key +# email :string +# name :string +# created_at :datetime not null +# updated_at :datetime not null +# contest_id :integer not null +# +# Indexes +# +# index_contestants_on_contest_id (contest_id) +# +# Foreign Keys +# +# contest_id (contest_id => contests.id) +# class Contestant < ApplicationRecord belongs_to :contest diff --git a/app/models/puzzle.rb b/app/models/puzzle.rb index afd7854..5246fe7 100644 --- a/app/models/puzzle.rb +++ b/app/models/puzzle.rb @@ -1,3 +1,22 @@ +# == Schema Information +# +# Table name: puzzles +# +# id :integer not null, primary key +# brand :string +# name :string +# created_at :datetime not null +# updated_at :datetime not null +# contest_id :integer not null +# +# Indexes +# +# index_puzzles_on_contest_id (contest_id) +# +# Foreign Keys +# +# contest_id (contest_id => contests.id) +# class Puzzle < ApplicationRecord belongs_to :contest diff --git a/app/models/session.rb b/app/models/session.rb index cf376fb..f960f47 100644 --- a/app/models/session.rb +++ b/app/models/session.rb @@ -1,3 +1,22 @@ +# == Schema Information +# +# Table name: sessions +# +# id :integer not null, primary key +# ip_address :string +# user_agent :string +# created_at :datetime not null +# updated_at :datetime not null +# user_id :integer not null +# +# Indexes +# +# index_sessions_on_user_id (user_id) +# +# Foreign Keys +# +# user_id (user_id => users.id) +# class Session < ApplicationRecord belongs_to :user end diff --git a/app/models/user.rb b/app/models/user.rb index d9c98c8..0148425 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -1,3 +1,19 @@ +# == Schema Information +# +# Table name: users +# +# id :integer not null, primary key +# admin :boolean default(FALSE), not null +# email_address :string not null +# password_digest :string not null +# username :string +# created_at :datetime not null +# updated_at :datetime not null +# +# Indexes +# +# index_users_on_email_address (email_address) UNIQUE +# class User < ApplicationRecord has_many :contests, dependent: :destroy has_many :sessions, dependent: :destroy diff --git a/lib/tasks/annotate_rb.rake b/lib/tasks/annotate_rb.rake new file mode 100644 index 0000000..1ad0ec3 --- /dev/null +++ b/lib/tasks/annotate_rb.rake @@ -0,0 +1,8 @@ +# This rake task was added by annotate_rb gem. + +# Can set `ANNOTATERB_SKIP_ON_DB_TASKS` to be anything to skip this +if Rails.env.development? && ENV["ANNOTATERB_SKIP_ON_DB_TASKS"].nil? + require "annotate_rb" + + AnnotateRb::Core.load_rake_tasks +end diff --git a/test/fixtures/completions.yml b/test/fixtures/completions.yml index 037ce8b..fdd6c8d 100644 --- a/test/fixtures/completions.yml +++ b/test/fixtures/completions.yml @@ -1,5 +1,29 @@ # Read about fixtures at https://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html +# == Schema Information +# +# Table name: completions +# +# id :integer not null, primary key +# time_seconds :integer +# created_at :datetime not null +# updated_at :datetime not null +# contest_id :integer not null +# contestant_id :integer not null +# puzzle_id :integer not null +# +# Indexes +# +# index_completions_on_contest_id (contest_id) +# index_completions_on_contestant_id (contestant_id) +# index_completions_on_puzzle_id (puzzle_id) +# +# Foreign Keys +# +# contest_id (contest_id => contests.id) +# contestant_id (contestant_id => contestants.id) +# puzzle_id (puzzle_id => puzzles.id) +# one: time_seconds: 1 contestant: one diff --git a/test/fixtures/contestants.yml b/test/fixtures/contestants.yml index ebb0c2a..fc869a4 100644 --- a/test/fixtures/contestants.yml +++ b/test/fixtures/contestants.yml @@ -1,5 +1,24 @@ # Read about fixtures at https://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html +# == Schema Information +# +# Table name: contestants +# +# id :integer not null, primary key +# email :string +# name :string +# created_at :datetime not null +# updated_at :datetime not null +# contest_id :integer not null +# +# Indexes +# +# index_contestants_on_contest_id (contest_id) +# +# Foreign Keys +# +# contest_id (contest_id => contests.id) +# one: name: MyString email: MyString diff --git a/test/fixtures/contests.yml b/test/fixtures/contests.yml index 661975c..d1367ad 100644 --- a/test/fixtures/contests.yml +++ b/test/fixtures/contests.yml @@ -1,5 +1,25 @@ # Read about fixtures at https://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html +# == Schema Information +# +# Table name: contests +# +# id :integer not null, primary key +# allow_registration :boolean default(FALSE) +# name :string +# team :boolean default(FALSE) +# created_at :datetime not null +# updated_at :datetime not null +# user_id :integer not null +# +# Indexes +# +# index_contests_on_user_id (user_id) +# +# Foreign Keys +# +# user_id (user_id => users.id) +# one: name: MyString user: one diff --git a/test/fixtures/puzzles.yml b/test/fixtures/puzzles.yml index 7d41224..6726a83 100644 --- a/test/fixtures/puzzles.yml +++ b/test/fixtures/puzzles.yml @@ -1,5 +1,24 @@ # Read about fixtures at https://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html +# == Schema Information +# +# Table name: puzzles +# +# id :integer not null, primary key +# brand :string +# name :string +# created_at :datetime not null +# updated_at :datetime not null +# contest_id :integer not null +# +# Indexes +# +# index_puzzles_on_contest_id (contest_id) +# +# Foreign Keys +# +# contest_id (contest_id => contests.id) +# one: name: MyString diff --git a/test/fixtures/users.yml b/test/fixtures/users.yml index 0951563..da7e35e 100644 --- a/test/fixtures/users.yml +++ b/test/fixtures/users.yml @@ -1,5 +1,21 @@ <% password_digest = BCrypt::Password.create("password") %> +# == Schema Information +# +# Table name: users +# +# id :integer not null, primary key +# admin :boolean default(FALSE), not null +# email_address :string not null +# password_digest :string not null +# username :string +# created_at :datetime not null +# updated_at :datetime not null +# +# Indexes +# +# index_users_on_email_address (email_address) UNIQUE +# one: email_address: one@example.com password_digest: <%= password_digest %> diff --git a/test/models/completion_test.rb b/test/models/completion_test.rb index 205cb95..55ac270 100644 --- a/test/models/completion_test.rb +++ b/test/models/completion_test.rb @@ -1,3 +1,27 @@ +# == Schema Information +# +# Table name: completions +# +# id :integer not null, primary key +# time_seconds :integer +# created_at :datetime not null +# updated_at :datetime not null +# contest_id :integer not null +# contestant_id :integer not null +# puzzle_id :integer not null +# +# Indexes +# +# index_completions_on_contest_id (contest_id) +# index_completions_on_contestant_id (contestant_id) +# index_completions_on_puzzle_id (puzzle_id) +# +# Foreign Keys +# +# contest_id (contest_id => contests.id) +# contestant_id (contestant_id => contestants.id) +# puzzle_id (puzzle_id => puzzles.id) +# require "test_helper" class CompletionTest < ActiveSupport::TestCase diff --git a/test/models/contest_test.rb b/test/models/contest_test.rb index ef72336..21a2705 100644 --- a/test/models/contest_test.rb +++ b/test/models/contest_test.rb @@ -1,3 +1,23 @@ +# == Schema Information +# +# Table name: contests +# +# id :integer not null, primary key +# allow_registration :boolean default(FALSE) +# name :string +# team :boolean default(FALSE) +# created_at :datetime not null +# updated_at :datetime not null +# user_id :integer not null +# +# Indexes +# +# index_contests_on_user_id (user_id) +# +# Foreign Keys +# +# user_id (user_id => users.id) +# require "test_helper" class ContestTest < ActiveSupport::TestCase diff --git a/test/models/contestant_test.rb b/test/models/contestant_test.rb index dc92d79..a4b3df4 100644 --- a/test/models/contestant_test.rb +++ b/test/models/contestant_test.rb @@ -1,3 +1,22 @@ +# == Schema Information +# +# Table name: contestants +# +# id :integer not null, primary key +# email :string +# name :string +# created_at :datetime not null +# updated_at :datetime not null +# contest_id :integer not null +# +# Indexes +# +# index_contestants_on_contest_id (contest_id) +# +# Foreign Keys +# +# contest_id (contest_id => contests.id) +# require "test_helper" class ContestantTest < ActiveSupport::TestCase diff --git a/test/models/puzzle_test.rb b/test/models/puzzle_test.rb index 6736bf6..d2666a8 100644 --- a/test/models/puzzle_test.rb +++ b/test/models/puzzle_test.rb @@ -1,3 +1,22 @@ +# == Schema Information +# +# Table name: puzzles +# +# id :integer not null, primary key +# brand :string +# name :string +# created_at :datetime not null +# updated_at :datetime not null +# contest_id :integer not null +# +# Indexes +# +# index_puzzles_on_contest_id (contest_id) +# +# Foreign Keys +# +# contest_id (contest_id => contests.id) +# require "test_helper" class PuzzleTest < ActiveSupport::TestCase diff --git a/test/models/user_test.rb b/test/models/user_test.rb index 5c07f49..bef68e8 100644 --- a/test/models/user_test.rb +++ b/test/models/user_test.rb @@ -1,3 +1,19 @@ +# == Schema Information +# +# Table name: users +# +# id :integer not null, primary key +# admin :boolean default(FALSE), not null +# email_address :string not null +# password_digest :string not null +# username :string +# created_at :datetime not null +# updated_at :datetime not null +# +# Indexes +# +# index_users_on_email_address (email_address) UNIQUE +# require "test_helper" class UserTest < ActiveSupport::TestCase