diff --git a/bodyparts.gemspec b/bodyparts.gemspec index 4800165..82f1f47 100644 --- a/bodyparts.gemspec +++ b/bodyparts.gemspec @@ -5,7 +5,7 @@ Gem::Specification.new do |s| s.name = %q{bodyparts} - s.version = "0.1.0" + s.version = "0.1.1" s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version= s.authors = ["Max Ogden"] diff --git a/lib/bodyparts.rb b/lib/bodyparts.rb index ab0edfe..cf5e485 100644 --- a/lib/bodyparts.rb +++ b/lib/bodyparts.rb @@ -27,11 +27,13 @@ def self.find_reply_in(email) body = email.body.raw_source end - matches = [] - rules.each {|rule| matches << body.match(rule[:reply_delimiter])} - matches.compact! - match = matches.sort_by {|m| m.begin(0)}.first - new_message = body[0, match.begin(0)] - {:new_message => new_message.strip, :rest_of_thread => body[match.begin(0)..-1].strip} + matches = rules.map {|rule| body.match(rule[:reply_delimiter])}.compact! + unless matches.empty? + match = matches.sort_by {|m| m.begin(0)}.first + new_message = body[0, match.begin(0)] + {:new_message => new_message.strip, :rest_of_thread => body[match.begin(0)..-1].strip} + else + body + end end end \ No newline at end of file