Module: Test::Unit::Diff
Relationships & Source Files | |
Namespace Children | |
Classes:
| |
Defined in: | lib/test/unit/diff.rb |
Class Method Summary
- .diff(differ_class, from, to, options = {}) mod_func
- .fold(string) mod_func
- .folded_readable(from, to, options = {}) mod_func
- .need_fold?(diff) ⇒ Boolean mod_func
- .readable(from, to, options = {}) mod_func
- .unified(from, to, options = {}) mod_func
Class Method Details
.diff(differ_class, from, to, options = {}) (mod_func)
[ GitHub ]# File 'lib/test/unit/diff.rb', line 725
def diff(differ_class, from, to, ={}) if from.respond_to?(:valid_encoding?) and not from.valid_encoding? from = from.dup.force_encoding("ASCII-8BIT") end if to.respond_to?(:valid_encoding?) and not to.valid_encoding? to = to.dup.force_encoding("ASCII-8BIT") end differ = differ_class.new(from.split(/\r?\n/), to.split(/\r?\n/)) lines = differ.diff( ) if Object.const_defined?(:EncodingError) begin lines.join("\n") rescue EncodingError lines.collect {|line| line.force_encoding("ASCII-8BIT")}.join("\n") end else lines.join("\n") end end
.fold(string) (mod_func)
[ GitHub ]# File 'lib/test/unit/diff.rb', line 707
def fold(string) string.split(/\r?\n/).collect do |line| line.gsub(/(.{78})/, "\\1\n") end.join("\n") end
.folded_readable(from, to, options = {}) (mod_func)
[ GitHub ]
.need_fold?(diff) ⇒ Boolean
(mod_func)
.readable(from, to, options = {}) (mod_func)
[ GitHub ]# File 'lib/test/unit/diff.rb', line 717
def readable(from, to, ={}) diff(ReadableDiffer, from, to, ) end
.unified(from, to, options = {}) (mod_func)
[ GitHub ]# File 'lib/test/unit/diff.rb', line 721
def unified(from, to, ={}) diff(UnifiedDiffer, from, to, ) end