diff 0.3.5 → 0.3.6

Sign up to get free protection for your applications and to get access to all the features.
data.tar.gz.sig CHANGED
@@ -1,5 +1,3 @@
1
- Ay��:��F��Ԗ=��V��
2
- S Ɏ��Ŏ�?�g�6٦[�؆Hلk�K�YvZ�9Ij}���͙ �P�Kp�� x�vk�zJU�7��; ��!��������#Pp�<E����� �ybw�����Y���in���� ��L�Ga�wI���{IϽ_n�s�Y�/�� �.G��
3
-
4
- ��}�m��M:�� D����&�)��h��G�����H��
5
- O'���Lw�{C�T�z���WE
1
+ k��a���ۍ\t����} �P����ڥP'��R��zI�/a����^���&J����%O�=�Ϊ�����ѢRM�x�F�}�N9W*�Q��.q �~��cf^ޛ���}�[N�J�20W�3�J�>�M���+�^=�A.F�7ԓ7HoSD���( �#�4ۈ�lB��9�G����٣
2
+ W
3
+ /Iɋ�ޮl*}A+3I��"���ş�Ğ�aU�`���� �}q�p�ma-�N�R�}wY�ԑ2���
data/Rakefile CHANGED
@@ -2,7 +2,7 @@ require 'rubygems'
2
2
  require 'rake'
3
3
  require 'echoe'
4
4
 
5
- Echoe.new('diff','0.3.5') do |s|
5
+ Echoe.new('diff','0.3.6') do |s|
6
6
  s.description = "Diff Algorithm Implementation"
7
7
  s.url = "http://users.cybercity.dk/~dsl8950/ruby/diff.html"
8
8
  s.author = "Wayne Walter"
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{diff}
5
- s.version = "0.3.5"
5
+ s.version = "0.3.6"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = ["Wayne Walter"]
@@ -46,12 +46,8 @@ module HTMLCollapsable
46
46
  end
47
47
 
48
48
  def patch_email(diff,starttoken = nil,endtoken = nil)
49
- newary = nil
50
- if diff.difftype == String
51
- newary = diff.difftype.new('')
52
- else
53
- newary = diff.difftype.new
54
- end
49
+ found_diff = 0
50
+ newary = diff.difftype.new
55
51
  ai = 0
56
52
  bi = 0
57
53
  diff.diffs.each { |d|
@@ -59,29 +55,30 @@ module HTMLCollapsable
59
55
  quoted = 0
60
56
  case mod[0]
61
57
  when '-'
62
- if ai < mod[1]
58
+ if ai < mod[1] && !starttoken.nil? && found_diff == 1
63
59
  quoted = 1
64
60
  end
65
- newary << starttoken if quoted == 1 && !starttoken.nil?
61
+ newary << starttoken if quoted == 1
66
62
  while ai < mod[1]
67
- newary << diff.orig_b[bi] if !starttoken.nil?
63
+ newary << diff.orig_b[bi] if quoted == 1 || found_diff == 0
68
64
  ai += 1
69
65
  bi += 1
70
66
  end
71
- newary << endtoken if quoted == 1 && !starttoken.nil?
67
+ newary << endtoken if quoted == 1
72
68
  ai += 1
73
69
  when '+'
74
- if bi < mod[1]
70
+ if bi < mod[1] && !starttoken.nil? && found_diff == 1
75
71
  quoted = 1
76
72
  end
77
- newary << starttoken if quoted == 1 && !starttoken.nil?
73
+ newary << starttoken if quoted == 1
78
74
  while bi < mod[1]
79
- newary << diff.orig_b[bi] if !starttoken.nil?
75
+ newary << diff.orig_b[bi] if quoted == 1 || found_diff == 0
80
76
  ai += 1
81
77
  bi += 1
82
78
  end
83
- newary << endtoken if quoted == 1 && !starttoken.nil?
79
+ newary << endtoken if quoted == 1
84
80
  newary << diff.orig_b[mod[1]]
81
+ found_diff = 1
85
82
  bi += 1
86
83
  else
87
84
  raise "Unknown diff action"
@@ -89,16 +86,26 @@ module HTMLCollapsable
89
86
  }
90
87
  }
91
88
  quoted = 0
92
- if ai < self.length
89
+ if ai < self.length && !starttoken.nil? && found_diff == 1
93
90
  quoted = 1
94
91
  end
95
- newary << starttoken if quoted == 1 && !starttoken.nil?
92
+ newary << starttoken if quoted == 1
96
93
  while ai < self.length
97
- newary << diff.orig_b[bi] if !starttoken.nil?
94
+ newary << diff.orig_b[bi] if quoted == 1 or found_diff == 0
98
95
  ai += 1
99
96
  bi += 1
100
97
  end
101
- newary << endtoken if quoted == 1 && !starttoken.nil?
98
+ newary << endtoken if quoted == 1
99
+ if found_diff == 0
100
+ if !starttoken.nil?
101
+ if newary.length > 0
102
+ newary.unshift starttoken
103
+ newary << endtoken
104
+ end
105
+ else
106
+ return diff.difftype.new
107
+ end
108
+ end
102
109
  return newary
103
110
  end
104
111
  end
@@ -1,49 +1,62 @@
1
1
  module EmailDiffArrayTests
2
2
 
3
3
  def test_array_double_quoted
4
- emailtest ["1","2","3"], [">1",">2",">3","4"], [888,">1",">2",">3",999,"4"]
5
- emailtest ["1"," > 2"," > 3"], [">1","> > 2","> > 3","4","5"], [888,">1","> > 2","> > 3",999,"4","5"]
6
- emailtest ["1","2","3"], [">1",">2",">3","4"], ["4"], :remove
7
- emailtest ["1"," > 2"," > 3"], [">1","> > 2","> > 3","4","5"], ["4","5"], :remove
4
+ emailtest ["1","2","3"], [">1",">2",">3","4"], [">1",">2",">3","4"]
5
+ emailtest ["1"," > 2"," > 3"], [">1","> > 2","> > 3","4","5"], [">1","> > 2","> > 3","4","5"]
6
+ end
7
+ def test_array_double_quoted_remove
8
+ emailtest ["1","2","3"], [">1",">2",">3","4"], [">1",">2",">3","4"], :remove
9
+ emailtest ["1"," > 2"," > 3"], [">1","> > 2","> > 3","4","5"], [">1","> > 2","> > 3","4","5"], :remove
8
10
  end
9
11
 
10
12
  def test_array_quoted
11
- emailtest ["1","2","3"], [">1",">2",">3","4"], [888,">1",">2",">3",999,"4"]
12
- emailtest ["1","2","3"], [">1",">2",">3","4","5"], [888,">1",">2",">3",999,"4","5"]
13
- emailtest ["1","2","3"], [">1",">2",">3","4"], ["4"], :remove
14
- emailtest ["1","2","3"], [">1",">2",">3","4","5"], ["4","5"], :remove
13
+ emailtest ["1","2","3"], [">1",">2",">3","4"], [">1",">2",">3","4"]
14
+ emailtest ["1","2","3"], [">1",">2",">3","4","5"], [">1",">2",">3","4","5"]
15
+ end
16
+ def test_array_quoted_remove
17
+ emailtest ["1","2","3"], [">1",">2",">3","4"], [">1",">2",">3","4"], :remove
18
+ emailtest ["1","2","3"], [">1",">2",">3","4","5"], [">1",">2",">3","4","5"], :remove
15
19
  end
16
20
 
17
21
  def test_array_append
18
- emailtest [1,2,3], [1,2,3,4], [888,1,2,3,999,4]
19
- emailtest [1,2,3], [1,2,3,4,5], [888,1,2,3,999,4,5]
20
- emailtest [1,2,3], [1,2,3,4], [4], :remove
21
- emailtest [1,2,3], [1,2,3,4,5], [4,5], :remove
22
+ emailtest [1,2,3], [1,2,3,4], [1,2,3,4]
23
+ emailtest [1,2,3], [1,2,3,4,5], [1,2,3,4,5]
24
+ end
25
+ def test_array_append_remove
26
+ emailtest [1,2,3], [1,2,3,4], [1,2,3,4], :remove
27
+ emailtest [1,2,3], [1,2,3,4,5], [1,2,3,4,5], :remove
22
28
  end
23
29
 
24
30
  def test_array_prepend
25
31
  emailtest [1,2,3], [0,1,2,3], [0,888,1,2,3,999]
26
32
  emailtest [1,2,3], [-1,0,1,2,3], [-1,0,888,1,2,3,999]
33
+ end
34
+ def test_array_prepend_remove
27
35
  emailtest [1,2,3], [0,1,2,3], [0,], :remove
28
36
  emailtest [1,2,3], [-1,0,1,2,3], [-1,0,], :remove
29
37
  end
30
38
 
31
39
  def test_array_insert
32
- emailtest [1,2,3], [1,2,4,3], [888,1,2,999,4,888,3,999]
33
- emailtest [1,2,3], [1,2,4,5,3], [888,1,2,999,4,5,888,3,999]
34
- emailtest [1,2,3], [1,2,4,3], [4,], :remove
35
- emailtest [1,2,3], [1,2,4,5,3], [4,5], :remove
40
+ emailtest [1,2,3], [1,2,4,3], [1,2,4,888,3,999]
41
+ emailtest [1,2,3], [1,2,4,5,3], [1,2,4,5,888,3,999]
42
+ end
43
+ def test_array_insert_remove
44
+ emailtest [1,2,3], [1,2,4,3], [1,2,4], :remove
45
+ emailtest [1,2,3], [1,2,4,5,3], [1,2,4,5], :remove
36
46
  end
37
47
 
38
48
  def test_array_remove
39
- emailtest [1,2,3], [1,3], [888,1,999,888,3,999]
49
+ emailtest [1,2,3], [1,3], [888,1,3,999]
50
+ end
51
+ def test_array_remove_remove
40
52
  emailtest [1,2,3], [1,3], [], :remove
41
-
42
53
  end
43
54
 
44
55
  def test_array_cutfront
45
56
  emailtest [1,2,3], [2,3], [888,2,3,999]
46
57
  emailtest [1,2,3], [3], [888,3,999]
58
+ end
59
+ def test_array_cutfront_remove
47
60
  emailtest [1,2,3], [2,3], [], :remove
48
61
  emailtest [1,2,3], [3], [], :remove
49
62
  end
@@ -51,41 +64,55 @@ module EmailDiffArrayTests
51
64
  def test_array_cutback
52
65
  emailtest [1,2,3], [1,2], [888,1,2,999]
53
66
  emailtest [1,2,3], [1], [888,1,999]
67
+ end
68
+ def test_array_cutback_remove
54
69
  emailtest [1,2,3], [1,2], [], :remove
55
70
  emailtest [1,2,3], [1], [], :remove
56
71
  end
57
72
 
58
73
  def test_array_empty
59
74
  emailtest [1,2,3], [], []
75
+ end
76
+ def test_array_empty_remove
60
77
  emailtest [1,2,3], [], [], :remove
61
78
  end
62
79
 
63
80
  def test_array_fill
64
81
  emailtest [], [1,2,3], [1,2,3]
82
+ end
83
+ def test_array_fill_remove
65
84
  emailtest [], [1,2,3], [1,2,3], :remove
66
85
  end
67
86
 
68
87
  def test_array_change
69
- emailtest [1,2,3], [1,4,3], [888,1,999,4,888,3,999]
70
- emailtest [1,2,3], [1,4,5], [888,1,999,4,5]
71
- emailtest [1,2,3,4], [1,5,4], [888,1,999,5,888,4,999]
72
- emailtest [1,2,3], [1,4,3], [4], :remove
73
- emailtest [1,2,3], [1,4,5], [4,5], :remove
74
- emailtest [1,2,3,4], [1,5,4], [5], :remove
88
+ emailtest [1,2,3], [1,4,3], [1,4,888,3,999]
89
+ emailtest [1,2,3], [1,4,5], [1,4,5]
90
+ emailtest [1,2,3,4], [1,5,4], [1,5,888,4,999]
91
+ end
92
+ def test_array_change_remove
93
+ emailtest [1,2,3], [1,4,3], [1,4], :remove
94
+ emailtest [1,2,3], [1,4,5], [1,4,5], :remove
95
+ emailtest [1,2,3,4], [1,5,4], [1,5], :remove
75
96
  end
76
97
 
77
98
  def test_array_noop
78
99
  emailtest [1,2,3], [1,2,3], [888,1,2,3,999]
100
+ end
101
+ def test_array_noop_remove
79
102
  emailtest [1,2,3], [1,2,3], [], :remove
80
103
  end
81
104
 
82
105
  def test_array_grow
83
106
  emailtest [1,2,3], [4,1,5,2,6,3,7], [4,888,1,999,5,888,2,999,6,888,3,999,7]
107
+ end
108
+ def test_array_grow_remove
84
109
  emailtest [1,2,3], [4,1,5,2,6,3,7], [4,5,6,7], :remove
85
110
  end
86
111
 
87
112
  def test_array_shrink
88
- emailtest [1,2,3,4,5,6,7], [2,4,6], [888,2,999,888,4,999,888,6,999]
113
+ emailtest [1,2,3,4,5,6,7], [2,4,6], [888,2,4,6,999]
114
+ end
115
+ def test_array_shrink_remove
89
116
  emailtest [1,2,3,4,5,6,7], [2,4,6], [], :remove
90
117
  end
91
118
 
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 3
8
- - 5
9
- version: 0.3.5
8
+ - 6
9
+ version: 0.3.6
10
10
  platform: ruby
11
11
  authors:
12
12
  - Wayne Walter
metadata.gz.sig CHANGED
Binary file