-
Notifications
You must be signed in to change notification settings - Fork 613
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
Make rake easier to use as a library #211
Merged
Merged
Conversation
This file contains 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
Currently it is impossible to start rake from within a library. By setting the default options explicitly we won't have to call handle_options after replacing ARGV.
This allows users to pass in an explicit ARGV for rake instead of changing their application's ARGV. While the previous commit allows users to create a Rake application explicitly by calling parts of Rake::Application#init directly, some users will not want to dig through the source to set up a Rake application. Swapping ARGV is confusing and error-prone, so this allows them to specify a set of Rake options directly.
These are no longer necessary
This allows users to use Rake as a library more easily. This allows loading multiple rakefiles from separate sources into separate Rake applications without task name collisions.
This allows Rake.with_application to work without users having to know to set the default options manually.
hsbt
approved these changes
Jun 29, 2017
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems useful for me too.
Eric-Guo
reviewed
Oct 25, 2017
@@ -74,19 +76,19 @@ def initialize | |||
# If you wish to build a custom rake command, you should call | |||
# +init+ on your application. Then define any tasks. Finally, | |||
# call +top_level+ to run your top level tasks. | |||
def run | |||
def run(argv = ARGV) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems it will caused #233 problem
This was referenced Mar 22, 2018
This was referenced Mar 22, 2018
Hamms
added a commit
to code-dot-org/code-dot-org
that referenced
this pull request
Mar 22, 2023
Specifically to pick up ruby/rake#211, which is required for Rails 6.1 support; without it, we get `undefined method \`with_application' for Rake:Module (NoMethodError)` when trying to run any rails script. Note that we specifically implement this by updating the `scss_lint` gem to pick up the change "Relax gem dependency constraints to allow rake 12.x" - https://github.com/sds/scss-lint/blob/master/CHANGELOG.md#0510 - https://github.com/ruby/rake/releases/tag/v12.2.0
Hamms
added a commit
to code-dot-org/code-dot-org
that referenced
this pull request
Mar 22, 2023
Specifically to pick up ruby/rake#211, which is required for Rails 6.1 support; without it, we get `undefined method ``with_application' for Rake:Module (NoMethodError)` when trying to run any rails script. Specifically, I implemented this by running `bundle update rake scss_lint`, to also pick up the `scss_lint` change "Relax gem dependency constraints to allow rake 12.x" - https://github.com/sds/scss-lint/blob/master/CHANGELOG.md#0510 - https://github.com/ruby/rake/releases/tag/v12.2.0 Tested locally that this resolves for me the problems with running rake tasks on Rails 6.1 Relying on existing tests to verify that this does not otherwise result in any change to functionality.
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.
I want to be able to load a set of rake tasks from within another application. Doing this presently is difficult, and looks something like this:
Figuring out which options you need to set is hard (and not documented), figuring out you need to set
Rake.application
is not documented, and the process of getting your Rakefile loaded is not documented.This PR replaces the above with a much simpler option:
Figuring out which options is now hidden from the user.
There are a few other API niceties in here like being able to create a new Rake application using a separate set of command line arguments from
ARGV
(so you don't have to overwriteARGV
).Some tests that use
capture_io
got a little more confusing because the output IO was set to real-$stderr
beforecapture_io
changed$stderr
to a StringIO.