32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
|
# File 'lib/cora/plugin.rb', line 32
def process(text)
listeners.each do |regex, entry|
if match = text.match(regex)
captures = match.captures
log "Matches #{regex}"
if entry[:within_state]
log "Applicable states: #{entry[:within_state].join(', ')}"
log "Current state: #{current_state}"
if entry[:within_state].include?(current_state)
log "Matches, executing block"
self.match_data = match
Fiber.new {
instance_exec(*captures, &entry[:block])
}.resume
return true
end
end
end
end
false
end
|