Discover rake tasks - #2130
Merged
Merged
Conversation
Rake is the obvious omission from the task providers - most Ruby projects keep their tasks there, and Rails apps put them in lib/tasks/*.rake as well. The tasks are read out of the task files rather than by running rake -T, which would load the whole application just to fill a completion prompt. That means only literally-named tasks can be offered - one whose name comes from a variable isn't knowable without running rake - but it keeps the provider as cheap as the others. Names are qualified with the namespace blocks they sit in, so what you get is what you'd type.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Rake was the obvious gap in the task providers - most Ruby projects keep their
tasks there, and Rails apps spread them across
lib/tasks/*.raketoo.The tasks are read out of the Rakefile and the
.rakefiles rather than byrunning
rake -T, which would load the whole application just to fill acompletion prompt. The tradeoff is that only literally-named tasks can be
offered:
task type, [:id]inside aneachloop isn't knowable withoutrunning rake. In exchange the provider stays as cheap as the others, and it
costs nothing at all in a project with no Rakefile.
Names are qualified with the
namespaceblocks they sit in, so you getrake:db:migraterather thanrake:migrate, and the command runs throughbundle execwhen there's aGemfile.Checked against real projects rather than just the fixtures - rubocop (17
tasks), rubocop-ast (14) and metaredux (2) all come out right, including
prof:run,changelog:mergeandreferences:verify. Two things that had tobe handled to get there:
task.files = [...]inside aRakeTask.newblock isa method call on the block argument and not a definition, and rubocop's
%w[new fix change].each { |type| task type, [:id] }is the dynamic caseabove. Both have specs.