Sha256: d35f1d029990e8992568a844be5543055d80eb5253201e65a67bee5eed4294ee

Contents?: true

Size: 1.57 KB

Versions: 3

Compression:

Stored size: 1.57 KB

Contents

# Author::    Nicolas Pouillard  <ertai@lrde.epita.fr>.
# Copyright:: Copyright (c) 2004, 2005 Uttk team. All rights reserved.
# License::   LGPL
# $Id: /fey/uttk/trunk/lib/uttk/streams/Stream.rb 8778 2005-09-26T04:34:48.103938Z ertai  $


module Uttk

  module Streams

    class Stream

      #
      # Attributes
      #

      attr_accessor :name, :my, :ref


      #
      # Constructor
      #

      def initialize ( name, ref=nil )
        @name, @my, @ref = name.to_s, TempPath.new(name), ref
      end


      #
      # Methods
      #

      def compare_streams
        return @cmp if defined? @cmp
        @cmp = @ref.compare_stream(@my)
        @status = @cmp ? :PASS : :FAILED
        @cmp
      end

      def status
        compare_streams
        @status
      end

      def to_uttk_log ( log )
        unless @name == 'input'
          str = @my.to_s_for_uttk_log
          unless str.nil? or (str.is_a? String and str.empty?)
            log["my_#@name"] = str
          end
        end
        unless @ref.nil?
          str = @ref.to_s_for_uttk_log
          unless str.nil? or (str.is_a? String and str.empty?)
            log["ref_#@name"] = str
          end
        end
      end

      def clean
        if @my.is_a? Pathname
          @my.unlink if @my.exist? and @my.temp?
        end
        if @ref.is_a? Pathname
          @ref.unlink if @ref.exist? and @ref.temp?
        elsif @ref.is_a? File
          ref = Pathname.new(@ref.path)
          ref.unlink if ref.exist? and ref.temp?
        end
      end

    end # class Stream

  end # module Streams

end # module Uttk

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
uttk-0.3.6.1 lib/uttk/streams/Stream.rb
uttk-0.3.1.2 lib/uttk/streams/Stream.rb
uttk-0.3.5.0 lib/uttk/streams/Stream.rb