Class: MaRuKu::In::Markdown::SpanLevelParser::CharSourceDebug

Inherits:
Object
  • Object
show all
Defined in:
lib/amp-front/third_party/maruku/input/charsource.rb,
lib/amp-front/third_party/maruku/input/charsource.rb

Overview

A debug scanner that checks the correctness of both by comparing their output

Instance Method Summary collapse

Constructor Details

#initialize(s, parent) ⇒ CharSourceDebug

Returns a new instance of CharSourceDebug.



277
278
279
280
# File 'lib/amp-front/third_party/maruku/input/charsource.rb', line 277

def initialize(s, parent)
	@a = CharSourceManual.new(s, parent)
	@b = CharSourceStrscan.new(s, parent)
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(methodname, *args) ⇒ Object



282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
# File 'lib/amp-front/third_party/maruku/input/charsource.rb', line 282

def method_missing(methodname, *args)
	a_bef = @a.describe
	b_bef = @b.describe
	
	a = @a.send(methodname, *args)
	b = @b.send(methodname, *args)
	
#		if methodname == :describe
#			return a
#		end
	
	if a.kind_of? MatchData
		if a.to_a != b.to_a
			puts "called: #{methodname}(#{args})"
			puts "Matchdata:\na = #{a.to_a.inspect}\nb = #{b.to_a.inspect}"
			puts "AFTER: "+@a.describe
			puts "AFTER: "+@b.describe
			puts "BEFORE: "+a_bef
			puts "BEFORE: "+b_bef
			puts caller.join("\n")
			exit
		end
	else
		if a!=b
			puts "called: #{methodname}(#{args})"
			puts "Attenzione!\na = #{a.inspect}\nb = #{b.inspect}"
			puts ""+@a.describe
			puts ""+@b.describe
			puts caller.join("\n")
			exit
		end
	end
	
	if @a.cur_char != @b.cur_char
		puts "Fuori sincronia dopo #{methodname}(#{args})"
		puts ""+@a.describe
		puts ""+@b.describe
		exit
	end
	
	return a
end