Class: Bwrap::Execution::Popen2e
- Inherits:
-
Object
- Object
- Bwrap::Execution::Popen2e
- Includes:
- Output
- Defined in:
- lib/bwrap/execution/popen2e.rb
Overview
Instance Attribute Summary collapse
-
#dry_run ⇒ Object
writeonly
Sets the attribute dry_run.
Instance Method Summary collapse
-
#child_status ⇒ Process::Status|nil
Only contains ‘Process::Status` if no block has been passed to #popen2e.
- #config=(value) ⇒ Object
-
#initialize(rootcmd: nil, config: nil) ⇒ Popen2e
constructor
A new instance of Popen2e.
-
#popen2e(*cmd, **kwargs, &block) ⇒ Array<(IO, IO, Thread)>
Write and read ‘IO` and a wait thread.
-
#rootcmd=(value) ⇒ Object
Can be used to implement kind of tag based bubblewrap command things.
Methods included from Output
debug?, debug_output, error_output, handle_output_options, info_output, quiet?, trace?, trace_output, verb_output, verbose?, warn_output
Constructor Details
#initialize(rootcmd: nil, config: nil) ⇒ Popen2e
Returns a new instance of Popen2e.
15 16 17 18 |
# File 'lib/bwrap/execution/popen2e.rb', line 15 def initialize rootcmd: nil, config: nil self.rootcmd = rootcmd self.config = config end |
Instance Attribute Details
#dry_run=(value) ⇒ Object (writeonly)
Sets the attribute dry_run
11 12 13 |
# File 'lib/bwrap/execution/popen2e.rb', line 11 def dry_run=(value) @dry_run = value end |
Instance Method Details
#child_status ⇒ Process::Status|nil
Only contains ‘Process::Status` if no block has been passed to #popen2e.
93 94 95 |
# File 'lib/bwrap/execution/popen2e.rb', line 93 def child_status @child_status end |
#config=(value) ⇒ Object
21 22 23 24 25 26 27 28 |
# File 'lib/bwrap/execution/popen2e.rb', line 21 def config= value @config = value return unless @config and @rootcmd error "Only either rootcmd or config object can be given to popen2e. " \ "Please set rootcmd to nil if wanting to use config object." end |
#popen2e(*cmd, **kwargs, &block) ⇒ Array<(IO, IO, Thread)>
Also options accepted by upstream’s ‘Open3.popen2e` are accepted here, in addition to those specified here.
Returns Write and read ‘IO` and a wait thread.
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 |
# File 'lib/bwrap/execution/popen2e.rb', line 61 def popen2e *cmd, **kwargs, &block @log = kwargs.key?(:log) ? kwargs.delete(:log) : true @log_callback = kwargs.key?(:log_callback) ? kwargs.delete(:log_callback) : 1 @log_callback += 1 # Passing to another method, so need to add one more. self.opts_from_input = cmd if kwargs @opts ||= {} @opts.merge! kwargs end resolve_actual_command cmd return if dry_run? open_pipes child_io = [ @in_read, @out_write ] parent_io = [ @in_write, @out_read ] popen_run(@actual_command, child_io, parent_io, &block) ensure if block @in_read.close @in_write.close @out_read.close @out_write.close end end |
#rootcmd=(value) ⇒ Object
Can be used to implement kind of tag based bubblewrap command things. This system is not well documented, and originally done for purposes of the code where this gem was splitted from.
Probably using #config= instead makes more sense.
37 38 39 40 41 42 43 44 |
# File 'lib/bwrap/execution/popen2e.rb', line 37 def rootcmd= value @rootcmd = value return unless @config and @rootcmd error "Only either rootcmd or config object can be given to popen2e. " \ "Please set config to nil if wanting to use rootcmd flags." end |