mail_address 1.3.0 → 1.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.github/workflows/test.yml +8 -1
- data/README.md +11 -13
- data/lib/mail_address/mail_address.rb +2 -2
- data/lib/mail_address/simple_parser.rb +4 -4
- data/lib/mail_address/version.rb +1 -1
- data/mail_address.gemspec +3 -1
- data/spec/spec_helper.rb +8 -10
- metadata +22 -8
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 6b0a0f8f9570bee5727e30b23812e5e453d134c7b0bd6600bea16d8a77e72d63
|
|
4
|
+
data.tar.gz: aedca5179b75e924bbc4257b51a62e9b0bb9bfaf5568a532006d1c0c327b3201
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: ce591ea386c87a8c7118f46db6ba4b503afe150f67ce8f9fd921f4c31470bba81fefba624d1ee377a6a2c46a5087df1ad9174c7abe79bf3702269809f2bbe4ae
|
|
7
|
+
data.tar.gz: e245562580351606d037c41a618629078ff4d89cd5f59deb3e7b10dd67907a7413d8186feb7cfe61beed77932f932cb726d1c630fc6e1fcdffbab7d2bffe30b7
|
data/.github/workflows/test.yml
CHANGED
|
@@ -12,7 +12,7 @@ jobs:
|
|
|
12
12
|
strategy:
|
|
13
13
|
fail-fast: false
|
|
14
14
|
matrix:
|
|
15
|
-
ruby-version: ['2.7', '3.0', '3.1', '3.2', '3.3']
|
|
15
|
+
ruby-version: ['2.7', '3.0', '3.1', '3.2', '3.3', '3.4']
|
|
16
16
|
|
|
17
17
|
steps:
|
|
18
18
|
- uses: actions/checkout@v4
|
|
@@ -25,3 +25,10 @@ jobs:
|
|
|
25
25
|
|
|
26
26
|
- name: Run tests
|
|
27
27
|
run: bundle exec rake spec
|
|
28
|
+
|
|
29
|
+
- name: Upload coverage to Coveralls
|
|
30
|
+
if: matrix.ruby-version == '3.4'
|
|
31
|
+
uses: coverallsapp/github-action@v2
|
|
32
|
+
with:
|
|
33
|
+
github-token: ${{ secrets.GITHUB_TOKEN }}
|
|
34
|
+
file: coverage/lcov/mail_address.lcov
|
data/README.md
CHANGED
|
@@ -1,20 +1,18 @@
|
|
|
1
|
-
# MailAddress [](https://github.com/kizashi1122/mail_address/actions/workflows/test.yml) [](https://coveralls.io/github/kizashi1122/mail_address?branch=master)
|
|
2
2
|
|
|
3
|
-
MailAddress is a port of Mail::Address
|
|
4
|
-
|
|
5
|
-
[mail](https://github.com/mikel/mail) is a great gem library. But some email addresses are unparsable with it. In perl, [Mail::Address](http://search.cpan.org/~markov/MailTools-2.14/lib/Mail/Address.pod) is a very common library to parse email addresses. Mail::Address conviniently can parse even non-RFC-compliant email addresses such as:
|
|
3
|
+
MailAddress is a Ruby port of Perl's [Mail::Address](http://search.cpan.org/~markov/MailTools-2.14/lib/Mail/Address.pod), a widely used email address parser. While the [mail](https://github.com/mikel/mail) gem is excellent, it cannot parse certain email addresses. Mail::Address can conveniently parse even non-RFC-compliant email addresses such as:
|
|
6
4
|
|
|
7
5
|
```rb
|
|
8
6
|
# mail gem cannot parse the following addresses
|
|
9
7
|
Ello [Do Not Reply] <do-not-reply@ello.co> # [, ] are not permitted according to RFC5322
|
|
10
8
|
大阪 太郎<osaka@example.com> # no whitespace just before `<`
|
|
11
9
|
```
|
|
12
|
-
|
|
10
|
+
However, Mail::Address (Perl) has some limitations that MailAddress addresses:
|
|
13
11
|
|
|
14
|
-
-
|
|
15
|
-
-
|
|
12
|
+
- Fails to parse correctly when the name part has no closing parenthesis.
|
|
13
|
+
- Over-modifies the name part.
|
|
16
14
|
|
|
17
|
-
Many people copy and paste email addresses from Excel or
|
|
15
|
+
Many people copy and paste email addresses from Excel or other spreadsheets, where addresses are separated by whitespace (tab or space). To handle this, MailAddress also includes a parser ported from the [Google Closure Library](https://github.com/google/closure-library/blob/master/closure/goog/format/emailaddress.js).
|
|
18
16
|
|
|
19
17
|
## Installation
|
|
20
18
|
|
|
@@ -34,8 +32,8 @@ Or install it yourself as:
|
|
|
34
32
|
|
|
35
33
|
## Usage
|
|
36
34
|
|
|
37
|
-
|
|
38
|
-
|
|
35
|
+
The API is almost the same as Mail::Address (Perl).
|
|
36
|
+
Note that the `comment` property was removed from the address class in v1.0.0, since most users are unlikely to need it.
|
|
39
37
|
|
|
40
38
|
```rb
|
|
41
39
|
require 'mail_address'
|
|
@@ -60,10 +58,10 @@ p addrs[1].user # "osaka"
|
|
|
60
58
|
p addrs[1].original # "大阪 太郎 <osaka@example.jp>"
|
|
61
59
|
```
|
|
62
60
|
|
|
63
|
-
`address.name` and `address.phrase` are almost same.
|
|
61
|
+
`address.name` and `address.phrase` are almost the same.
|
|
64
62
|
`address.phrase` keeps outermost double quotes or parentheses.
|
|
65
63
|
|
|
66
|
-
|
|
64
|
+
If you only need a single address, you can use `parse_first`.
|
|
67
65
|
|
|
68
66
|
```rb
|
|
69
67
|
line = "John Doe <john@example.com>"
|
|
@@ -83,7 +81,7 @@ addrs = MailAddress.parse_simple(line)
|
|
|
83
81
|
|
|
84
82
|
## Contributing
|
|
85
83
|
|
|
86
|
-
1. Fork it ( https://github.com/
|
|
84
|
+
1. Fork it ( https://github.com/kizashi1122/mail_address/fork )
|
|
87
85
|
2. Create your feature branch (`git checkout -b my-new-feature`)
|
|
88
86
|
3. Commit your changes (`git commit -am 'Add some feature'`)
|
|
89
87
|
4. Push to the branch (`git push origin my-new-feature`)
|
|
@@ -20,7 +20,7 @@ module MailAddress
|
|
|
20
20
|
end
|
|
21
21
|
|
|
22
22
|
phrase, address, objs = [], [], []
|
|
23
|
-
original = ''
|
|
23
|
+
original = ''.dup
|
|
24
24
|
depth, idx, end_paren_idx = 0, 0, 0
|
|
25
25
|
|
|
26
26
|
tokens = _tokenize lines
|
|
@@ -64,7 +64,7 @@ module MailAddress
|
|
|
64
64
|
objs.push(o) if o
|
|
65
65
|
depth = 0
|
|
66
66
|
end_paren_idx = 0
|
|
67
|
-
original = ''
|
|
67
|
+
original = ''.dup
|
|
68
68
|
_next = _find_next idx+1, tokens, len
|
|
69
69
|
elsif (depth > 0)
|
|
70
70
|
token.strip!
|
|
@@ -20,7 +20,7 @@ module MailAddress
|
|
|
20
20
|
|
|
21
21
|
def self.parse_simple(str)
|
|
22
22
|
result = []
|
|
23
|
-
email = token = ''
|
|
23
|
+
email = token = ''.dup
|
|
24
24
|
|
|
25
25
|
# Remove non-UNIX-style newlines that would otherwise cause getToken_ to
|
|
26
26
|
# choke. Remove multiple consecutive whitespace characters for the same
|
|
@@ -33,7 +33,7 @@ module MailAddress
|
|
|
33
33
|
if !is_empty_or_whitespace(email)
|
|
34
34
|
result.push(parse_internal(email))
|
|
35
35
|
end
|
|
36
|
-
email = ''
|
|
36
|
+
email = ''.dup
|
|
37
37
|
i += 1
|
|
38
38
|
next
|
|
39
39
|
end
|
|
@@ -49,8 +49,8 @@ module MailAddress
|
|
|
49
49
|
end
|
|
50
50
|
|
|
51
51
|
def self.parse_internal(addr)
|
|
52
|
-
name = ''
|
|
53
|
-
address = ''
|
|
52
|
+
name = ''.dup
|
|
53
|
+
address = ''.dup
|
|
54
54
|
i = 0
|
|
55
55
|
while i < addr.length
|
|
56
56
|
token = get_token(addr, i)
|
data/lib/mail_address/version.rb
CHANGED
data/mail_address.gemspec
CHANGED
|
@@ -11,6 +11,7 @@ Gem::Specification.new do |spec|
|
|
|
11
11
|
spec.description = "A practical mail address parser implemented based on Perl Module Mail::Address."
|
|
12
12
|
spec.homepage = "https://github.com/kizashi1122/mail_address"
|
|
13
13
|
spec.license = "MIT"
|
|
14
|
+
spec.required_ruby_version = '>= 2.7'
|
|
14
15
|
|
|
15
16
|
spec.files = `git ls-files -z`.split("\x0")
|
|
16
17
|
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
|
@@ -20,5 +21,6 @@ Gem::Specification.new do |spec|
|
|
|
20
21
|
spec.add_development_dependency "bundler", "~> 2.1"
|
|
21
22
|
spec.add_development_dependency "rake", "~> 13.0"
|
|
22
23
|
spec.add_development_dependency 'rspec', '~> 3.1', '>= 3.1.0'
|
|
23
|
-
spec.add_development_dependency "
|
|
24
|
+
spec.add_development_dependency "simplecov", "~> 0.22"
|
|
25
|
+
spec.add_development_dependency "simplecov-lcov", "~> 0.8"
|
|
24
26
|
end
|
data/spec/spec_helper.rb
CHANGED
|
@@ -1,18 +1,16 @@
|
|
|
1
1
|
require 'simplecov'
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
require '
|
|
5
|
-
|
|
6
|
-
add_filter '.bundle/'
|
|
7
|
-
end
|
|
3
|
+
if ENV['CI']
|
|
4
|
+
require 'simplecov-lcov'
|
|
5
|
+
SimpleCov::Formatter::LcovFormatter.config.report_with_single_file = true
|
|
8
6
|
SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter.new([
|
|
9
7
|
SimpleCov::Formatter::HTMLFormatter,
|
|
10
|
-
|
|
8
|
+
SimpleCov::Formatter::LcovFormatter
|
|
11
9
|
])
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
SimpleCov.start do
|
|
13
|
+
add_filter '.bundle/'
|
|
16
14
|
end
|
|
17
15
|
|
|
18
16
|
require 'rubygems'
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: mail_address
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.3.
|
|
4
|
+
version: 1.3.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Kizashi Nagata
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2026-02-
|
|
11
|
+
date: 2026-02-24 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: bundler
|
|
@@ -59,19 +59,33 @@ dependencies:
|
|
|
59
59
|
- !ruby/object:Gem::Version
|
|
60
60
|
version: 3.1.0
|
|
61
61
|
- !ruby/object:Gem::Dependency
|
|
62
|
-
name:
|
|
62
|
+
name: simplecov
|
|
63
63
|
requirement: !ruby/object:Gem::Requirement
|
|
64
64
|
requirements:
|
|
65
|
-
- - "
|
|
65
|
+
- - "~>"
|
|
66
66
|
- !ruby/object:Gem::Version
|
|
67
|
-
version: '0'
|
|
67
|
+
version: '0.22'
|
|
68
68
|
type: :development
|
|
69
69
|
prerelease: false
|
|
70
70
|
version_requirements: !ruby/object:Gem::Requirement
|
|
71
71
|
requirements:
|
|
72
|
-
- - "
|
|
72
|
+
- - "~>"
|
|
73
|
+
- !ruby/object:Gem::Version
|
|
74
|
+
version: '0.22'
|
|
75
|
+
- !ruby/object:Gem::Dependency
|
|
76
|
+
name: simplecov-lcov
|
|
77
|
+
requirement: !ruby/object:Gem::Requirement
|
|
78
|
+
requirements:
|
|
79
|
+
- - "~>"
|
|
80
|
+
- !ruby/object:Gem::Version
|
|
81
|
+
version: '0.8'
|
|
82
|
+
type: :development
|
|
83
|
+
prerelease: false
|
|
84
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
85
|
+
requirements:
|
|
86
|
+
- - "~>"
|
|
73
87
|
- !ruby/object:Gem::Version
|
|
74
|
-
version: '0'
|
|
88
|
+
version: '0.8'
|
|
75
89
|
description: A practical mail address parser implemented based on Perl Module Mail::Address.
|
|
76
90
|
email:
|
|
77
91
|
- kizashi1122@gmail.com
|
|
@@ -110,7 +124,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
110
124
|
requirements:
|
|
111
125
|
- - ">="
|
|
112
126
|
- !ruby/object:Gem::Version
|
|
113
|
-
version: '
|
|
127
|
+
version: '2.7'
|
|
114
128
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
115
129
|
requirements:
|
|
116
130
|
- - ">="
|