Class Uttk::Strategies::IOBased
In: lib/uttk/strategies/IOBased.rb
Parent: Strategy

Methods

Included Modules

Abstract

Public Class methods

Constructor

[Source]

# File lib/uttk/strategies/IOBased.rb, line 18
      def initialize ( *a, &b )
        stream :input
        stream :output
        stream :error
        super
      end

Public Instance methods

[Source]

# File lib/uttk/strategies/IOBased.rb, line 98
      def stream ( name )
        @streams ||= []
        @streams_name ||= []
        @streams_name << name
      end

Accessors

[Source]

# File lib/uttk/strategies/IOBased.rb, line 132
      def stream_class= ( aClass )
        if aClass.is_a? Class
          @stream_class = aClass
        else
          @stream_class = Streams.const_get(aClass)
        end
      end

Protected Instance methods

[Source]

# File lib/uttk/strategies/IOBased.rb, line 46
      def assertion
        @streams.each do |stream|
          next if invalid_stream?(stream)
          fail("#{stream.name} is different") unless stream.compare_streams
        end
        pass
      end

[Source]

# File lib/uttk/strategies/IOBased.rb, line 56
      def epilogue
        @streams.each { |strm| strm.clean unless strm.nil? }
        super
      end

[Source]

# File lib/uttk/strategies/IOBased.rb, line 70
      def failed_hook
        super
        @streams.each do |stream|
          next if invalid_stream?(stream)
          @log["#{stream.name}_status"] = stream.status
        end
        print_streams() unless @quiet_print
      end

[Source]

# File lib/uttk/strategies/IOBased.rb, line 105
      def make_streams
        @streams = @streams_name.map do |name|
          stream = nil
          if instance_variables.include? "@#{name}"
            val = instance_variable_get("@#{name}")
            if val.nil?
              stream = @stream_class.new(name)
            else
              val = val.do_symtbl_gsub(@symtbl)
              if val.is_a? String
                tmp = TempPath.new
                tmp.open('w') { |res| res.print val }
                val = tmp.open('r')
              end
              stream = @stream_class.new(name, val)
            end
          end
          instance_variable_set "@#{name}", stream
          stream
        end
      end

[Source]

# File lib/uttk/strategies/IOBased.rb, line 63
      def pass_hook
        super
        print_streams() if @verbose_print
      end

Methods

[Source]

# File lib/uttk/strategies/IOBased.rb, line 30
      def prologue
        super
        make_streams
        unless @input.nil?
          if @input.ref.is_a? Pathname
            @input.my = @input.ref
          else
            @input.my.open('w') do |my|
              my.print @input.ref.to_s_for_uttk_log
            end
          end
        end
      end

[Validate]