module BitScopeNew

takelage bit scope new

Public Instance Methods

bit_scope_new(scope) click to toggle source

Backend method for bit scope new. @return [Int] status of new command

# File lib/takelage/bit/scope/new.rb, line 7
def bit_scope_new(scope)
  log.debug "Creating new bit remote scope \"#{scope}\""

  return false unless configured? %w[bit_ssh bit_remote]

  return false if _bit_scope_new_scope_exists? scope

  cmd_bit_ssh = config.active['bit_ssh']

  cmd_bit_scope_new = _bit_scope_new_cmd scope

  run "#{cmd_bit_ssh} '#{cmd_bit_scope_new}'"

  log.info "Created new bit remote scope \"#{scope}\""
end

Private Instance Methods

_bit_scope_new_cmd(scope) click to toggle source

Prepare bit scope new command.

# File lib/takelage/bit/scope/new.rb, line 35
def _bit_scope_new_cmd(scope)
  root = config.active['bit_root']

  format(
    config.active['cmd_bit_scope_new_bit_init'],
    scope: scope,
    root: root
  )
end
_bit_scope_new_scope_exists?(scope) click to toggle source

Check if bit scope already exists.

# File lib/takelage/bit/scope/new.rb, line 26
def _bit_scope_new_scope_exists?(scope)
  scope_list = bit_scope_list
  return false unless scope_list.include? scope

  log.error "The remote bit scope \"#{scope}\" already exists"
  false
end