Class: Mxrb::Runtime::Clipboard
- Inherits:
-
Object
- Object
- Mxrb::Runtime::Clipboard
- Defined in:
- lib/mxrb/runtime/clipboard.rb
Overview
Copies secrets through stdin so they never appear in the process list.
Constant Summary collapse
- COMMANDS =
[ ['wl-copy'], ['pbcopy'], ['xclip', '-selection', 'clipboard'], ['xsel', '--clipboard', '--input'], ['clip.exe'] ].freeze
Instance Method Summary collapse
- #copy(text) ⇒ Object
-
#initialize(path: ENV.fetch('PATH', ''), runner: nil) ⇒ Clipboard
constructor
A new instance of Clipboard.
Constructor Details
#initialize(path: ENV.fetch('PATH', ''), runner: nil) ⇒ Clipboard
Returns a new instance of Clipboard.
14 15 16 17 |
# File 'lib/mxrb/runtime/clipboard.rb', line 14 def initialize(path: ENV.fetch('PATH', ''), runner: nil) @path = path @runner = runner || method(:capture) end |
Instance Method Details
#copy(text) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/mxrb/runtime/clipboard.rb', line 19 def copy(text) command = available_command unless command raise ToolchainError, 'no clipboard command found; install wl-copy, pbcopy, xclip, xsel, or clip.exe' end _stdout, stderr, status = @runner.call(command, text.to_s) raise ToolchainError, "clipboard command failed: #{stderr}" unless status.success? command.first end |