2012-03-30 29 views
1

我想一些耙任務添加到命名空間中的一對夫婦leves,但我不希望有縮進我的整個文件做將rake任務添加到名稱空間而不進行縮進?

namespace :one_descriptive_name do 
    namespace :sub_name do 
    # many tasks which all have to be 4 chars deep 
    end 

    namespace :another_sub_name do 
    # many more tasks. oh, my poor eyes 
    # and limited screen-width, woe is me!! 
    end 
end 

還有沒有其他的辦法把一個任務進入一個命名空間?

回答

3

所以我知道的兩個選項

選項1

多層次

namespace 'level1:level2:level3' do 
    task :my_task 
end 

選項2

定義您namespacenamespace在定義你的任務declar通貨膨脹

task 'level1:level2:my_task' 

然後還有其他幾個更瘋狂的方式,但這些似乎是最乾淨的方法

2

簡單:

namespace :one_descriptive_name do 
namespace :sub_name do 
# many tasks none of which have to be 4 chars deep 
end 

namespace :another_sub_name do 
# many more tasks. 
end 
end 
2

Ruby沒有以同樣的方式Python中使用顯著空白確實。如果你不想要,你不必縮進代碼。