Class: RSCM::Accurev::AcXMLScrubIO
- Inherits:
-
StringIO
- Object
- StringIO
- RSCM::Accurev::AcXMLScrubIO
- Defined in:
- lib/rscm/scm/accurev/filterio.rb
Overview
IO stream which cleans irregularities out of accurev xml output.
In particular:
-
Unlike other commands, the
-fx
output from _accurev update_ has a root element of <acResponse>, not <AcResponse>. -
_accurev update_ emits broken XML when there are no files to update.
Instance Method Summary collapse
- #clean(source) ⇒ Object
-
#initialize(sourceio) ⇒ AcXMLScrubIO
constructor
@param: sourceio - io or string source to wrap.
Constructor Details
#initialize(sourceio) ⇒ AcXMLScrubIO
@param: sourceio - io or string source to wrap
20 21 22 23 24 25 26 |
# File 'lib/rscm/scm/accurev/filterio.rb', line 20 def initialize( sourceio ) if sourceio.respond_to?( :read ) super( clean( sourceio.read ) ) else super( clean(sourceio) ) end end |
Instance Method Details
#clean(source) ⇒ Object
28 29 30 31 32 33 34 35 36 |
# File 'lib/rscm/scm/accurev/filterio.rb', line 28 def clean( source ) File.open( "/tmp/scrubio.outA", "w" ).puts( source ) source.gsub!( /<acResponse/, "<AcResponse" ) source.gsub!( /<\/acResponse/, "<\/AcResponse" ) File.open( "/tmp/scrubio.outB", "w" ).puts( source ) source.gsub!( /command="update"[^>]*(>?)/, 'command="update"\1' ) File.open( "/tmp/scrubio.outC", "w" ).puts( source ) return source end |