Sha256: b8f2022aba69cdfe22772af84790a0dd14f5b80e2054bf151faf1704a3c8f948

Contents?: true

Size: 962 Bytes

Versions: 5

Compression:

Stored size: 962 Bytes

Contents

# Author::    Nicolas Pouillard  <ertai@lrde.epita.fr>.
# Copyright:: Copyright (c) 2004, 2005 TTK team. All rights reserved.
# License::   LGPL
# $Id: Diff.rb 567 2005-04-13 08:00:06Z polrop $


module TTK

  module Streams

    class Diff < Stream

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

    end # Diff

  end # module Streams

end # module TTK

class Object
  def to_diff_for_ttk_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_ttk_log ( my )
    open.to_diff_for_ttk_log(my)
  end
end

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

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
ttk-0.1.576 lib/ttk/strategies/Streams/Diff.rb
ttk-0.2.1 lib/ttk/strategies/Streams/Diff.rb
ttk-0.1.579 lib/ttk/strategies/Streams/Diff.rb
ttk-0.2.0 lib/ttk/strategies/Streams/Diff.rb
ttk-0.1.580 lib/ttk/strategies/Streams/Diff.rb