email_parser 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -0
- data/Gemfile.lock +1 -1
- data/README.md +1 -0
- data/email_parser.gemspec +1 -1
- data/lib/email_parser/version.rb +1 -1
- data/lib/email_parser.rb +8 -4
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4ea1a1988ef62756778d13c2151fbe9ca21d7543054d97bda23deafce3603e3c
|
4
|
+
data.tar.gz: d8f123352b5bfcaacc4b44e205ce5a5fe27ce3212344e92a9dff1f54454d45c2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7a372f31baebd0855edffef741e4fbf9235d9620e8f3f935618be4d7f05aaf2963f427fbae01f6c49cafe0fbc0ede544fce24bc70f60a08dec5fc84a3a59bfa4
|
7
|
+
data.tar.gz: 9957b4f39069be665c645074e4afc3527ded5da57c87bb30ca9da8580697f478bbb8319b08eca9d7306ad2b8c61bf5113839d8986d2b668d1b6e81af1095d3dc
|
data/CHANGELOG.md
CHANGED
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -37,6 +37,7 @@ EmailParser.valid?("test.@example.com", allow_local_end_with_dot: true) # => tru
|
|
37
37
|
## Parser options
|
38
38
|
|
39
39
|
- `allow_address_literal: true` allows `a@[127.0.0.1]` etc. (default: `false`)
|
40
|
+
- `allow_domain_label_begin_with_number: true` allows `a@123.com` etc.
|
40
41
|
- `allow_dot_sequence_in_local: true` allows `a..b@example.com` etc. (default: `false`)
|
41
42
|
- `allow_local_begin_with_dot: true` allows `.a@example.com` etc. (default: `false`)
|
42
43
|
- `allow_local_end_with_dot: true` allows `a.@example.com` etc. (default: `false`)
|
data/email_parser.gemspec
CHANGED
@@ -17,7 +17,7 @@ Gem::Specification.new do |spec|
|
|
17
17
|
|
18
18
|
spec.metadata["homepage_uri"] = spec.homepage
|
19
19
|
spec.metadata["source_code_uri"] = "https://github.com/labocho/email_parser"
|
20
|
-
spec.metadata["changelog_uri"] = "https://github.com/labocho/email_parser/master/CHANGELOG.md"
|
20
|
+
spec.metadata["changelog_uri"] = "https://github.com/labocho/email_parser/blob/master/CHANGELOG.md"
|
21
21
|
|
22
22
|
# Specify which files should be added to the gem when it is released.
|
23
23
|
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
data/lib/email_parser/version.rb
CHANGED
data/lib/email_parser.rb
CHANGED
@@ -21,7 +21,7 @@ class EmailParser
|
|
21
21
|
")+",
|
22
22
|
)
|
23
23
|
|
24
|
-
attr_reader :allow_address_literal, :allow_dot_sequence_in_local, :allow_local_begin_with_dot, :allow_local_end_with_dot
|
24
|
+
attr_reader :allow_address_literal, :allow_domain_label_begin_with_number, :allow_dot_sequence_in_local, :allow_local_begin_with_dot, :allow_local_end_with_dot
|
25
25
|
|
26
26
|
def self.parse(src, **options)
|
27
27
|
new(**options).parse(src)
|
@@ -31,10 +31,11 @@ class EmailParser
|
|
31
31
|
new(**options).valid?(src)
|
32
32
|
end
|
33
33
|
|
34
|
-
def initialize(allow_address_literal: false, allow_dot_sequence_in_local: false, allow_local_begin_with_dot: false, allow_local_end_with_dot: false)
|
34
|
+
def initialize(allow_address_literal: false, allow_domain_label_begin_with_number: false, allow_dot_sequence_in_local: false, allow_local_begin_with_dot: false, allow_local_end_with_dot: false)
|
35
35
|
@allow_address_literal = allow_address_literal
|
36
36
|
raise NotImplementedError("Sorry, `allow_address_literal == true` is not supported yet") if allow_address_literal
|
37
37
|
|
38
|
+
@allow_domain_label_begin_with_number = allow_domain_label_begin_with_number
|
38
39
|
@allow_dot_sequence_in_local = allow_dot_sequence_in_local
|
39
40
|
@allow_local_begin_with_dot = allow_local_begin_with_dot
|
40
41
|
@allow_local_end_with_dot = allow_local_end_with_dot
|
@@ -170,10 +171,13 @@ class EmailParser
|
|
170
171
|
|
171
172
|
def label(s)
|
172
173
|
buffer = ""
|
173
|
-
|
174
|
+
|
175
|
+
unless allow_domain_label_begin_with_number
|
176
|
+
return unless push!(buffer, s.scan(/[a-zA-Z]/))
|
177
|
+
end
|
174
178
|
|
175
179
|
push!(buffer, s.scan(/[a-zA-Z0-9]+/))
|
176
|
-
push!(buffer, s.scan(/(-[a-zA-Z0-9])+/))
|
180
|
+
push!(buffer, s.scan(/(-[a-zA-Z0-9]+)+/))
|
177
181
|
|
178
182
|
[:label, buffer]
|
179
183
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: email_parser
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- labocho
|
@@ -112,7 +112,7 @@ metadata:
|
|
112
112
|
allowed_push_host: https://rubygems.org
|
113
113
|
homepage_uri: https://github.com/labocho/email_parser
|
114
114
|
source_code_uri: https://github.com/labocho/email_parser
|
115
|
-
changelog_uri: https://github.com/labocho/email_parser/master/CHANGELOG.md
|
115
|
+
changelog_uri: https://github.com/labocho/email_parser/blob/master/CHANGELOG.md
|
116
116
|
post_install_message:
|
117
117
|
rdoc_options: []
|
118
118
|
require_paths:
|