Class: Bcome::System::Local
- Inherits:
-
Object
- Object
- Bcome::System::Local
- Includes:
- Singleton
- Defined in:
- lib/objects/system/local.rb
Instance Method Summary collapse
- #command(raw_command) ⇒ Object
- #execute_command(raw_command, print_out_command = false) ⇒ Object
- #in_console_session? ⇒ Boolean
- #local_user ⇒ Object
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
19 20 21 |
# File 'lib/objects/system/local.rb', line 19 def in_console_session? ::Bcome::Workspace.instance.console_set? end |
#local_user ⇒ Object
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 |