Class: RSTFILTER__

Inherits:
Object
  • Object
show all
Defined in:
lib/rstfilter/exec_setup.rb

Constant Summary collapse

SHOW_EXCEPTION =
ENV['RSTFILTER_SHOW_EXCEPTIONS']
@@records =
{}

Class Method Summary collapse

Class Method Details

.__rst_inspect__(val) ⇒ Object



21
22
23
24
25
26
27
# File 'lib/rstfilter/exec_setup.rb', line 21

def self.__rst_inspect__ val
  begin
    __rst_inspect_body__ val
  rescue Exception => e
    "!! __rst_inspect__ failed: #{e}"
  end
end

.__rst_inspect_body__(val) ⇒ Object



12
13
14
# File 'lib/rstfilter/exec_setup.rb', line 12

def self.__rst_inspect_body__ val
  ::PP.pp(val, '')
end

.clearObject



35
36
37
# File 'lib/rstfilter/exec_setup.rb', line 35

def self.clear
  @@records.clear
end

.record(begin_line, begin_col, end_line, end_col) ⇒ Object



50
51
52
53
54
55
56
57
# File 'lib/rstfilter/exec_setup.rb', line 50

def self.record begin_line, begin_col, end_line, end_col
  r = yield
  write begin_line, begin_col, end_line, end_col, r, nil
  r
rescue Exception => e
  write begin_line, begin_col, end_line, end_col, e, 'raised '
  raise
end

.recordsObject



31
32
33
# File 'lib/rstfilter/exec_setup.rb', line 31

def self.records
  @@records
end

.write(begin_line, begin_col, end_line, end_col, val, prefix) ⇒ Object



39
40
41
42
43
44
45
46
47
48
# File 'lib/rstfilter/exec_setup.rb', line 39

def self.write begin_line, begin_col, end_line, end_col, val, prefix
  # p [begin_line, begin_col, end_line, end_col]
  out, err = *[$__rst_filter_captured_out, $__rst_filter_captured_err].map{|o|
    str = o.string
    o.string = ''
    str
  } if $__rst_filter_captured_out

  @@records[[begin_line, begin_col, end_line, end_col]] = ["#{prefix}#{__rst_inspect__(val)}", out, err]
end