Class: Olelo::PatchSummary
Instance Attribute Summary collapse
Instance Method Summary
collapse
#context!, #deleted!, #line!, #no_changes!, #separator!
Methods included from Util
#check, #decode64, #deep_copy, #encode64, #escape, #escape_html, #escape_javascript, included, #md5, #no_cache?, #sha256, #titlecase, #truncate, #unescape, #unescape_backslash, #unescape_html, #valid_xml_chars?
Constructor Details
#initialize(options = {}) ⇒ PatchSummary
Returns a new instance of PatchSummary.
190
191
192
|
# File 'lib/olelo/patch.rb', line 190
def initialize(options = {})
@options = options
end
|
Instance Attribute Details
Returns the value of attribute html.
188
189
190
|
# File 'lib/olelo/patch.rb', line 188
def html
@html
end
|
Instance Method Details
#begin!(src, dst) ⇒ Object
204
205
206
207
|
# File 'lib/olelo/patch.rb', line 204
def begin!(src, dst)
@src, @dst = src, dst
@ins = @del = 0
end
|
225
226
227
|
# File 'lib/olelo/patch.rb', line 225
def binary!
@ins = @del = '-'
end
|
#deletion!(line) ⇒ Object
233
234
235
|
# File 'lib/olelo/patch.rb', line 233
def deletion!(line)
@del += 1
end
|
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
|
# File 'lib/olelo/patch.rb', line 209
def end!
if @src && @dst
if @src == @dst
@html << %{<tr class="edit"><td class="name">#{link(escape_html @src)}</td><td class="ins">#{@ins}</td><td class="del">#{@del}</td></tr>}
else
text = "#{escape_html @src} → #{escape_html @dst}"
@html << %{<tr class="move"><td class="name">#{link text}</td><td class="ins">#{@ins}</td><td class="del">#{@del}</td></tr>}
end
elsif @src
@html << %{<tr class="delete"><td class="name">#{link(escape_html @src)}</td><td class="ins">#{@ins}</td><td class="del">#{@del}</td></tr>}
else
@html << %{<tr class="new"><td class="name">#{link(escape_html @dst)}</td><td class="ins">#{@ins}</td><td class="del">#{@del}</td></tr>}
end
@file += 1
end
|
#finalize! ⇒ Object
199
200
201
202
|
# File 'lib/olelo/patch.rb', line 199
def finalize!
@html << %{<tr><td colspan="3">#{escape_html :no_changes.t}</td></tr>} if @file == 0
@html << "</tbody></table>"
end
|
#initialize! ⇒ Object
194
195
196
197
|
# File 'lib/olelo/patch.rb', line 194
def initialize!
@html = %{<table class="patch-summary"><thead><tr><th>#{escape_html :summary.t}</th><th class="ins">+</th><th class="del">-</th></tr></thead><tbody>}
@file = 0
end
|
#insertion!(line) ⇒ Object
229
230
231
|
# File 'lib/olelo/patch.rb', line 229
def insertion!(line)
@ins += 1
end
|
#link(text) ⇒ Object
237
238
239
|
# File 'lib/olelo/patch.rb', line 237
def link(text)
@options[:links] ? %{<a href="#patch-#{@file}">#{text}</a>} : text
end
|