Module: SSHKit::Custom::Config::Store
- Defined in:
- lib/sshkit/custom/config/store.rb
Class Method Summary collapse
-
.active_backend ⇒ Object
Returns the active backend in the current thread.
-
.add_env(env) ⇒ Object
Set the environment for the current backend.
-
.add_pwd(directory) ⇒ Object
Set the working directory for the current backend.
-
.add_user_group(user, group) ⇒ Object
Set the user and group for the current backend.
-
.backends ⇒ Object
Get the actual backends.
-
.backends=(hosts) ⇒ Object
Sets the actual backends.
-
.create_runner(opts) ⇒ Object
Creates a new runner.
-
.default_runner_opts(opts) ⇒ Object
Sets the default runner opts for instance change the default runner.
-
.pop_env ⇒ Object
Resets the environment variables to the previous one.
-
.pop_pwd ⇒ Object
Set the working directory to the previous working directory for the current backend.
-
.pop_user_group ⇒ Object
Resets user and group to the previous one.
-
.runner ⇒ Object
The actual runner object.
Class Method Details
.active_backend ⇒ Object
Returns the active backend in the current thread
104 105 106 |
# File 'lib/sshkit/custom/config/store.rb', line 104 def active_backend SSHKit::Custom::Runner::Abstract.active_backend end |
.add_env(env) ⇒ Object
Set the environment for the current backend.
69 70 71 72 73 74 |
# File 'lib/sshkit/custom/config/store.rb', line 69 def add_env(env) old_env = active_backend.env.clone _envs << old_env env = old_env.merge(env) active_backend.env = env end |
.add_pwd(directory) ⇒ Object
Set the working directory for the current backend.
51 52 53 54 |
# File 'lib/sshkit/custom/config/store.rb', line 51 def add_pwd(directory) active_backend.pwd ||= [] active_backend.pwd << directory end |
.add_user_group(user, group) ⇒ Object
Set the user and group for the current backend.
90 91 92 93 94 |
# File 'lib/sshkit/custom/config/store.rb', line 90 def add_user_group(user, group) _user_groups << { user: active_backend.user, group: active_backend.group } active_backend.user = user active_backend.group = group end |
.backends ⇒ Object
Get the actual backends
45 46 47 |
# File 'lib/sshkit/custom/config/store.rb', line 45 def backends @backends ||= [] end |
.backends=(hosts) ⇒ Object
Sets the actual backends
40 41 42 |
# File 'lib/sshkit/custom/config/store.rb', line 40 def backends=(hosts) @backends = hosts.map { |host| SSHKit.config.backend.new(host) } end |
.create_runner(opts) ⇒ Object
Creates a new runner
30 31 32 |
# File 'lib/sshkit/custom/config/store.rb', line 30 def create_runner(opts) @runner = Runner::Abstract.create_runner((global_config_scope[:_default_runner_opts] || {}).merge(opts)) end |
.default_runner_opts(opts) ⇒ Object
Sets the default runner opts for instance change the default runner
109 110 111 |
# File 'lib/sshkit/custom/config/store.rb', line 109 def default_runner_opts(opts) global_config_scope[:_default_runner_opts] = opts end |
.pop_env ⇒ Object
Resets the environment variables to the previous one.
77 78 79 80 |
# File 'lib/sshkit/custom/config/store.rb', line 77 def pop_env old_env = _envs.pop || {} active_backend.env = old_env end |
.pop_pwd ⇒ Object
Set the working directory to the previous working directory for the current backend.
57 58 59 60 |
# File 'lib/sshkit/custom/config/store.rb', line 57 def pop_pwd active_backend.pwd ||= [] active_backend.pwd.pop end |
.pop_user_group ⇒ Object
Resets user and group to the previous one.
97 98 99 100 101 |
# File 'lib/sshkit/custom/config/store.rb', line 97 def pop_user_group old_user_group = _user_groups.pop || {} active_backend.user = old_user_group[:user] active_backend.group = old_user_group[:group] end |
.runner ⇒ Object
The actual runner object
35 36 37 |
# File 'lib/sshkit/custom/config/store.rb', line 35 def runner @runner.tap { |r| r.backends = backends } end |