Last active
December 14, 2015 01:49
-
-
Save jimweirich/5009198 to your computer and use it in GitHub Desktop.
How Rake runs its top level.
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
| # Sample custom rake-like command supporting three options. | |
| # | |
| # mycmd start | |
| # mycmd stop | |
| # mycmd restart | |
| require 'rake' | |
| Rake.application.init('mycmd') | |
| task :start do ... end | |
| task :stop do ... end | |
| task :restart do ... end | |
| Rake.application.top_level |
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
| # Snippet of code from Rake/application.rb ... | |
| # Run the Rake application. The run method performs the following | |
| # three steps: | |
| # | |
| # * Initialize the command line options (+init+). | |
| # * Define the tasks (+load_rakefile+). | |
| # * Run the top level tasks (+top_level+). | |
| # | |
| # 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 | |
| standard_exception_handling do | |
| init | |
| load_rakefile | |
| top_level | |
| end | |
| end | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment