Class: Olelo::PatchFormatter

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Olelo::PatchParser::ChangeHandler

#change!, #line!

Methods inherited from Olelo::PatchParser::Handler

#finalize!, #line!

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 = {}) ⇒ PatchFormatter

Returns a new instance of PatchFormatter.



245
246
247
# File 'lib/olelo/patch.rb', line 245

def initialize(options = {})
  @options = options
end

Instance Attribute Details

#htmlObject (readonly)

Returns the value of attribute html.



243
244
245
# File 'lib/olelo/patch.rb', line 243

def html
  @html
end

Instance Method Details

#begin!(src, dst) ⇒ Object



254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
# File 'lib/olelo/patch.rb', line 254

def begin!(src, dst)
  super
  @html << '<table class="patch"'
  @html << %{ id="patch-#{@file}"} if @options[:links]
  if @options[:header]
    @html << '><thead><tr class="'
    if src && dst
      if src == dst
        @html << 'edit"><th>' << escape_html(src)
      else
        @html << 'move"><th>' << escape_html(src) << ' &#8594; ' << escape_html(dst)
      end
    elsif src
      @html << 'delete"><th>' << escape_html(src)
    else
      @html << 'new"><th>' << escape_html(dst)
    end
    @html << '</th></tr></thead><tbody><tr><td><pre>'
  else
    @html << '><tbody><tr><td><pre>'
  end
end

#binary!Object



283
284
285
# File 'lib/olelo/patch.rb', line 283

def binary!
  @html << escape_html(:binary_file.t)
end

#context!(text) ⇒ Object



307
308
309
# File 'lib/olelo/patch.rb', line 307

def context!(text)
  @html << escape_html(text)
end

#deleted!Object



287
288
289
# File 'lib/olelo/patch.rb', line 287

def deleted!
  @html << escape_html(:deleted.t)
end

#deletion!(text) ⇒ Object



303
304
305
# File 'lib/olelo/patch.rb', line 303

def deletion!(text)
  @html << '<del>' << escape_html(text) << '</del>'
end

#end!Object



277
278
279
280
281
# File 'lib/olelo/patch.rb', line 277

def end!
  super
  @html << '</pre></td></tr></tbody></table>'
  @file += 1
end

#initialize!Object



249
250
251
252
# File 'lib/olelo/patch.rb', line 249

def initialize!
  @html = ''
  @file = 0
end

#insertion!(text) ⇒ Object



299
300
301
# File 'lib/olelo/patch.rb', line 299

def insertion!(text)
  @html << '<ins>' << escape_html(text) << '</ins>'
end

#no_changes!Object



291
292
293
# File 'lib/olelo/patch.rb', line 291

def no_changes!
  @html << escape_html(:no_changes.t)
end

#separator!Object



295
296
297
# File 'lib/olelo/patch.rb', line 295

def separator!
  @html << '</pre></td></tr><tr><td><pre>'
end