Class: GemInstaller::OutputProxy
- Inherits:
-
Object
- Object
- GemInstaller::OutputProxy
- Defined in:
- lib/geminstaller/output_proxy.rb
Instance Attribute Summary collapse
-
#options ⇒ Object
writeonly
Sets the attribute options.
Instance Method Summary collapse
- #default_stream=(stream) ⇒ Object
-
#output(output) ⇒ Object
TODO: should remove this, make callers explicitly choose.
- #silent? ⇒ Boolean
- #syserr(err) ⇒ Object
- #sysout(out) ⇒ Object
Instance Attribute Details
#options=(value) ⇒ Object (writeonly)
Sets the attribute options
3 4 5 |
# File 'lib/geminstaller/output_proxy.rb', line 3 def (value) = value end |
Instance Method Details
#default_stream=(stream) ⇒ Object
4 5 6 7 |
# File 'lib/geminstaller/output_proxy.rb', line 4 def default_stream=(stream) raise GemInstaller::GemInstallerError.new("Invalid default stream: #{stream}") unless stream == :stderr or stream == :stdout @default_stream = stream end |
#output(output) ⇒ Object
TODO: should remove this, make callers explicitly choose.
24 25 26 27 28 29 30 |
# File 'lib/geminstaller/output_proxy.rb', line 24 def output(output) if @default_stream == :stdout sysout(output) else syserr(output) end end |
#silent? ⇒ Boolean
32 33 34 |
# File 'lib/geminstaller/output_proxy.rb', line 32 def silent? && [:silent] end |
#syserr(err) ⇒ Object
14 15 16 17 18 19 20 21 |
# File 'lib/geminstaller/output_proxy.rb', line 14 def syserr(err) return if silent? if [:redirect_stderr_to_stdout] $stdout.print err else $stderr.print err end end |
#sysout(out) ⇒ Object
9 10 11 12 |
# File 'lib/geminstaller/output_proxy.rb', line 9 def sysout(out) return if silent? $stdout.print out end |