Class: Protozoa::Views::Compare
- Inherits:
-
Layout
- Object
- Mustache
- Layout
- Protozoa::Views::Compare
show all
- Defined in:
- lib/amiba/frontend/views/compare.rb
Instance Attribute Summary collapse
Attributes inherited from Layout
#name
Instance Method Summary
collapse
Methods inherited from Layout
#edit_url, #escaped_name, #view_url
Instance Attribute Details
#diff ⇒ Object
Returns the value of attribute diff.
4
5
6
|
# File 'lib/amiba/frontend/views/compare.rb', line 4
def diff
@diff
end
|
#message ⇒ Object
Returns the value of attribute message.
4
5
6
|
# File 'lib/amiba/frontend/views/compare.rb', line 4
def message
@message
end
|
#page ⇒ Object
Returns the value of attribute page.
4
5
6
|
# File 'lib/amiba/frontend/views/compare.rb', line 4
def page
@page
end
|
#versions ⇒ Object
Returns the value of attribute versions.
4
5
6
|
# File 'lib/amiba/frontend/views/compare.rb', line 4
def versions
@versions
end
|
Instance Method Details
#after ⇒ Object
18
19
20
|
# File 'lib/amiba/frontend/views/compare.rb', line 18
def after
@versions[1][0..6]
end
|
#before ⇒ Object
14
15
16
|
# File 'lib/amiba/frontend/views/compare.rb', line 14
def before
@versions[0][0..6]
end
|
#left_diff_line_number(id, line) ⇒ Object
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
|
# File 'lib/amiba/frontend/views/compare.rb', line 52
def left_diff_line_number(id, line)
if line =~ /^@@/
m, li = *line.match(/\-(\d+)/)
@left_diff_line_number = li.to_i
@current_line_number = @left_diff_line_number
ret = '...'
elsif line[0] == ?-
ret = @left_diff_line_number.to_s
@left_diff_line_number += 1
@current_line_number = @left_diff_line_number - 1
elsif line[0] == ?+
ret = ' '
else
ret = @left_diff_line_number.to_s
@left_diff_line_number += 1
@current_line_number = @left_diff_line_number - 1
end
ret
end
|
#line_class(line) ⇒ Object
39
40
41
42
43
44
45
46
47
48
49
|
# File 'lib/amiba/frontend/views/compare.rb', line 39
def line_class(line)
if line =~ /^@@/
'gc'
elsif line =~ /^\+/
'gi'
elsif line =~ /^\-/
'gd'
else
''
end
end
|
#lines ⇒ Object
22
23
24
25
26
27
28
29
30
31
|
# File 'lib/amiba/frontend/views/compare.rb', line 22
def lines
lines = []
@diff.diff.split("\n")[2..-1].each_with_index do |line, line_index|
lines << { :line => line,
:class => line_class(line),
:ldln => left_diff_line_number(0, line),
:rdln => right_diff_line_number(0, line) }
end if @diff
lines
end
|
#path ⇒ Object
10
11
12
|
# File 'lib/amiba/frontend/views/compare.rb', line 10
def path
@page.path
end
|
#right_diff_line_number(id, line) ⇒ Object
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
|
# File 'lib/amiba/frontend/views/compare.rb', line 73
def right_diff_line_number(id, line)
if line =~ /^@@/
m, ri = *line.match(/\+(\d+)/)
@right_diff_line_number = ri.to_i
@current_line_number = @right_diff_line_number
ret = '...'
elsif line[0] == ?-
ret = ' '
elsif line[0] == ?+
ret = @right_diff_line_number.to_s
@right_diff_line_number += 1
@current_line_number = @right_diff_line_number - 1
else
ret = @right_diff_line_number.to_s
@right_diff_line_number += 1
@current_line_number = @right_diff_line_number - 1
end
ret
end
|
#show_revert ⇒ Object
33
34
35
|
# File 'lib/amiba/frontend/views/compare.rb', line 33
def show_revert
!@message
end
|
#title ⇒ Object
6
7
8
|
# File 'lib/amiba/frontend/views/compare.rb', line 6
def title
"Comparison of #{@page.title}"
end
|