Pull out RichMessageExtractor

No need to have it embedded
  when it should be unit tested!
This commit is contained in:
Matt Bridges 2013-07-18 18:34:07 -05:00
parent 519e3df4d4
commit ecdade33c3
3 changed files with 83 additions and 29 deletions

View file

@ -0,0 +1,28 @@
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