Skip to content

Commit

Permalink
decide when run rake or rails routes.
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanfox1985 committed May 12, 2023
1 parent 3a78787 commit 57b92fe
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 5 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,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 `rake/rails routes`.


## Upgrading to 3.X and annotate models not working?
Expand Down Expand Up @@ -217,7 +217,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 'rake/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 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 "rake/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
3 changes: 2 additions & 1 deletion lib/annotate/annotate_routes/header_generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ def generate(options = {})
private

def routes_map(options)
result = `rake routes`.chomp("\n").split(/\n/, -1)
command = Rails.version.first.to_i > 5 ? `rails routes` : `rake routes`
result = command.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 'rake/rails routes'") do
env['routes'] = 'true'
end

Expand Down

0 comments on commit 57b92fe

Please sign in to comment.