Issue: SSHKit::Backend::Netssh binding change in run method breaks lookup in 'normal' block scope
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 35/100
Research direction
Start at SSHKit::Backend::Netssh#run and inspect how instance_exec changes the block binding. Reproduce the cap-task example with Nginx#upload_files and tmp_config_file, then determine the expected scope behavior and add coverage for service-object method lookup. Done means the encapsulated action can resolve tmp_config_file while the existing block behavior remains intact.
Written by the indexing model from the issue text.
Description
Hi,
in SSHKit::Backend::Netssh#run instance_exec is used to change the binding of the given block. With this binding change it is difficult to encapsulate an action in a service object for instance you have a cap-task:
desc 'Setup nginx configuration'
task :setup do
Nginx.new(self).setup
end
class Nginx < SimpleDelegator
...
def upload_files
on roles nginx_roles do |host|
set :host_server_name, host.properties.fetch(:host_server_name)
template 'assets.host.site', tmp_config_file
end
end
def tmp_config_file
'remote_file_name'
end
...
end
This does not work because the block is executed in the context of the SSHKit::Backend::Netssh object context and does not know the method tmp_config_file.
Why do I want to do such things? Testing! Rake and Cap tasks are difficult to test.
When I encapsulate the actions I can test the a little.
regards
dieter
- Dominant language
- Ruby
- Stars
- 1.2k
- Forks
- 257
- PR merge metrics
- No merged PRs in 30d
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from capistrano/sshkit
-
Difficulty 5/5 Over a week Newbie friendliness 35/100
capistrano/sshkit#563 · 6 reactions ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 45/100
capistrano/sshkit#562 ·
-
Difficulty 3/5 1-2 days Newbie friendliness 48/100
capistrano/sshkit#554 · 3 comments ·
-
Difficulty 3/5 1-2 days Newbie friendliness 35/100
capistrano/sshkit#543 · 2 comments ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 45/100
capistrano/sshkit#518 · 1 comment ·
All issues in capistrano/sshkit
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
-
bug
Difficulty 1/5 Under an hour Newbie friendliness 90/100
riscv/riscv-unified-db#2626 ·
-
Component: GLib
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
-
ds-drift
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
we-promise/sure#3693 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
simp/pupmod-simp-simp#395 ·