Class: LearnOpen::Adapters::SystemAdapter
- Inherits:
-
Object
- Object
- LearnOpen::Adapters::SystemAdapter
- Defined in:
- lib/learn_open/adapters/system_adapter.rb
Class Method Summary collapse
- .change_context_directory(dir) ⇒ Object
- .open_editor(editor, path:) ⇒ Object
- .open_login_shell(shell) ⇒ Object
- .run_command(command) ⇒ Object
- .run_command_with_capture(command) ⇒ Object
- .spawn(command, block: false) ⇒ Object
Class Method Details
.change_context_directory(dir) ⇒ Object
27 28 29 |
# File 'lib/learn_open/adapters/system_adapter.rb', line 27 def self.change_context_directory(dir) Dir.chdir(dir) end |
.open_editor(editor, path:) ⇒ Object
6 7 8 |
# File 'lib/learn_open/adapters/system_adapter.rb', line 6 def self.open_editor(editor, path:) system("#{editor} .") end |
.open_login_shell(shell) ⇒ Object
10 11 12 |
# File 'lib/learn_open/adapters/system_adapter.rb', line 10 def self.open_login_shell(shell) exec("#{shell} -l") end |
.run_command(command) ⇒ Object
19 20 21 |
# File 'lib/learn_open/adapters/system_adapter.rb', line 19 def self.run_command(command) system(command) end |
.run_command_with_capture(command) ⇒ Object
23 24 25 |
# File 'lib/learn_open/adapters/system_adapter.rb', line 23 def self.run_command_with_capture(command) Open3.capture3(command) end |
.spawn(command, block: false) ⇒ Object
14 15 16 17 |
# File 'lib/learn_open/adapters/system_adapter.rb', line 14 def self.spawn(command, block: false) pid = Process.spawn(command, [:out, :err] => File::NULL) Process.waitpid(pid) if block end |