tracks/app/services/rich_message_extractor.rb
Matt Bridges ecdade33c3 Pull out RichMessageExtractor
No need to have it embedded
  when it should be unit tested!
2013-07-18 18:34:09 -05:00

28 lines
403 B
Ruby

class RichMessageExtractor
RICH_MESSAGE_FIELDS_REGEX = /([^>@]*)@?([^>]*)>?(.*)/
def initialize(message)
@message = message
end
def description
fields[1].strip
end
def context
fields[2].strip
end
def project
stripped = fields[3].strip
stripped.blank? ? nil : stripped
end
private
def fields
@message.match(RICH_MESSAGE_FIELDS_REGEX)
end
end