Sha256: eef885b29c93cd40e0dcb039335df84ddd7d17b5613c61c84911d1b0361283ca

Contents?: true

Size: 1015 Bytes

Versions: 3

Compression:

Stored size: 1015 Bytes

Contents

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


module Uttk

  module Streams

    class Diff < Stream

      def to_uttk_log ( log )
        log["diff_#@name"] = @ref.to_diff_for_uttk_log(@my) if @ref.can_diff?
      end

    end # Diff

  end # module Streams

end # module Uttk

class Object
  def to_diff_for_uttk_log ( my )
    IO.popen("diff -u --label my #{my} --label ref -", 'r+') do |diff|
      diff << to_s
      diff.close_write
      diff.readlines.join
    end
  end
  def can_diff?
    true
  end
end

class NilClass
  def can_diff?
    false
  end
end

class Regexp
  def can_diff?
    false
  end
end

class Pathname
  def to_diff_for_uttk_log ( my )
    open.to_diff_for_uttk_log(my)
  end
end

class IO
  def to_diff_for_uttk_log ( my )
    rewind
    readlines.join.to_diff_for_uttk_log(my)
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
uttk-0.4.6.1 lib/uttk/streams/Diff.rb
uttk-0.4.5.0 lib/uttk/streams/Diff.rb
uttk-0.4.6.2 lib/uttk/streams/Diff.rb