Hi Maxim,
Everything in the `on()` block is evaluated in the context of a SSHKit
handler, by default this is the Net::SSH handler. If you really need to do
what you are doing, you can create your own class with more methods, and
force Capistrano to use that runner for the backend.
Better would be to write your methods in a way that they return a
SSHKit::Command, so that you could do something like:
execute InitdHandler.new('handler', 'bin/handler', nil, start_env:
'PATH=/opt/ruby/shims:$PATH RUBY_ENV=production').install
Where the #install method returns the aforementioned SSHKit::Command.
If you go this way, then you'll be able to unit test that
InitdHandler#install returns the correct command, and it allows you to keep
your code isolated.
The Ruby autoloading code will not care if your modules are defined in our
namespaces or not, so it should "just work".
Lee Hambley
--
http://lee.hambley.name/
+49 (0) 170 298 5667
On 26 December 2013 12:55, Maxim Dobryakov <[email protected]>wrote:
> Hi their,
>
> I want to add several commands to Capistrano DSL for manage init.d files.
> For example:
>
> task :init_d do
> on roles(:app), in: :sequence, wait: 5 do
> *install_initd('handler', 'bin/handler', nil, start_env:
> 'PATH=/opt/ruby/shims:$PATH RUBY_ENV=production')*
> end
> end
>
> As you can see I want to add several methods with arguments and call them
> from tasks. I can't use tasks because they don't have ability to pass
> parameters.
>
> Could you please recommend a way how can I extend Capistrano DSL and add
> own method to it?
>
> Thanks
>
> --
> You received this message because you are subscribed to the Google Groups
> "Capistrano" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To view this discussion on the web, visit
> https://groups.google.com/d/msgid/capistrano/43d7d1e1-23b0-4fd3-8485-a16f32148faa%40googlegroups.com
> .
> For more options, visit https://groups.google.com/groups/opt_out.
>
--
You received this message because you are subscribed to the Google Groups
"Capistrano" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web, visit
https://groups.google.com/d/msgid/capistrano/CAN_%2BVLWkwL70rLrufeq3-R%2BDRUu-YQzg0rbzUHEs-EAkxzUPtg%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.