reply_parser 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +17 -0
- data/.travis.yml +9 -0
- data/Gemfile +4 -0
- data/Guardfile +5 -0
- data/LICENSE.txt +22 -0
- data/README.md +32 -0
- data/Rakefile +1 -0
- data/lib/reply_parser.rb +21 -0
- data/lib/reply_parser/version.rb +3 -0
- data/reply_parser.gemspec +29 -0
- data/spec/reply_parser_spec.rb +31 -0
- metadata +157 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 77aa7bc69ff21fe41da489c6cda07bf338c41863
|
4
|
+
data.tar.gz: 195e3728e389ac7b297ed4f8d131a22153f32d3c
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 7bde707bc9dbf7aa8af699923e31dbfbe33862a6cdbdfda57102d2e291dc590c4a08bd56e67ae40026178b62be330fc6c16d914f9716e60448416472b2213579
|
7
|
+
data.tar.gz: 3b484af83414f946798825345679547d14f7ebb3a33bfa5445f4165c1edcc5cfef5d4a76549f18d9272d214df3e28c68fda8ee906c41115ca8009aa532b25a5d
|
data/.gitignore
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/Guardfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2013 Chris Oliver
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
# ReplyParser
|
2
|
+
|
3
|
+
A Rails 4.0 email reply parser for incoming emails.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
gem 'reply_parser'
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
Or install it yourself as:
|
16
|
+
|
17
|
+
$ gem install reply_parser
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
Using the Reply parser is pretty simple, just pass your email body
|
22
|
+
through the sanitize method.
|
23
|
+
|
24
|
+
```ReplyParser.sanitize(body)```
|
25
|
+
|
26
|
+
## Contributing
|
27
|
+
|
28
|
+
1. Fork it
|
29
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
30
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
31
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
32
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
data/lib/reply_parser.rb
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
require "reply_parser/version"
|
2
|
+
|
3
|
+
require "active_support/core_ext"
|
4
|
+
require "action_view/vendor/html-scanner/html/tokenizer"
|
5
|
+
require "action_view/vendor/html-scanner/html/node"
|
6
|
+
require "action_view/vendor/html-scanner/html/sanitizer"
|
7
|
+
|
8
|
+
module ReplyParser
|
9
|
+
def self.sanitize(html)
|
10
|
+
remove_reply HTML::FullSanitizer.new.sanitize(html)
|
11
|
+
end
|
12
|
+
|
13
|
+
def self.remove_reply(text)
|
14
|
+
case text
|
15
|
+
when /On .+ wrote:$/m
|
16
|
+
text[/(.+)On .+ wrote:$/m, 1].strip
|
17
|
+
else
|
18
|
+
text
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'reply_parser/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "reply_parser"
|
8
|
+
spec.version = ReplyParser::VERSION
|
9
|
+
spec.authors = ["Chris Oliver", "Chris Zempel"]
|
10
|
+
spec.email = ["excid3@gmail.com", "zempel@efeqdev.com"]
|
11
|
+
spec.description = %q{An email body reply parser}
|
12
|
+
spec.summary = %q{Email reply parser that strips out HTML tags and returns only the reply portion of an email}
|
13
|
+
spec.homepage = "http://github.com/excid3/reply_parser"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files`.split($/)
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_development_dependency "bundler", "~> 1.3"
|
22
|
+
spec.add_development_dependency "rake"
|
23
|
+
spec.add_development_dependency "rspec", "~> 2.14.1"
|
24
|
+
spec.add_development_dependency "guard", "~> 2.2.2"
|
25
|
+
spec.add_development_dependency "guard-rspec", "~> 4.0.3"
|
26
|
+
|
27
|
+
spec.add_dependency "actionpack", "~> 4.0.0"
|
28
|
+
spec.add_dependency "activesupport", "~> 4.0.0"
|
29
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
require 'reply_parser'
|
2
|
+
|
3
|
+
describe ReplyParser do
|
4
|
+
it "has a sanitize method" do
|
5
|
+
ReplyParser.should respond_to(:sanitize)
|
6
|
+
end
|
7
|
+
|
8
|
+
it "should return a string" do
|
9
|
+
ReplyParser.sanitize("").should eq("")
|
10
|
+
end
|
11
|
+
|
12
|
+
it "should return the same text" do
|
13
|
+
ReplyParser.sanitize("test").should eq("test")
|
14
|
+
end
|
15
|
+
|
16
|
+
it "should sanitize the input" do
|
17
|
+
ReplyParser.sanitize("<div>hey</div>").should eq("hey")
|
18
|
+
ReplyParser.sanitize("<div><span>hey</span></div>").should eq("hey")
|
19
|
+
ReplyParser.sanitize("<div><span>hey").should eq("hey")
|
20
|
+
end
|
21
|
+
|
22
|
+
it "returns only the content above the reply" do
|
23
|
+
ReplyParser.sanitize("""<div>This is my reply</div>
|
24
|
+
|
25
|
+
asdfljk
|
26
|
+
On Oct 15, 2013 at 8:35pm, Chris Oliver <excid3@gmail.com> wrote:"""
|
27
|
+
).should eq("""This is my reply
|
28
|
+
|
29
|
+
asdfljk""")
|
30
|
+
end
|
31
|
+
end
|
metadata
ADDED
@@ -0,0 +1,157 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: reply_parser
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Chris Oliver
|
8
|
+
- Chris Zempel
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2013-10-29 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: bundler
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
requirements:
|
18
|
+
- - ~>
|
19
|
+
- !ruby/object:Gem::Version
|
20
|
+
version: '1.3'
|
21
|
+
type: :development
|
22
|
+
prerelease: false
|
23
|
+
version_requirements: !ruby/object:Gem::Requirement
|
24
|
+
requirements:
|
25
|
+
- - ~>
|
26
|
+
- !ruby/object:Gem::Version
|
27
|
+
version: '1.3'
|
28
|
+
- !ruby/object:Gem::Dependency
|
29
|
+
name: rake
|
30
|
+
requirement: !ruby/object:Gem::Requirement
|
31
|
+
requirements:
|
32
|
+
- - '>='
|
33
|
+
- !ruby/object:Gem::Version
|
34
|
+
version: '0'
|
35
|
+
type: :development
|
36
|
+
prerelease: false
|
37
|
+
version_requirements: !ruby/object:Gem::Requirement
|
38
|
+
requirements:
|
39
|
+
- - '>='
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
version: '0'
|
42
|
+
- !ruby/object:Gem::Dependency
|
43
|
+
name: rspec
|
44
|
+
requirement: !ruby/object:Gem::Requirement
|
45
|
+
requirements:
|
46
|
+
- - ~>
|
47
|
+
- !ruby/object:Gem::Version
|
48
|
+
version: 2.14.1
|
49
|
+
type: :development
|
50
|
+
prerelease: false
|
51
|
+
version_requirements: !ruby/object:Gem::Requirement
|
52
|
+
requirements:
|
53
|
+
- - ~>
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
version: 2.14.1
|
56
|
+
- !ruby/object:Gem::Dependency
|
57
|
+
name: guard
|
58
|
+
requirement: !ruby/object:Gem::Requirement
|
59
|
+
requirements:
|
60
|
+
- - ~>
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: 2.2.2
|
63
|
+
type: :development
|
64
|
+
prerelease: false
|
65
|
+
version_requirements: !ruby/object:Gem::Requirement
|
66
|
+
requirements:
|
67
|
+
- - ~>
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: 2.2.2
|
70
|
+
- !ruby/object:Gem::Dependency
|
71
|
+
name: guard-rspec
|
72
|
+
requirement: !ruby/object:Gem::Requirement
|
73
|
+
requirements:
|
74
|
+
- - ~>
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: 4.0.3
|
77
|
+
type: :development
|
78
|
+
prerelease: false
|
79
|
+
version_requirements: !ruby/object:Gem::Requirement
|
80
|
+
requirements:
|
81
|
+
- - ~>
|
82
|
+
- !ruby/object:Gem::Version
|
83
|
+
version: 4.0.3
|
84
|
+
- !ruby/object:Gem::Dependency
|
85
|
+
name: actionpack
|
86
|
+
requirement: !ruby/object:Gem::Requirement
|
87
|
+
requirements:
|
88
|
+
- - ~>
|
89
|
+
- !ruby/object:Gem::Version
|
90
|
+
version: 4.0.0
|
91
|
+
type: :runtime
|
92
|
+
prerelease: false
|
93
|
+
version_requirements: !ruby/object:Gem::Requirement
|
94
|
+
requirements:
|
95
|
+
- - ~>
|
96
|
+
- !ruby/object:Gem::Version
|
97
|
+
version: 4.0.0
|
98
|
+
- !ruby/object:Gem::Dependency
|
99
|
+
name: activesupport
|
100
|
+
requirement: !ruby/object:Gem::Requirement
|
101
|
+
requirements:
|
102
|
+
- - ~>
|
103
|
+
- !ruby/object:Gem::Version
|
104
|
+
version: 4.0.0
|
105
|
+
type: :runtime
|
106
|
+
prerelease: false
|
107
|
+
version_requirements: !ruby/object:Gem::Requirement
|
108
|
+
requirements:
|
109
|
+
- - ~>
|
110
|
+
- !ruby/object:Gem::Version
|
111
|
+
version: 4.0.0
|
112
|
+
description: An email body reply parser
|
113
|
+
email:
|
114
|
+
- excid3@gmail.com
|
115
|
+
- zempel@efeqdev.com
|
116
|
+
executables: []
|
117
|
+
extensions: []
|
118
|
+
extra_rdoc_files: []
|
119
|
+
files:
|
120
|
+
- .gitignore
|
121
|
+
- .travis.yml
|
122
|
+
- Gemfile
|
123
|
+
- Guardfile
|
124
|
+
- LICENSE.txt
|
125
|
+
- README.md
|
126
|
+
- Rakefile
|
127
|
+
- lib/reply_parser.rb
|
128
|
+
- lib/reply_parser/version.rb
|
129
|
+
- reply_parser.gemspec
|
130
|
+
- spec/reply_parser_spec.rb
|
131
|
+
homepage: http://github.com/excid3/reply_parser
|
132
|
+
licenses:
|
133
|
+
- MIT
|
134
|
+
metadata: {}
|
135
|
+
post_install_message:
|
136
|
+
rdoc_options: []
|
137
|
+
require_paths:
|
138
|
+
- lib
|
139
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
140
|
+
requirements:
|
141
|
+
- - '>='
|
142
|
+
- !ruby/object:Gem::Version
|
143
|
+
version: '0'
|
144
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
145
|
+
requirements:
|
146
|
+
- - '>='
|
147
|
+
- !ruby/object:Gem::Version
|
148
|
+
version: '0'
|
149
|
+
requirements: []
|
150
|
+
rubyforge_project:
|
151
|
+
rubygems_version: 2.1.4
|
152
|
+
signing_key:
|
153
|
+
specification_version: 4
|
154
|
+
summary: Email reply parser that strips out HTML tags and returns only the reply portion
|
155
|
+
of an email
|
156
|
+
test_files:
|
157
|
+
- spec/reply_parser_spec.rb
|