Created
June 11, 2019 17:20
-
-
Save ChrisDrit/ca2f59ee234a59bd03b80b7fcfcfe060 to your computer and use it in GitHub Desktop.
Ruby Rake Task Methods
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
# ----------- | |
# In reference to: | |
# http://www.albertoalmagro.com/ruby-methods-defined-in-rake-tasks/ | |
# ----------- | |
# Rakefile | |
# Load tasks | |
Dir.glob('*.rake').each do |path| | |
load path | |
end | |
# ----------- | |
# foo.rake | |
desc 'foo task' | |
task :foo do | |
def greet | |
puts 'Hello from foo.rake' | |
end | |
puts 'In foo task' | |
greet | |
end | |
#------------- | |
# bar.rake | |
desc 'bar task' | |
task :bar do | |
def greet | |
puts 'Hello from bar.rake' | |
end | |
puts 'In bar task' | |
greet | |
end | |
#----------- | |
# Output | |
# $ rake -T | |
# rake bar # bar task | |
# rake foo # foo task | |
# $ rake foo | |
# In foo task | |
# Hello from foo.rake | |
# $ rake bar | |
# In bar task | |
# Hello from bar.rake |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks for this tip! I'm editing the post to add it 👏