Skip to content

Commit

Permalink
Merge branch 'release/v2.7.3'
Browse files Browse the repository at this point in the history
  • Loading branch information
ctran committed Apr 21, 2018
2 parents 5f37a97 + db3eb14 commit 89bce57
Show file tree
Hide file tree
Showing 21 changed files with 1,177 additions and 227 deletions.
72 changes: 19 additions & 53 deletions .rubocop_todo.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# This configuration was generated by
# `rubocop --auto-gen-config`
# on 2016-12-17 10:16:05 +0100 using RuboCop version 0.46.0.
# on 2017-10-13 10:01:18 +0200 using RuboCop version 0.46.0.
# The point is for the user to remove these configuration records
# one by one as the offenses are removed from the code base.
# Note that changes in the inspected code, or installation of new
Expand Down Expand Up @@ -65,11 +65,6 @@ Lint/HandleExceptions:
Exclude:
- 'bin/annotate'

# Offense count: 8
Lint/IneffectiveAccessModifier:
Exclude:
- 'lib/annotate/annotate_routes.rb'

# Offense count: 1
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, SupportedStyles.
Expand All @@ -88,62 +83,51 @@ Lint/ShadowingOuterLocalVariable:
Exclude:
- 'Rakefile'

# Offense count: 6
# Offense count: 7
# Cop supports --auto-correct.
# Configuration parameters: IgnoreEmptyBlocks, AllowUnusedKeywordArguments.
Lint/UnusedBlockArgument:
Exclude:
- 'bin/annotate'

# Offense count: 1
# Configuration parameters: ContextCreatingMethods.
Lint/UselessAccessModifier:
Exclude:
- 'lib/annotate/annotate_routes.rb'

# Offense count: 17
# Offense count: 18
Metrics/AbcSize:
Max: 159
Max: 142

# Offense count: 3
# Configuration parameters: CountComments.
Metrics/BlockLength:
Max: 134
Max: 142

# Offense count: 2
Metrics/BlockNesting:
Max: 4

# Offense count: 8
# Offense count: 9
Metrics/CyclomaticComplexity:
Max: 42
Max: 36

# Offense count: 350
# Offense count: 380
# Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns.
# URISchemes: http, https
Metrics/LineLength:
Max: 543
Max: 276

# Offense count: 24
# Offense count: 26
# Configuration parameters: CountComments.
Metrics/MethodLength:
Max: 79

# Offense count: 1
# Configuration parameters: CountComments.
Metrics/ModuleLength:
Max: 116
Max: 75

# Offense count: 7
Metrics/PerceivedComplexity:
Max: 48
Max: 42

# Offense count: 1
Style/AccessorMethodName:
Exclude:
- 'lib/annotate.rb'

# Offense count: 3
# Offense count: 2
# Cop supports --auto-correct.
Style/AlignArray:
Exclude:
Expand Down Expand Up @@ -259,21 +243,14 @@ Style/ExtraSpacing:
- 'spec/integration/rails_4.2.0/Gemfile'
- 'spec/integration/rails_4.2.0/config.ru'

# Offense count: 9
# Offense count: 10
# Configuration parameters: EnforcedStyle, SupportedStyles.
# SupportedStyles: format, sprintf, percent
Style/FormatString:
Exclude:
- 'lib/annotate/annotate_models.rb'
- 'lib/annotate/annotate_routes.rb'

# Offense count: 181
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, SupportedStyles.
# SupportedStyles: when_needed, always
Style/FrozenStringLiteralComment:
Enabled: false

# Offense count: 7
# Configuration parameters: MinBodyLength.
Style/GuardClause:
Expand Down Expand Up @@ -356,16 +333,6 @@ Style/NumericLiterals:

# Offense count: 2
# Cop supports --auto-correct.
# Configuration parameters: AutoCorrect, EnforcedStyle, SupportedStyles.
# SupportedStyles: predicate, comparison
Style/NumericPredicate:
Exclude:
- 'spec/**/*'
- 'lib/annotate.rb'
- 'lib/annotate/annotate_models.rb'

# Offense count: 6
# Cop supports --auto-correct.
# Configuration parameters: PreferredDelimiters.
Style/PercentLiteralDelimiters:
Exclude:
Expand Down Expand Up @@ -458,16 +425,15 @@ Style/SpaceAroundKeyword:
- 'spec/integration/rails_4.2.0/Gemfile'
- 'spec/integration/standalone/Gemfile'

# Offense count: 6
# Offense count: 4
# Cop supports --auto-correct.
# Configuration parameters: AllowForAlignment.
Style/SpaceAroundOperators:
Exclude:
- 'lib/annotate/annotate_models.rb'
- 'lib/tasks/annotate_models.rake'
- 'lib/tasks/annotate_routes.rake'

# Offense count: 4
# Offense count: 1
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, SupportedStyles.
# SupportedStyles: space, no_space
Expand Down Expand Up @@ -517,14 +483,14 @@ Style/SpaceInsideStringInterpolation:
Exclude:
- 'lib/annotate/annotate_models.rb'

# Offense count: 223
# Offense count: 237
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, SupportedStyles, ConsistentQuotesInMultiline.
# SupportedStyles: single_quotes, double_quotes
Style/StringLiterals:
Enabled: false

# Offense count: 2
# Offense count: 1
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, SupportedStyles.
# SupportedStyles: single_quotes, double_quotes
Expand Down Expand Up @@ -581,7 +547,7 @@ Style/UnneededInterpolation:
Exclude:
- 'bin/annotate'

# Offense count: 8
# Offense count: 4
# Cop supports --auto-correct.
Style/UnneededPercentQ:
Exclude:
Expand Down
28 changes: 16 additions & 12 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,19 +1,23 @@
sudo: false
language: ruby
rvm:
- 1.9.3
- 2.0
- 2.1
- 2.2.5
- 2.3.0
- 2.4.0
- ruby-head
- 2.2.7
- 2.3.4
- 2.4.1
- ruby-head
matrix:
allow_failures:
- rvm: ruby-head
- rvm: 1.9.3
- rvm: ruby-head
before_install:
- gem update --system
- gem update bundler
- gem update --system
- gem update bundler
script:
- bundle exec rubocop && bundle exec rspec
- bundle exec rubocop && bundle exec rspec
deploy:
provider: rubygems
api_key:
secure: Y7DUitak26kcRAAkgph/7m6Y1wHeObD0BelSSJbmCfjkRd/qaVy7fz9VvHL9zxlRJtLGVHInyCnwcfzinibY6OFd3MoMYHKv8GFa2LxLJNEVSY46KQYFxfH5JTg1ejh6ldoJRRBoeOx9dcWS80pRNjYMKPGnpSz7yDBl1azibFs=
gem: annotate
on:
tags: true
repo: ctran/annotate_models
3 changes: 3 additions & 0 deletions CHANGELOG.rdoc
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
== 2.7.3
See https://github.com/ctran/annotate_models/releases/tag/v2.7.3

== 2.7.2
See https://github.com/ctran/annotate_models/releases/tag/v2.7.2

Expand Down
3 changes: 3 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
source 'https://rubygems.org'

ruby '>= 2.2.0'

gem 'activerecord', '>= 4.2.5', require: false
gem 'rake', require: false

group :development do
gem 'bump'
gem 'mg', require: false
gem 'travis', require: false
platforms :mri, :mingw do
gem 'yard', require: false
end
Expand Down
32 changes: 24 additions & 8 deletions README.rdoc
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ your...
- Object Daddy exemplars
- Machinist blueprints
- Fabrication fabricators
- Thoughtbot's factory_girl factories, i.e. the (spec|test)/factories/<model>_factory.rb files
- Thoughtbot's factory_bot factories, i.e. the (spec|test)/factories/<model>_factory.rb files
- routes.rb file (for Rails projects)

The schema comment looks like this:
Expand Down Expand Up @@ -55,11 +55,15 @@ Also, if you pass the -r option, it'll annotate routes.rb with the output of

Into Gemfile from rubygems.org:

gem 'annotate'
group :development do
gem 'annotate'
end

Into Gemfile from Github:

gem 'annotate', git: 'https://github.com/ctran/annotate_models.git'
group :development do
gem 'annotate', git: 'https://github.com/ctran/annotate_models.git'
end

Into environment gems from rubygems.org:

Expand Down Expand Up @@ -154,14 +158,15 @@ If you want to run <code>rake db:migrate</code> as a one-off without running ann
you can do so with a simple environment variable, instead of editing the
+.rake+ file:

skip_on_db_migrate=1 rake db:migrate
ANNOTATE_SKIP_ON_DB_MIGRATE=1 rake db:migrate


== Options

Usage: annotate [options] [model_file]*
-d, --delete Remove annotations from all model files or the routes.rb file
-p, --position [before|top|after|bottom] Place the annotations at the top (before) or the bottom (after) of the model/test/fixture/factory/routes file(s)
-p [before|top|after|bottom], Place the annotations at the top (before) or the bottom (after) of the model/test/fixture/factory/route/serializer file(s)
--position
--pc, --position-in-class [before|top|after|bottom]
Place the annotations at the top (before) or the bottom (after) of the model file
--pf, --position-in-factory [before|top|after|bottom]
Expand All @@ -179,15 +184,19 @@ you can do so with a simple environment variable, instead of editing the
--wo, --wrapper-open STR Annotation wrapper opening.
--wc, --wrapper-close STR Annotation wrapper closing
-r, --routes Annotate routes.rb with the output of 'rake routes'
-aa, --active-admin Annotate all activeadmin models
-a, --active-admin Annotate active_admin models
-v, --version Show the current version of this gem
-m, --show-migration Include the migration version number in the annotation
-i, --show-indexes List the table's database indexes in the annotation
-k, --show-foreign-keys List the table's foreign key constraints in the annotation
--ck, --complete-foreign-keys
Complete foreign key names in the annotation
-i, --show-indexes List the table's database indexes in the annotation
-s, --simple-indexes Concat the column's related indexes in the annotation
--model-dir dir Annotate model files stored in dir rather than app/models, separate multiple dirs with commas
--root-dir dir Annotate files stored within root dir projects, separate multiple dirs with commas
--ignore-model-subdirects Ignore subdirectories of the models directory
--sort Sort columns alphabetically, rather than in creation order
--classified-sort Sort columns alphabetically, but first goes id, then the rest columns, then the timestamp columns and then the association columns
-R, --require path Additional file to require before loading models, may be used multiple times
-e [tests,fixtures,factories,serializers],
--exclude Do not annotate fixtures, test files, factories, and/or serializers
Expand All @@ -197,6 +206,13 @@ you can do so with a simple environment variable, instead of editing the
--timestamp Include timestamp in (routes) annotation
--trace If unable to annotate a file, print the full stack trace, not just the exception message.
-I, --ignore-columns REGEX don't annotate columns that match a given REGEX (i.e., `annotate -I '^(id|updated_at|created_at)'`
--ignore-routes REGEX don't annotate routes that match a given REGEX (i.e., `annotate -I '(mobile|resque|pghero)'`
--hide-limit-column-types VALUES
don't show limit for given column types, separated by commas (i.e., `integer,boolean,text`)
--hide-default-column-types VALUES
don't show default for given column types, separated by commas (i.e., `json,jsonb,hstore`)
--ignore-unknown-models don't display warnings for bad model files
--with-comment include database comments in model annotations



Expand Down Expand Up @@ -242,7 +258,7 @@ extra carefully, and consider using one.

== Links

- Factory Girl: http://github.com/thoughtbot/factory_girl
- Factory Bot: http://github.com/thoughtbot/factory_bot
- Object Daddy: http://github.com/flogic/object_daddy
- Machinist: http://github.com/notahat/machinist
- Fabrication: http://github.com/paulelliott/fabrication
Expand Down
2 changes: 1 addition & 1 deletion Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ require 'mg'
begin
MG.new('annotate.gemspec')
rescue Exception
STDERR.puts("WARNING: Couldn't read gemspec. As such, a number of tasks may be unavailable to you until you run 'rake gem:gemspec' to correct the issue.")
$stderr.puts("WARNING: Couldn't read gemspec. As such, a number of tasks may be unavailable to you until you run 'rake gem:gemspec' to correct the issue.")
# Gemspec is probably in a broken state, so let's give ourselves a chance to
# build a new one...
end
Expand Down
2 changes: 1 addition & 1 deletion annotate.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Gem::Specification.new do |s|
s.name = 'annotate'
s.version = Annotate.version

s.required_ruby_version = '>= 1.9.3'
s.required_ruby_version = '>= 2.2.0'
s.required_rubygems_version = Gem::Requirement.new('>= 0') if s.respond_to? :required_rubygems_version=
s.authors = ['Alex Chaffee', 'Cuong Tran', 'Marcos Piccinini', 'Turadg Aleahmad', 'Jon Frisby']
s.description = 'Annotates Rails/ActiveRecord Models, routes, fixtures, and others based on the database schema.'
Expand Down
14 changes: 12 additions & 2 deletions bin/annotate
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ OptionParser.new do |opts|
ENV['routes'] = 'true'
end

opts.on('-aa', '--active-admin', 'Annotate active_admin models') do
opts.on('-a', '--active-admin', 'Annotate active_admin models') do
ENV['active_admin'] = 'true'
end

Expand All @@ -107,6 +107,12 @@ OptionParser.new do |opts|
ENV['show_foreign_keys'] = 'yes'
end

opts.on('--ck',
'--complete-foreign-keys', 'Complete foreign key names in the annotation') do
ENV['show_foreign_keys'] = 'yes'
ENV['show_complete_foreign_keys'] = 'yes'
end

opts.on('-i', '--show-indexes',
"List the table's database indexes in the annotation") do
ENV['show_indexes'] = 'yes'
Expand Down Expand Up @@ -191,12 +197,16 @@ OptionParser.new do |opts|
opts.on('--ignore-unknown-models', "don't display warnings for bad model files") do |values|
ENV['ignore_unknown_models'] = 'true'
end

opts.on('--with-comment', "include database comments in model annotations") do |values|
ENV['with_comment'] = 'true'
end
end.parse!

options = Annotate.setup_options(
is_rake: ENV['is_rake'] && !ENV['is_rake'].empty?
)
Annotate.eager_load(options)
Annotate.eager_load(options) if Annotate.include_models?

AnnotateModels.send(target_action, options) if Annotate.include_models?
AnnotateRoutes.send(target_action, options) if Annotate.include_routes?
Loading

0 comments on commit 89bce57

Please sign in to comment.