Skip to content

Use rails routes instead of rake routes, minimum rails is now 5.0 #843

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
Please see https://github.com/ctran/annotate_models/releases for changes between releases.

## 4.0.0
Changes
- Minimum supported rails version is now 5.0
- Fixed rails 6 warning on `rake routes` deprecation

## 3.1.1
Changes
- Bump required ruby version to >= 2.4 [#772](https://github.com/ctran/annotate_models/pull/772)
Expand Down
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ source 'https://rubygems.org'

ruby '>= 2.4.0'

gem 'activerecord', '>= 4.2.5', '< 6', require: false
gem 'activerecord', '>= 5.0', '< 7', require: false
gem 'rake', require: false

group :development do
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ when using `SpatialAdapter`, `PostgisAdapter` or `PostGISAdapter`:
# path :geometry line_string, 4326
```

Also, if you pass the `-r` option, it'll annotate `routes.rb` with the output of `rake routes`.
Also, if you pass the `-r` option, it'll annotate `routes.rb` with the output of `rails routes`.


## Upgrading to 3.X and annotate models not working?
Expand Down Expand Up @@ -219,7 +219,7 @@ you can do so with a simple environment variable, instead of editing the
If --w option is used, the same text will be used as opening and closing
--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'
-r, --routes Annotate routes.rb with the output of 'rails routes'
--models Annotate ActiveRecord models
-a, --active-admin Annotate active_admin models
-v, --version Show the current version of this gem
Expand Down
2 changes: 1 addition & 1 deletion annotate.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ Gem::Specification.new do |s|

s.specification_version = 4 if s.respond_to? :specification_version
s.add_runtime_dependency(%q<rake>, '>= 10.4', '< 14.0')
s.add_runtime_dependency(%q<activerecord>, ['>= 3.2', '< 8.0'])
s.add_runtime_dependency(%q<activerecord>, ['>= 5.0', '< 8.0'])

s.metadata = {
"bug_tracker_uri" => "https://github.com/ctran/annotate_models/issues/",
Expand Down
2 changes: 1 addition & 1 deletion lib/annotate/annotate_routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#
#
#
# Prepends the output of "rake routes" to the top of your routes.rb file.
# Prepends the output of "rails routes" to the top of your routes.rb file.
# Yes, it's simple but I'm thick and often need a reminder of what my routes
# mean.
#
Expand Down
2 changes: 1 addition & 1 deletion lib/annotate/annotate_routes/header_generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def generate(options = {})
private

def routes_map(options)
result = `rake routes`.chomp("\n").split(/\n/, -1)
result = `rails routes`.chomp("\n").split(/\n/, -1)

# In old versions of Rake, the first line of output was the cwd. Not so
# much in newer ones. We ditch that line if it exists, and if not, we
Expand Down
2 changes: 1 addition & 1 deletion lib/annotate/parser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ def add_options_to_parser(option_parser) # rubocop:disable Metrics/MethodLength

option_parser.on('-r',
'--routes',
"Annotate routes.rb with the output of 'rake routes'") do
"Annotate routes.rb with the output of 'rails routes'") do
env['routes'] = 'true'
end

Expand Down
2 changes: 1 addition & 1 deletion lib/annotate/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module Annotate
def self.version
'3.2.0'
'4.0.0'
end
end
10 changes: 5 additions & 5 deletions spec/lib/annotate/annotate_routes_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,11 @@
expect(File).to receive(:exist?).with(ROUTE_FILE).and_return(true).once
expect(File).to receive(:read).with(ROUTE_FILE).and_return(route_file_content).once

expect(AnnotateRoutes::HeaderGenerator).to receive(:`).with('rake routes').and_return(rake_routes_result).once
expect(AnnotateRoutes::HeaderGenerator).to receive(:`).with('rails routes').and_return(rake_routes_result).once
end

context 'When the result of `rake routes` is present' do
context 'When the result of `rake routes` does not contain Rake version' do
context 'When the result of `rails routes` is present' do
context 'When the result of `rails routes` does not contain Rake version' do
context 'When the file does not contain magic comment' do
let :rake_routes_result do
<<-EOS
Expand Down Expand Up @@ -236,7 +236,7 @@
end
end

context 'When the result of `rake routes` contains Rake version' do
context 'When the result of `rails routes` contains Rake version' do
context 'with older Rake versions' do
let :rake_routes_result do
<<~EOS.chomp
Expand Down Expand Up @@ -394,7 +394,7 @@
end
end

context 'When the result of `rake routes` is blank' do
context 'When the result of `rails routes` is blank' do
let :rake_routes_result do
''
end
Expand Down