Default Reiki and Namespaces

I read the documents and looked through quite a few examples, but I do not understand how the default and namespaces are. (using rake, version 10.0.3)

It seems at first, although I don’t remember how I see it explicitly, that there can be only one default task, no matter how many are defined. Obviously, the load order (PROJECT_NAME :: Application.load_tasks) determines the winner. When I struggled to create a default default, I found that sometimes I redefined the default default for the rails application, where:

rake 

runs tests by default.

First enter the command "rake -T":

 $ rake -T a_name rake a_name:a_task_1 # a_task_1 rake a_name:a_task_2 # a_task_2 rake a_name:b_name:b_task_1 # b_task_1 rake a_name:b_name:b_task_2 # b_task_2 rake a_name:default # This is hopefully a namespaced default 

When I start the namespace, which I hope is the "default", I get:

 $ rake a_name rake aborted! Don't know how to build task 'a_name' (See full trace by running task with --trace) 

I expected this to run b_task_1 in the b_name namespace, because I declared it as the default

However, if I explicitly use the word "default", I get the following:

 $ rake a_name:default a_task_1 

Anyway, I'm completely confused. Can anyone help clarify this for me ...

 namespace :a_name do desc "a_task_1" task :a_task_1 do puts "a_task_1" end desc "a_task_2" task :a_task_2 do puts "a_task_2" end namespace :b_name do desc "b_task_1" task :b_task_1 do puts "b_task_1" end desc "b_task_2" task :b_task_2 do puts "b_task_2" end end desc "This is hopefully a namespaced default" task :default => 'b_name:b_task_1' end 
+4
source share
1 answer

You can define a task with the same name as your namespace. This is not as good as if I set a default task defined inside the namespace itself.

 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 

And what do they list:

 rake foo # runs bar & baz in foo rake foo:bar # bar in foo rake foo:baz # baz in foo 
+10
source

All Articles