Top Level Namespace

Instance Method Summary collapse

Instance Method Details

#update_testsObject



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'bin/regex_test', line 5

def update_tests
  options = 0
  options |= @chk_ext.active? ? Regexp::EXTENDED : 0
  #options |= @chk_line.active? ? Regexp::MULTILINE : 0
  options |= @chk_case.active? ? Regexp::IGNORECASE : 0
  @buf_tests.text.each_line.with_index do |test, idx|
    begin
      rex = Regexp.new(@e_regexp.text, options)
      if matches = test.match(rex)
        matches.to_a.each.with_index do |match, midx|
          m_start = @buf_tests.get_iter_at_line_offset(idx, matches.begin(midx))
          m_end = @buf_tests.get_iter_at_line_offset(idx, matches.end(midx))
          @buf_tests.apply_tag((midx+1).to_s, m_start, m_end)
        end
      else
        raise
      end
    rescue
      m_start = @buf_tests.get_iter_at_line(idx)
      m_end = @buf_tests.get_iter_at_line_offset(idx, test.length-1)
      @buf_tests.remove_all_tags(m_start, m_end)
    end
  end
end