2011-09-15 3 views
0

Ruby on Rails와 Capistrano gem을 사용하고 있습니다. 나는 카프리 스트라노 요리법을 마시고 싶다. deploy.rb 파일에서Capistrano 조리법을 마시는 법?

내가 가진 :

# First task 
task :first_task do 
    ... 

    run "cd #{current_path}; #{try_sudo} chmod -R 666 /log/production.log" 
end 

# Second task 
task :second_task do 
    run "..." 

    # The following code is equal to that stated in the first task. 
    run "cd #{current_path}; #{try_sudo} chmod -R 666 /log/production.log" 
end 

그래서, 는 어떻게 위의 코드 때문에 중복되지 작업을하기 위해 건조 할 수 있습니까?

당신이 할 수 있어야한다, 그래서 그냥 도메인 특정 언어 (DSL)과 코드를 루비

답변

4

카피 스트라 노 코드 :

def chmod_log 
    run "cd #{current_path}; #{try_sudo} chmod -R 666 /log/production.log" 
end 

# First task 
task :first_task do 
    ... 

    chmod_log 
end 

# Second task 
task :second_task do 
    run "..." 

    # The following code is equal to that stated in the first task. 
    chmod_log 
end