Class: Bcome::System::Local

Inherits:
Object
  • Object
show all
Includes:
Singleton
Defined in:
lib/objects/system/local.rb

Instance Method Summary collapse

Instance Method Details

#command(raw_command) ⇒ Object



29
30
31
# File 'lib/objects/system/local.rb', line 29

def command(raw_command)
  ::Bcome::Command::Local.run(raw_command)
end

#execute_command(raw_command, print_out_command = false) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
# File 'lib/objects/system/local.rb', line 7

def execute_command(raw_command, print_out_command = false)
  puts "\n> #{raw_command}".bc_blue + "\n" if print_out_command

  local_command = command(raw_command)
  if local_command.failed? && !in_console_session?
    # we fail fast if we're not in a console session
    raise Bcome::Exception::FailedToRunLocalCommand, "#{raw_command}. Error: " + local_command.stderr
  end

  local_command
end

#in_console_session?Boolean

Returns:

  • (Boolean)


19
20
21
# File 'lib/objects/system/local.rb', line 19

def in_console_session?
  ::Bcome::Workspace.instance.console_set?
end

#local_userObject



23
24
25
26
27
# File 'lib/objects/system/local.rb', line 23

def local_user
  result = command('whoami')
  result.stdout =~ /(.+)\n/
  Regexp.last_match(1)
end