palmister 0.0.1 → 0.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,31 +1,33 @@
1
1
  #require 'action_view/template_handlers/erb'
2
- class Palmister::SimpleCorrectionDiff #:nodoc:
3
- include ERB::Util
2
+ module Palmister
3
+ class SimpleCorrectionDiff #:nodoc:
4
+ include ERB::Util
4
5
 
5
- attr_accessor :content
6
+ attr_accessor :content
6
7
 
7
- def initialize
8
- @content = ""
9
- end
8
+ def initialize
9
+ @content = ""
10
+ end
10
11
 
11
- def change(event)
12
- out = Palmister::StringSimpleCorrectionDiff.new
13
- Diff::LCS.traverse_sequences(event.old_element, event.new_element, out)
14
- @content << %Q|<span class="change">#{out.content}#{out.closing}</span><br/></span><br/>\n|
15
- end
12
+ def change(event)
13
+ out = Palmister::StringSimpleCorrectionDiff.new
14
+ Diff::LCS.traverse_sequences(event.old_element, event.new_element, out)
15
+ @content << %Q|<span class="change">#{out.content}#{out.closing}</span><br/></span><br/>\n|
16
+ end
16
17
 
17
18
  # This will be called with both lines are the same
18
- def match(event)
19
- @content << %Q|<span class="match">#{event.new_element}</span><br/>\n|
20
- end
19
+ def match(event)
20
+ @content << %Q|<span class="match">#{event.new_element}</span><br/>\n|
21
+ end
21
22
 
22
23
  # This will be called when there is a line in A that isn't in B
23
- def discard_a(event)
24
- @content << %Q|<span class="only_a"><del>#{event.old_element}</del></span><br/>\n|
25
- end
24
+ def discard_a(event)
25
+ @content << %Q|<span class="only_a"><del>#{event.old_element}</del></span><br/>\n|
26
+ end
26
27
 
27
28
  # This will be called when there is a line in B that isn't in A
28
- def discard_b(event)
29
- @content << %Q|<span class="only_b"><ins>#{event.new_element}</ins></span><br/>\n|
29
+ def discard_b(event)
30
+ @content << %Q|<span class="only_b"><ins>#{event.new_element}</ins></span><br/>\n|
31
+ end
30
32
  end
31
33
  end
@@ -1,36 +1,38 @@
1
- class Palmister::SimpleHtmlDiff #:nodoc:
2
- attr_accessor :content
3
- attr_accessor :old_line
4
- attr_accessor :new_line
1
+ module Palmister
2
+ class SimpleHtmlDiff #:nodoc:
3
+ attr_accessor :content
4
+ attr_accessor :old_line
5
+ attr_accessor :new_line
5
6
 
6
- def initialize
7
- @content = ""
8
- @old_line = 1
9
- @new_line = 1
10
- end
7
+ def initialize
8
+ @content = ""
9
+ @old_line = 1
10
+ @new_line = 1
11
+ end
11
12
 
12
- def change(event)
13
- @content << %Q|<tr><td>#{old_line}. </td><td><pre class="only_a">#{event.old_element}</pre></td><td><pre class="only_b">#{event.new_element}</pre></td><td>#{new_line}. </td></tr>\n|
14
- @old_line += 1
15
- @new_line += 1
16
- end
13
+ def change(event)
14
+ @content << %Q|<tr><td>#{old_line}. </td><td><pre class="only_a">#{event.old_element}</pre></td><td><pre class="only_b">#{event.new_element}</pre></td><td>#{new_line}. </td></tr>\n|
15
+ @old_line += 1
16
+ @new_line += 1
17
+ end
17
18
 
18
19
  # This will be called with both lines are the same
19
- def match(event)
20
- @content << %Q|<tr><td>#{old_line}. </td><td colspan="2"><pre class="match">#{event.old_element}</pre></td><td>#{new_line}. </td></tr>\n|
21
- @old_line += 1
22
- @new_line += 1
23
- end
20
+ def match(event)
21
+ @content << %Q|<tr><td>#{old_line}. </td><td colspan="2"><pre class="match">#{event.old_element}</pre></td><td>#{new_line}. </td></tr>\n|
22
+ @old_line += 1
23
+ @new_line += 1
24
+ end
24
25
 
25
26
  # This will be called when there is a line in A that isn't in B
26
- def discard_a(event)
27
- @content << %Q|<tr><td>#{old_line}. </td><td><pre class="only_a">#{event.old_element}</pre></td><td></td><td></td></tr>\n|
28
- @old_line += 1
29
- end
27
+ def discard_a(event)
28
+ @content << %Q|<tr><td>#{old_line}. </td><td><pre class="only_a">#{event.old_element}</pre></td><td></td><td></td></tr>\n|
29
+ @old_line += 1
30
+ end
30
31
 
31
32
  # This will be called when there is a line in B that isn't in A
32
- def discard_b(event)
33
- @content << %Q|<tr><td></td><td></td><td><pre class="only_b">#{event.new_element}</pre></td><td>#{new_line}. </td></tr>\n|
34
- @new_line += 1
33
+ def discard_b(event)
34
+ @content << %Q|<tr><td></td><td></td><td><pre class="only_b">#{event.new_element}</pre></td><td>#{new_line}. </td></tr>\n|
35
+ @new_line += 1
36
+ end
35
37
  end
36
38
  end
@@ -1,26 +1,28 @@
1
- class Palmister::SimpleLineDiff #:nodoc:
2
- attr_accessor :content
1
+ module Palmister
2
+ class SimpleLineDiff #:nodoc:
3
+ attr_accessor :content
3
4
 
4
- def initialize
5
- @content = ""
6
- end
5
+ def initialize
6
+ @content = ""
7
+ end
7
8
 
8
- def change(event)
9
- @content << %Q|<span class="only_a">#{event.old_element}</span><br/>\n<span class="only_b">#{event.new_element}</span><br/>\n|
10
- end
9
+ def change(event)
10
+ @content << %Q|<span class="only_a">#{event.old_element}</span><br/>\n<span class="only_b">#{event.new_element}</span><br/>\n|
11
+ end
11
12
 
12
13
  # This will be called with both lines are the same
13
- def match(event)
14
- @content << %Q|<span class="match">#{event.old_element}</span><br/>\n|
15
- end
14
+ def match(event)
15
+ @content << %Q|<span class="match">#{event.old_element}</span><br/>\n|
16
+ end
16
17
 
17
18
  # This will be called when there is a line in A that isn't in B
18
- def discard_a(event)
19
- @content << %Q|<span class="only_a">#{event.old_element}</span><br/>\n|
20
- end
19
+ def discard_a(event)
20
+ @content << %Q|<span class="only_a">#{event.old_element}</span><br/>\n|
21
+ end
21
22
 
22
23
  # This will be called when there is a line in B that isn't in A
23
- def discard_b(event)
24
- @content << %Q|<span class="only_b">#{event.new_element}</span><br/>\n|
24
+ def discard_b(event)
25
+ @content << %Q|<span class="only_b">#{event.new_element}</span><br/>\n|
26
+ end
25
27
  end
26
28
  end
@@ -1,59 +1,60 @@
1
- class Palmister::VcDiff #:nodoc:
2
- attr_accessor :content
3
- attr_accessor :old_line
4
- attr_accessor :new_line
5
- attr_accessor :last_lines
6
- attr_accessor :last
7
-
8
- def initialize
9
- @content = ""
10
- @last_lines = []
11
- @old_line = 1
12
- @new_line = 1
13
- end
1
+ module Palmister
2
+ class VcDiff #:nodoc:
3
+ attr_accessor :content
4
+ attr_accessor :old_line
5
+ attr_accessor :new_line
6
+ attr_accessor :last_lines
7
+ attr_accessor :last
8
+
9
+ def initialize
10
+ @content = ""
11
+ @last_lines = []
12
+ @old_line = 1
13
+ @new_line = 1
14
+ end
14
15
 
15
- def change(event)
16
- add_last_lines unless @last == :change
17
- @content << %Q|<tr><td>#{old_line}. </td><td><pre class="only_a">#{event.old_element}</pre></td><td><pre class="only_b">#{event.new_element}</pre></td><td>#{new_line}. </td></tr>\n|
16
+ def change(event)
17
+ add_last_lines unless @last == :change
18
+ @content << %Q|<tr><td>#{old_line}. </td><td><pre class="only_a">#{event.old_element}</pre></td><td><pre class="only_b">#{event.new_element}</pre></td><td>#{new_line}. </td></tr>\n|
18
19
 
19
- @last = :change
20
- @old_line += 1
21
- @new_line += 1
22
- end
20
+ @last = :change
21
+ @old_line += 1
22
+ @new_line += 1
23
+ end
23
24
 
24
25
  # This will be called with both lines are the same
25
- def match(event)
26
- @last_lines.push %Q|<tr><td>#{old_line}. </td><td colspan="2"><pre class="match">#{event.old_element}</pre></td><td>#{new_line}. </td></tr>\n|
27
- @old_line += 1
28
- @new_line += 1
29
- end
26
+ def match(event)
27
+ @last_lines.push %Q|<tr><td>#{old_line}. </td><td colspan="2"><pre class="match">#{event.old_element}</pre></td><td>#{new_line}. </td></tr>\n|
28
+ @old_line += 1
29
+ @new_line += 1
30
+ end
30
31
 
31
32
  # This will be called when there is a line in A that isn't in B
32
- def discard_a(event)
33
- add_last_lines unless @last == :discard_a
34
- @content << %Q|<tr><td>#{old_line}. </td><td><pre class="only_a">#{event.old_element}</pre></td><td></td><td></td></tr>\n|
33
+ def discard_a(event)
34
+ add_last_lines unless @last == :discard_a
35
+ @content << %Q|<tr><td>#{old_line}. </td><td><pre class="only_a">#{event.old_element}</pre></td><td></td><td></td></tr>\n|
35
36
 
36
- @last = :discard_a
37
- @old_line += 1
38
- end
37
+ @last = :discard_a
38
+ @old_line += 1
39
+ end
39
40
 
40
41
  # This will be called when there is a line in B that isn't in A
41
- def discard_b(event)
42
- add_last_lines unless @last == :discard_b
43
- @content << %Q|<tr><td></td><td></td><td><pre class="only_b">#{event.new_element}</pre></td><td>#{new_line}. </td></tr>\n|
42
+ def discard_b(event)
43
+ add_last_lines unless @last == :discard_b
44
+ @content << %Q|<tr><td></td><td></td><td><pre class="only_b">#{event.new_element}</pre></td><td>#{new_line}. </td></tr>\n|
44
45
 
45
- @last = :discard_b
46
- @new_line += 1
47
- end
46
+ @last = :discard_b
47
+ @new_line += 1
48
+ end
48
49
 
49
- def add_last_lines(n = 3)
50
- @content << %Q|<tr><td colspan="4">Next Change: </td></tr>\n|
51
- start = @last_lines.length - n
52
- start = 0 if start < 0
53
- start.upto @last_lines.length do |i|
54
- @content << @last_lines[i] if @last_lines[i]
50
+ def add_last_lines(n = 3)
51
+ @content << %Q|<tr><td colspan="4">Next Change: </td></tr>\n|
52
+ start = @last_lines.length - n
53
+ start = 0 if start < 0
54
+ start.upto @last_lines.length do |i|
55
+ @content << @last_lines[i] if @last_lines[i]
56
+ end
57
+ @last_lines = []
55
58
  end
56
- @last_lines = []
57
59
  end
58
-
59
60
  end
@@ -1,3 +1,3 @@
1
1
  module Palmister
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: palmister
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: