Skip to content

Commit ba13601

Browse files
committed
Merge remote-tracking branch 'upstream/pr/985' into community-maintained
2 parents 2407ee4 + 6720020 commit ba13601

File tree

4 files changed

+8
-6
lines changed

4 files changed

+8
-6
lines changed

README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ when using `SpatialAdapter`, `PostgisAdapter` or `PostGISAdapter`:
4949
# path :geometry line_string, 4326
5050
```
5151

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

5454

5555
## Upgrading to 3.X and annotate models not working?
@@ -217,7 +217,7 @@ you can do so with a simple environment variable, instead of editing the
217217
If --w option is used, the same text will be used as opening and closing
218218
--wo, --wrapper-open STR Annotation wrapper opening.
219219
--wc, --wrapper-close STR Annotation wrapper closing
220-
-r, --routes Annotate routes.rb with the output of 'rake routes'
220+
-r, --routes Annotate routes.rb with the output of 'rake/rails routes'
221221
--models Annotate ActiveRecord models
222222
-a, --active-admin Annotate active_admin models
223223
-v, --version Show the current version of this gem

lib/annotate/annotate_routes.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
#
55
#
66
#
7-
# Prepends the output of "rake routes" to the top of your routes.rb file.
7+
# Prepends the output of "rake/rails routes" to the top of your routes.rb file.
88
# Yes, it's simple but I'm thick and often need a reminder of what my routes
99
# mean.
1010
#

lib/annotate/annotate_routes/header_generator.rb

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
require_relative 'helpers'
1+
require 'active_record'
2+
require_relative './helpers'
23

34
module AnnotateRoutes
45
class HeaderGenerator
@@ -16,7 +17,8 @@ def generate(options = {})
1617
private
1718

1819
def routes_map(options)
19-
result = `rake routes`.chomp("\n").split("\n", -1)
20+
command = ActiveRecord.version.to_s.first.to_i > 5 ? `rails routes` : `rake routes`
21+
result = command.chomp("\n").split(/\n/, -1)
2022

2123
# In old versions of Rake, the first line of output was the cwd. Not so
2224
# much in newer ones. We ditch that line if it exists, and if not, we

lib/annotate/parser.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ def add_options_to_parser(option_parser) # rubocop:disable Metrics/MethodLength,
153153

154154
option_parser.on('-r',
155155
'--routes',
156-
"Annotate routes.rb with the output of 'rake routes'") do
156+
"Annotate routes.rb with the output of 'rake/rails routes'") do
157157
env['routes'] = 'true'
158158
end
159159

0 commit comments

Comments
 (0)