extended_email_reply_parser 0.3.1 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 28188e56db27a6bcfda9da4b4e07b47d0b03f23b
4
- data.tar.gz: e0235a53fff960d3a28f249e9af03c0ec5fb61bf
3
+ metadata.gz: 945dbd97e90b02bd2f9ea5b0005867fb3dfa9fa3
4
+ data.tar.gz: 261767d15481a9c51862d623446f33da47681ed7
5
5
  SHA512:
6
- metadata.gz: b91056d876d0bdf911044af2d4fe42ab09f35bf2c15a2ed94d1038437b2aad3d549d50392539dead1e93ebc4b27c169d84e8551c6c2205f2e4babfdb5b87941e
7
- data.tar.gz: 251e200710616e637acab72fa755f5db39fb672c0c569a441ee07fba200c5c1143ea89b65631355f329b67d7794aac6d3ad72e67de96556725e2f82bb17ac313
6
+ metadata.gz: 330300aae38701945c25aba3eee8301c270a9d92bb369616f60b07ed4ff7f11c85ca61f13c0e033b468317ce8b6a7d1fee9315fc94cd35a2c9dd1bc855c268de
7
+ data.tar.gz: 5075415426c2c38c202e98213ed5cce1389dab8a17989e74e0e37e951c42f56d70a6d8558b8e27447480494675dc1509490d3f927fb00c88908cf9f20824d9f9
data/CHANGELOG.md CHANGED
@@ -10,6 +10,11 @@ This project adheres to [Semantic Versioning](http://semver.org/).
10
10
  ### Removed
11
11
  ### Fixed
12
12
 
13
+ ## ExtendedEmailReplyParser 0.4.0 (2016-11-14)
14
+ ### Added
15
+ - `Mail::Message#extract_html` extracts the html part as a counterpart for `Mail::Message#extract_text`. This is useful when an email has no text part.
16
+ - `Parsers::HtmlMails#parse` removes quotes indicated by `<div name="quote"></div>`.
17
+
13
18
  ## ExtendedEmailReplyParser 0.3.1 (2016-07-26)
14
19
  ### Fixed
15
20
  - Fixing issue "undefined `body_in_utf8` for `nil`".
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # ExtendedEmailReplyParser
2
2
 
3
- [![Join the chat at https://gitter.im/fiedl/extended_email_reply_parser](https://badges.gitter.im/fiedl/extended_email_reply_parser.svg)](https://gitter.im/fiedl/extended_email_reply_parser?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) [![Build Status](https://travis-ci.org/fiedl/extended_email_reply_parser.svg?branch=master)](https://travis-ci.org/fiedl/extended_email_reply_parser) [![Code Climate](https://codeclimate.com/github/fiedl/extended_email_reply_parser/badges/gpa.svg)](https://codeclimate.com/github/fiedl/extended_email_reply_parser) [![Test Coverage](https://codeclimate.com/github/fiedl/extended_email_reply_parser/badges/coverage.svg)](https://codeclimate.com/github/fiedl/extended_email_reply_parser/coverage) [![Gem Version](https://badge.fury.io/rb/extended_email_reply_parser.svg)](https://badge.fury.io/rb/extended_email_reply_parser) [![Documentation](https://img.shields.io/badge/documentation-rubydoc.info-blue.svg)](http://www.rubydoc.info/github/fiedl/extended_email_reply_parser/)
3
+ [![Join the chat at https://gitter.im/fiedl/extended_email_reply_parser](https://badges.gitter.im/fiedl/extended_email_reply_parser.svg)](https://gitter.im/fiedl/extended_email_reply_parser?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) [![Build Status](https://travis-ci.org/fiedl/extended_email_reply_parser.svg?branch=master)](https://travis-ci.org/fiedl/extended_email_reply_parser) [![Code Climate](https://codeclimate.com/github/fiedl/extended_email_reply_parser/badges/gpa.svg)](https://codeclimate.com/github/fiedl/extended_email_reply_parser) [![Test Coverage](https://codeclimate.com/github/fiedl/extended_email_reply_parser/badges/coverage.svg)](https://codeclimate.com/github/fiedl/extended_email_reply_parser/coverage) [![Gem Version](https://badge.fury.io/rb/extended_email_reply_parser.svg)](https://badge.fury.io/rb/extended_email_reply_parser) [![Dependency Status](https://gemnasium.com/badges/github.com/fiedl/extended_email_reply_parser.svg)](https://gemnasium.com/github.com/fiedl/extended_email_reply_parser) [![Documentation](https://img.shields.io/badge/documentation-rubydoc.info-blue.svg)](http://www.rubydoc.info/github/fiedl/extended_email_reply_parser/)
4
4
 
5
5
  When implementing a "reply or comment by email" feature, it's neccessary to filter out signatures and the previous conversation. One needs to extract just the relevant parts for the conversation or comment section of the application. This is what this [ruby](https://www.ruby-lang.org) gem helps to do.
6
6
 
@@ -24,7 +24,7 @@ Gem::Specification.new do |spec|
24
24
  spec.require_paths = ["lib"]
25
25
 
26
26
  spec.add_development_dependency "bundler", "~> 1.12"
27
- spec.add_development_dependency "rake", "~> 10.0"
27
+ spec.add_development_dependency "rake", ">= 10.0"
28
28
  spec.add_development_dependency "rspec", "~> 3.0"
29
29
  spec.add_development_dependency 'pry'
30
30
 
@@ -81,7 +81,7 @@ module ExtendedEmailReplyParser
81
81
  end
82
82
 
83
83
  def self.parse_message(message)
84
- self.parse_text message.extract_text
84
+ self.parse_text(message.extract_text || message.extract_html_body_content)
85
85
  end
86
86
 
87
87
  def self.parse_text(text)
@@ -21,6 +21,15 @@ module Mail
21
21
  (self.text_part || (self if self.content_type.include?('text/plain'))).try(:body_in_utf8)
22
22
  end
23
23
 
24
+ def extract_html
25
+ (self.html_part || (self if self.content_type.include?('text/html'))).try(:body_in_utf8)
26
+ end
27
+
28
+ def extract_html_body_content
29
+ # http://stackoverflow.com/a/356376/2066546
30
+ extract_html.match(/(.*<\s*body[^>]*>)(.*)(<\s*\/\s*body\s*\>.+)/m)[2] || extract_html
31
+ end
32
+
24
33
  def parse
25
34
  ExtendedEmailReplyParser.parse self
26
35
  end
@@ -0,0 +1,11 @@
1
+ module ExtendedEmailReplyParser
2
+ class Parsers::HtmlMails < Parsers::Base
3
+
4
+ def parse
5
+ except_in_visible_block_quotes do
6
+ hide_everything_after ["<div name=\"quote\""]
7
+ end
8
+ end
9
+
10
+ end
11
+ end
@@ -1,3 +1,3 @@
1
1
  module ExtendedEmailReplyParser
2
- VERSION = "0.3.1"
2
+ VERSION = "0.4.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: extended_email_reply_parser
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sebastian Fiedlschuster
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-07-25 00:00:00.000000000 Z
11
+ date: 2016-11-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -28,14 +28,14 @@ dependencies:
28
28
  name: rake
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - "~>"
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
33
  version: '10.0'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - "~>"
38
+ - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: '10.0'
41
41
  - !ruby/object:Gem::Dependency
@@ -149,6 +149,7 @@ files:
149
149
  - lib/extended_email_reply_parser/parsers.rb
150
150
  - lib/extended_email_reply_parser/parsers/base.rb
151
151
  - lib/extended_email_reply_parser/parsers/github.rb
152
+ - lib/extended_email_reply_parser/parsers/html_mails.rb
152
153
  - lib/extended_email_reply_parser/parsers/i18n_de.rb
153
154
  - lib/extended_email_reply_parser/parsers/i18n_en.rb
154
155
  - lib/extended_email_reply_parser/version.rb