Sha256: 780bba2f9e62b0945c8331de97c9a68382cf65f31144bcef40f4832bb2625389

Contents?: true

Size: 471 Bytes

Versions: 2

Compression:

Stored size: 471 Bytes

Contents

# frozen_string_literal: true
module Thredded
  class AtNotificationExtractor
    # Matches the names in @joe, @"Joe 1", but not email@host.com.
    # The matched name is captured and may contain the surrounding quotes.
    MATCH_NAME_RE = /(?:^|[\s>])@([\w]+|"[\w ]+")(?=\W|$)/

    def initialize(content)
      @content = content
    end

    def run
      @content.scan(MATCH_NAME_RE).map(&:first).map { |m| m.start_with?('"') ? m[1..-2] : m }.uniq
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
thredded-0.6.0 app/commands/thredded/at_notification_extractor.rb
thredded-0.5.1 app/commands/thredded/at_notification_extractor.rb