Module: HrLite::MentionParser

Defined in:
lib/hr_lite/mention_parser.rb

Overview

Kudos messages carry mentions as visible plain-text markers:

"Great save @[Asha Rao](42) during the outage"

The picker inserts them; this parser extracts the ids server-side.

Constant Summary collapse

MARKER =
/@\[([^\]\n]{1,80})\]\((\d+)\)/
LIMIT =

notification-spam cap

10

Class Method Summary collapse

Class Method Details

.strip_markers(text) ⇒ Object

Bell/email bodies show "@Asha Rao", never the raw marker.



14
15
16
# File 'lib/hr_lite/mention_parser.rb', line 14

def self.strip_markers(text)
  text.to_s.gsub(MARKER) { "@#{Regexp.last_match(1)}" }
end

.user_ids(text) ⇒ Object



9
10
11
# File 'lib/hr_lite/mention_parser.rb', line 9

def self.user_ids(text)
  text.to_s.scan(MARKER).map { |(_name, id)| id.to_i }.uniq.first(LIMIT)
end