namespace :baseline do
INDEX_DIR = index(:baseline) # context
task(:foo) ...
end
How do I get the :baseline
Symbol in this context?
Additional rake files (with the file extension “ .rake ”) may be placed in rakelib directory located at the top level of a project (i.e. the same directory that contains the main Rakefile ). Also, rails projects may include additional rake files in the lib/tasks directory. Through require 'rake/clean' Rake provides clean and clobber tasks:
As far as rake is concerned, all tasks are run from the directory in which the Rakefile resides. Not all tasks need to be included in a single Rakefile.
You can define a task with the same name as your namespace. It is not as pretty as having the default task defined inside the namespace itself I think. desc "runs bar & baz in foo" task foo: ["foo:bar", "foo:baz"] namespace :foo do desc "bar in foo" task :bar do puts "bar" end desc "baz in foo" task :baz do puts "baz" end end
The import command addresses this by specifying a file to be loaded after the main rakefile is loaded, but before any targets on the command line are invoked. In addition, if the file name matches an explicit task, that task is invoked before loading the file.
namespace :baseline do |namespace|
scope = namespace.instance_variable_get("@scope")
INDEX_DIR = index(scope)
task(:foo) ...
end
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With