Name | Total Lines | Lines of Code | Total Coverage | Code Coverage |
---|---|---|---|---|
rcov/ruby/1.8/gems/diff-lcs-1.1.2/lib/diff/lcs/block.rb | 51 | 28 | 52.94%
|
17.86%
|
Code reported as executed by Ruby looks like this...and this: this line is also marked as covered.Lines considered as run by rcov, but not reported by Ruby, look like this,and this: these lines were inferred by rcov (using simple heuristics).Finally, here's a line marked as not executed.
1 #! /usr/env/bin ruby |
2 #-- |
3 # Copyright 2004 Austin Ziegler <diff-lcs@halostatue.ca> |
4 # adapted from: |
5 # Algorithm::Diff (Perl) by Ned Konz <perl@bike-nomad.com> |
6 # Smalltalk by Mario I. Wolczko <mario@wolczko.com> |
7 # implements McIlroy-Hunt diff algorithm |
8 # |
9 # This program is free software. It may be redistributed and/or modified under |
10 # the terms of the GPL version 2 (or later), the Perl Artistic licence, or the |
11 # Ruby licence. |
12 # |
13 # $Id: block.rb,v 1.3 2004/08/08 20:33:09 austin Exp $ |
14 #++ |
15 # Contains Diff::LCS::Block for bin/ldiff. |
16 |
17 # A block is an operation removing, adding, or changing a group of items. |
18 # Basically, this is just a list of changes, where each change adds or |
19 # deletes a single item. Used by bin/ldiff. |
20 class Diff::LCS::Block |
21 attr_reader :changes, :insert, :remove |
22 |
23 def initialize(chunk) |
24 @changes = [] |
25 @insert = [] |
26 @remove = [] |
27 |
28 chunk.each do |item| |
29 @changes << item |
30 @remove << item if item.deleting? |
31 @insert << item if item.adding? |
32 end |
33 end |
34 |
35 def diff_size |
36 @insert.size - @remove.size |
37 end |
38 |
39 def op |
40 case [@remove.empty?, @insert.empty?] |
41 when [false, false] |
42 '!' |
43 when [false, true] |
44 '-' |
45 when [true, false] |
46 '+' |
47 else # [true, true] |
48 '^' |
49 end |
50 end |
51 end |
Generated on Fri Apr 22 17:22:41 -0700 2011 with rcov 0.9.8