Sha256: e5d3e2b0dc8fada87762833d36b5484efe137e80cb6870cf775ce9ada576b830

Contents?: true

Size: 1.03 KB

Versions: 16

Compression:

Stored size: 1.03 KB

Contents

module Nucleon
module Event
class Regex < Plugin::Event
 
  #-----------------------------------------------------------------------------
  # Regular expression event interface
  
  def normalize(reload)
    super
    
    if get(:string)
      myself.pattern = delete(:string)
    end
  end
      
  #-----------------------------------------------------------------------------
  # Property accessors / modifiers
  
  def pattern(default = '')
    return get(:pattern, default)
  end
  
  #---
   
  def pattern=pattern
    set(:pattern, string(pattern))  
  end
  
  #-----------------------------------------------------------------------------
  # Operations
  
  def render
    return "#{name}:#{pattern}"
  end
  
  #---
   
  def check(source)
    if pattern.empty?
      logger.warn("Can not check regex pattern because it is empty")
    else
      success = source.match(/#{pattern}/)
      
      logger.debug("Checking regex event with pattern #{pattern}: #{success.inspect}")
      return success
    end
    return true
  end
end
end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
nucleon-0.1.19 lib/nucleon/event/regex.rb
nucleon-0.1.18 lib/nucleon/event/regex.rb
nucleon-0.1.17 lib/nucleon/event/regex.rb
nucleon-0.1.16 lib/nucleon/event/regex.rb
nucleon-0.1.15 lib/nucleon/event/regex.rb
nucleon-0.1.14 lib/nucleon/event/regex.rb
nucleon-0.1.13 lib/nucleon/event/regex.rb
nucleon-0.1.12 lib/nucleon/event/regex.rb
nucleon-0.1.11 lib/nucleon/event/regex.rb
nucleon-0.1.10 lib/nucleon/event/regex.rb
nucleon-0.1.9 lib/nucleon/event/regex.rb
nucleon-0.1.8 lib/nucleon/event/regex.rb
nucleon-0.1.7 lib/nucleon/event/regex.rb
nucleon-0.1.6 lib/nucleon/event/regex.rb
nucleon-0.1.5 lib/nucleon/event/regex.rb
nucleon-0.1.4 lib/nucleon/event/regex.rb