Skip to content
This repository has been archived by the owner on Dec 24, 2020. It is now read-only.

Commit

Permalink
Merge pull request #23 from connorshea/add-annotate
Browse files Browse the repository at this point in the history
Add annotate gem and annotate all models
  • Loading branch information
connorshea committed Apr 28, 2018
2 parents 31ff9ad + d58ae18 commit c127292
Show file tree
Hide file tree
Showing 8 changed files with 162 additions and 17 deletions.
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ group :development do
# Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
gem 'spring'
gem 'spring-watcher-listen', '~> 2.0.0'
gem 'annotate', '~> 2.7'
end

group :test do
Expand Down
4 changes: 4 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ GEM
tzinfo (~> 1.1)
addressable (2.5.2)
public_suffix (>= 2.0.2, < 4.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)
Expand Down Expand Up @@ -213,6 +216,7 @@ PLATFORMS
ruby

DEPENDENCIES
annotate (~> 2.7)
bootsnap (>= 1.1.0)
bootstrap (~> 4.1.0)
byebug
Expand Down
12 changes: 12 additions & 0 deletions app/models/browser.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
# == Schema Information
#
# Table name: browsers
#
# id :bigint(8) not null, primary key
# name :string
# releases :jsonb
# created_at :datetime not null
# updated_at :datetime not null
# browser_id :string
#

class Browser < ApplicationRecord
store_accessor :releases, :release_date, :release_notes, :status

Expand Down
31 changes: 31 additions & 0 deletions app/models/feature.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,34 @@
# == Schema Information
#
# Table name: features
#
# id :bigint(8) not null, primary key
# chrome :jsonb
# chrome_android :jsonb
# deprecated :boolean
# description :string
# edge :jsonb
# edge_mobile :jsonb
# experimental :boolean
# firefox :jsonb
# firefox_android :jsonb
# ie :jsonb
# mdn_url :string
# name :string
# nodejs :jsonb
# opera :jsonb
# qq_android :jsonb
# safari :jsonb
# safari_ios :jsonb
# samsunginternet_android :jsonb
# standard_track :boolean
# uc_android :jsonb
# uc_chinese_android :jsonb
# webview_android :jsonb
# created_at :datetime not null
# updated_at :datetime not null
#

class Feature < ApplicationRecord
include PgSearch

Expand Down
34 changes: 17 additions & 17 deletions db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.

ActiveRecord::Schema.define(version: 2018_04_23_232646) do
ActiveRecord::Schema.define(version: 2018_04_26_202826) do

# These are extensions that must be enabled in order to support this database
enable_extension "pg_trgm"
Expand All @@ -33,22 +33,22 @@
t.boolean "standard_track"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.jsonb "chrome", default: "{}"
t.jsonb "chrome_android", default: "{}"
t.jsonb "edge", default: "{}"
t.jsonb "edge_mobile", default: "{}"
t.jsonb "firefox", default: "{}"
t.jsonb "firefox_android", default: "{}"
t.jsonb "ie", default: "{}"
t.jsonb "nodejs", default: "{}"
t.jsonb "opera", default: "{}"
t.jsonb "qq_android", default: "{}"
t.jsonb "safari", default: "{}"
t.jsonb "safari_ios", default: "{}"
t.jsonb "samsunginternet_android", default: "{}"
t.jsonb "uc_android", default: "{}"
t.jsonb "uc_chinese_android", default: "{}"
t.jsonb "webview_android", default: "{}"
t.jsonb "chrome"
t.jsonb "chrome_android"
t.jsonb "edge"
t.jsonb "edge_mobile"
t.jsonb "firefox"
t.jsonb "firefox_android"
t.jsonb "ie"
t.jsonb "nodejs"
t.jsonb "opera"
t.jsonb "qq_android"
t.jsonb "safari"
t.jsonb "safari_ios"
t.jsonb "samsunginternet_android"
t.jsonb "uc_android"
t.jsonb "uc_chinese_android"
t.jsonb "webview_android"
end

end
54 changes: 54 additions & 0 deletions lib/tasks/auto_annotate_models.rake
Original file line number Diff line number Diff line change
@@ -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' => 'false',
'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' => 'true',
'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
12 changes: 12 additions & 0 deletions test/models/browser_test.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
# == Schema Information
#
# Table name: browsers
#
# id :bigint(8) not null, primary key
# name :string
# releases :jsonb
# created_at :datetime not null
# updated_at :datetime not null
# browser_id :string
#

require 'test_helper'

class BrowserTest < ActiveSupport::TestCase
Expand Down
31 changes: 31 additions & 0 deletions test/models/feature_test.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,34 @@
# == Schema Information
#
# Table name: features
#
# id :bigint(8) not null, primary key
# chrome :jsonb
# chrome_android :jsonb
# deprecated :boolean
# description :string
# edge :jsonb
# edge_mobile :jsonb
# experimental :boolean
# firefox :jsonb
# firefox_android :jsonb
# ie :jsonb
# mdn_url :string
# name :string
# nodejs :jsonb
# opera :jsonb
# qq_android :jsonb
# safari :jsonb
# safari_ios :jsonb
# samsunginternet_android :jsonb
# standard_track :boolean
# uc_android :jsonb
# uc_chinese_android :jsonb
# webview_android :jsonb
# created_at :datetime not null
# updated_at :datetime not null
#

require 'test_helper'

class FeatureTest < ActiveSupport::TestCase
Expand Down

0 comments on commit c127292

Please sign in to comment.