Class TTK::Strategies::IOBased
In: lib/ttk/strategies/IOBased.rb
Parent: Strategy

Methods

Included Modules

Abstract

Public Class methods

Constructor

[Source]

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

Public Instance methods

[Source]

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

Accessors

[Source]

# File lib/ttk/strategies/IOBased.rb, line 129
      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/ttk/strategies/IOBased.rb, line 45
      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/ttk/strategies/IOBased.rb, line 55
      def epilogue
        @streams.each { |strm| strm.clean unless strm.nil? }
        super
      end

[Source]

# File lib/ttk/strategies/IOBased.rb, line 69
      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/ttk/strategies/IOBased.rb, line 102
      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/ttk/strategies/IOBased.rb, line 62
      def pass_hook
        super
        print_streams() if @verbose_print
      end

Methods

[Source]

# File lib/ttk/strategies/IOBased.rb, line 37
      def prologue
        super
        make_streams
        @input.my = nil unless @input.nil?
      end

[Validate]