-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #8 from Applifting/dev
Remove digits from name
- Loading branch information
Showing
5 changed files
with
18 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -59,7 +59,7 @@ ParseNameFromEmail.get_email_name('[email protected]') # => 'john-s | |
ParseNameFromEmail.parse_name_from('[email protected]') # => 'John Snow' | ||
ParseNameFromEmail.parse_name_from('[email protected]') # => 'John Snow' | ||
ParseNameFromEmail.parse_name_from('[email protected]') # => 'John Snow' | ||
ParseNameFromEmail.parse_name_from('[email protected]') # => 'John 123 Snow' | ||
ParseNameFromEmail.parse_name_from('[email protected]') # => 'John Snow' | ||
ParseNameFromEmail.parse_name_from('John Snow <[email protected]>') # => 'John Snow' | ||
|
||
# validating RFC format of email | ||
|
@@ -74,10 +74,10 @@ ParseNameFromEmail.parse_name_from('[email protected]') # => 'Joh | |
|
||
# batches | ||
string_with_emails = 'John Snow <[email protected]>, [email protected]' | ||
ParseNameFromEmail.parse_names_from(string_with_emails) # => ['John Snow', 'Alice 123'] | ||
ParseNameFromEmail.parse_names_from(string_with_emails) # => ['John Snow', 'Alice'] | ||
|
||
string_with_emails = '[email protected], [email protected]' | ||
ParseNameFromEmail.parse_names_from(string_with_emails) # => ['Lily (black)', 'Alice 123'] | ||
ParseNameFromEmail.parse_names_from(string_with_emails) # => ['Lily (black)', 'Alice'] | ||
|
||
# advanced parsing | ||
string_with_emails = '[email protected], [email protected]' | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
module ParseNameFromEmail | ||
VERSION = '0.1.1'.freeze | ||
VERSION = '0.2.0'.freeze | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -103,7 +103,7 @@ | |
|
||
it 'should parse by set of numbers' do | ||
email = '[email protected]' | ||
expect(parse_name_from_email.parse_name_from(email)).to eq 'Some 123 Email' | ||
expect(parse_name_from_email.parse_name_from(email)).to eq 'Some Email' | ||
end | ||
|
||
it 'should parse by big chars' do | ||
|
@@ -116,6 +116,11 @@ | |
expect(parse_name_from_email.parse_name_from(email)).to eq 'Some (email)' | ||
end | ||
|
||
it 'should friendly parse by \+ with numbers' do | ||
email = '[email protected]' | ||
expect(parse_name_from_email.parse_name_from(email)).to eq 'Some (email123)' | ||
end | ||
|
||
it 'should not friendly parse by \+ if not configured' do | ||
parse_name_from_email.configure do |config| | ||
config.friendly_plus_part = false | ||
|
@@ -141,17 +146,17 @@ | |
|
||
it 'should valid parse names from rfc emails, but some email is without name' do | ||
string_with_emails = 'John Snow <[email protected]>, Lily Black <[email protected]>, [email protected]' | ||
expect(parse_name_from_email.parse_names_from(string_with_emails)).to eq ['John Snow', 'Lily Black', 'Alice 123'] | ||
expect(parse_name_from_email.parse_names_from(string_with_emails)).to eq ['John Snow', 'Lily Black', 'Alice'] | ||
end | ||
|
||
it 'should valid parse names in non rfc format of emails' do | ||
string_with_emails = '[email protected], [email protected], [email protected]' | ||
expect(parse_name_from_email.parse_names_from(string_with_emails)).to eq ['John Snow', 'Lily Black', 'Alice 123'] | ||
expect(parse_name_from_email.parse_names_from(string_with_emails)).to eq ['John Snow', 'Lily Black', 'Alice'] | ||
end | ||
|
||
it 'should valid parse names in non rfc format of emails and any email is with \+' do | ||
string_with_emails = '[email protected], [email protected], [email protected]' | ||
expect(parse_name_from_email.parse_names_from(string_with_emails)).to eq ['John Snow', 'Lily (black)', 'Alice 123'] | ||
expect(parse_name_from_email.parse_names_from(string_with_emails)).to eq ['John Snow', 'Lily (black)', 'Alice'] | ||
end | ||
end | ||
|
||
|
@@ -172,21 +177,21 @@ | |
|
||
it 'should valid parse names from rfc emails, but some email is without name' do | ||
string_with_emails = 'John Snow <[email protected]>, Lily Black <[email protected]>, [email protected]' | ||
expected_hash = { '[email protected]' => 'John Snow', '[email protected]' => 'Lily Black', '[email protected]' => 'Alice 123' } | ||
expected_hash = { '[email protected]' => 'John Snow', '[email protected]' => 'Lily Black', '[email protected]' => 'Alice' } | ||
|
||
expect(parse_name_from_email.parse_emails_with_names_from(string_with_emails)).to eq expected_hash | ||
end | ||
|
||
it 'should valid parse names in non rfc format of emails' do | ||
string_with_emails = '[email protected], [email protected], [email protected]' | ||
expected_hash = { '[email protected]' => 'John Snow', '[email protected]' => 'Lily Black', '[email protected]' => 'Alice 123' } | ||
expected_hash = { '[email protected]' => 'John Snow', '[email protected]' => 'Lily Black', '[email protected]' => 'Alice' } | ||
|
||
expect(parse_name_from_email.parse_emails_with_names_from(string_with_emails)).to eq expected_hash | ||
end | ||
|
||
it 'should valid parse names in non rfc format of emails and any email is with \+' do | ||
string_with_emails = '[email protected], [email protected], [email protected]' | ||
expected_hash = { '[email protected]' => 'John Snow', '[email protected]' => 'Lily (black)', '[email protected]' => 'Alice 123' } | ||
expected_hash = { '[email protected]' => 'John Snow', '[email protected]' => 'Lily (black)', '[email protected]' => 'Alice' } | ||
|
||
expect(parse_name_from_email.parse_emails_with_names_from(string_with_emails)).to eq expected_hash | ||
end | ||
|