module SSHKit::Custom::Config::Store

Public Instance Methods

_envs() click to toggle source

@api private

# File lib/sshkit/custom/config/store.rb, line 63
def _envs
  config_scope[:_envs] ||= []
end
_user_groups() click to toggle source

@api private

# File lib/sshkit/custom/config/store.rb, line 83
def _user_groups
  config_scope[:_user_groups] ||= []
end
active_backend() click to toggle source

Returns the active backend in the current thread

# File lib/sshkit/custom/config/store.rb, line 104
def active_backend
  SSHKit::Custom::Runner::Abstract.active_backend
end
add_env(env) click to toggle source

Set the environment for the current backend. @param env [Hash<String, String>] The new ENV-Vars to be used.

# 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) click to toggle source

Set the working directory for the current backend. @param directory [String] The new working directory

# 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) click to toggle source

Set the user and group for the current backend. @param user [String] The new username @param group [String, nil] The new group

# 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() click to toggle source

Get the actual backends

# File lib/sshkit/custom/config/store.rb, line 45
def backends
  @backends ||= []
end
backends=(hosts) click to toggle source

Sets the actual backends

# File lib/sshkit/custom/config/store.rb, line 40
def backends=(hosts)
  @backends = hosts.map { |host| SSHKit.config.backend.new(host) }
end
config_scope() click to toggle source

@api private

# File lib/sshkit/custom/config/store.rb, line 13
def config_scope
  @config_scope ||= ScopedStorage::Scope.new('sshkit_dsl_config', scope_storage)
end
create_runner(opts) click to toggle source

Creates a new runner @option opts [Symbol] :in Chooses the runner to be used

:parallel => Parallel
:sequence => Sequential
:groups => Group

@option opts [Integer] :wait Amount of seconds to sleep between executions for Sequential and Parallel Runner @option opts [Integer] :limit Amount of hosts to use in one Batch for Group Runner

# 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) click to toggle source

Sets the default runner opts for instance change the default runner

# File lib/sshkit/custom/config/store.rb, line 109
def default_runner_opts(opts)
  global_config_scope[:_default_runner_opts] = opts
end
global_config_scope() click to toggle source

@api private

# File lib/sshkit/custom/config/store.rb, line 18
def global_config_scope
  @global_config_scope ||= ScopedStorage::Scope.new('sshkit_dsl_global_config', ScopedStorage::ThreadGlobalStorage)
end
pop_env() click to toggle source

Resets the environment variables to the previous one.

# File lib/sshkit/custom/config/store.rb, line 77
def pop_env
  old_env = _envs.pop || {}
  active_backend.env = old_env
end
pop_pwd() click to toggle source

Set the working directory to the previous working directory for the current backend.

# File lib/sshkit/custom/config/store.rb, line 57
def pop_pwd
  active_backend.pwd ||= []
  active_backend.pwd.pop
end
pop_user_group() click to toggle source

Resets user and group to the previous one.

# 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() click to toggle source

The actual runner object

# File lib/sshkit/custom/config/store.rb, line 35
def runner
  @runner.tap { |r| r.backends = backends }
end
scope_storage() click to toggle source

@api private

# File lib/sshkit/custom/config/store.rb, line 8
def scope_storage
  ScopedStorage::ThreadLocalStorage
end