Where should I put helper functions in capistrano 3

353 views
Skip to first unread message

Robert Kuzelj

unread,
Apr 16, 2014, 9:42:25 AM4/16/14
to capis...@googlegroups.com
./lib/capistrano or ./lib/capistrano/tasks or somewhere completely different?

Bruno Sutic

unread,
Apr 16, 2014, 10:15:03 AM4/16/14
to capis...@googlegroups.com
Hi,
from what I know /lib/capistrano/tasks/ folder is reserved for *.rake and *.cap files. That means capistrano tasks, not really helpers.

So I think you should be good by putting your helper methods in ./lib/capistrano/helper_methods.rb
Then in config/deploy.rb file:
```
require_relative '../lib/capistrano/helper_methods'
include Capistrano::HelperMethods

task :some_task do
  helper_method
end
```

Hope that helps!

nifr

unread,
May 7, 2014, 11:28:05 AM5/7/14
to capis...@googlegroups.com
Have a look at this commit:
https://github.com/capistrano/capistrano/commit/7e41233d76fec0aca6877b62b876b7e2c9b85ec0

*.cap files have been deprecated for full rake compatibility.

Haani Niyaz

unread,
May 16, 2014, 12:55:56 AM5/16/14
to capis...@googlegroups.com
Hi,

I am doing what Bruno mentioned as well, however I'm doing it the following way:

lib/capistrano/helpers.rb


In my Capfile I load it by default with:

Dir.glob('lib/capistrano/**/*.rb').each { |r| import r }


Reply all
Reply to author
Forward
0 new messages