email_repair 0.2.0 → 1.0.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d81deac964185bcd7e75e10d32bb25af1e591250
4
- data.tar.gz: d8001888aac57df3008c145e4c5ea344fa760efa
3
+ metadata.gz: a87714cd558a4ce9a5ffe176b2dcfc379f2b771b
4
+ data.tar.gz: 8322e71366d7e121483b368cdfa83e235d413560
5
5
  SHA512:
6
- metadata.gz: ab4bce6136b84fae7ea1ab9c3cc8ca95b7e5dfc6e7053286cdc93b5eed6a26668c9ea6d1d9188024aceb7fd5e578327452e3cc91ec07f720dd0e56e16cce9a68
7
- data.tar.gz: cd70ccc7af7c13ec14628a58c36c0d964679b7a3ed8f5f4a08fb2f7273085d00935d27501af85a83c99017a38de66721a051848dfbda239c47ed0fe2f9555b49
6
+ metadata.gz: 8771c5ce3aa48dec34961e30285df05f14b1d99711772248f94306b23d573c5f5d4bc00ca8c1f9a5d50a2fa927b3504f55656176fb8664937a26249ecc6e93f7
7
+ data.tar.gz: 1c8f55a9e3e83df59cbb22d1994977455d904645701c2b685b48107985654e14a4a592d6ae3e518b04e56f5161334f6de279bd8cd1a89dd0c28be20d3dc153d5
@@ -42,10 +42,10 @@ module EmailRepair
42
42
  class CommonMistakeRepair
43
43
  def self.repair(email)
44
44
  email.downcase
45
- .gsub(/\s/, '')
46
- .sub(/@+/, '@')
47
- .sub(/\.c0m$/, '.com')
48
- .sub(/,[a-z]{2,24}$/) { |m| m.sub(',', '.') }
45
+ .gsub(/\s/, '')
46
+ .sub(/@+/, '@')
47
+ .sub(/\.c0m$/, '.com')
48
+ .sub(/,[a-z]{2,24}$/) { |m| m.sub(',', '.') }
49
49
  end
50
50
  end
51
51
 
@@ -58,7 +58,7 @@ module EmailRepair
58
58
 
59
59
  class CommonDomainRepair
60
60
  def self.repair(*)
61
- fail 'not implemented'
61
+ raise 'not implemented'
62
62
  end
63
63
 
64
64
  def self.common_domains
@@ -78,7 +78,7 @@ module EmailRepair
78
78
  class CommonDomainSuffixRepair < CommonDomainRepair
79
79
  def self.repair(email)
80
80
  common_domains.each do |name, suffix|
81
- email = "#{email}.#{suffix}" if email.match(/#{name}$/)
81
+ email = "#{email}.#{suffix}" if email.match?(/#{name}$/)
82
82
  end
83
83
  email
84
84
  end
@@ -100,7 +100,7 @@ module EmailRepair
100
100
  punc_regex = /[.#-]#{name}.#{suffix}$/
101
101
  if email.match(punc_regex)
102
102
  email = email.sub(punc_regex, "@#{name}.#{suffix}")
103
- elsif email.match(/[^@]#{name}.#{suffix}$/)
103
+ elsif email.match?(/[^@]#{name}.#{suffix}$/)
104
104
  email = email.sub(/#{name}.#{suffix}$/, "@#{name}.#{suffix}")
105
105
  end
106
106
  end
@@ -1,3 +1,3 @@
1
1
  module EmailRepair
2
- VERSION = '0.2.0'
2
+ VERSION = '1.0.0'.freeze
3
3
  end
@@ -2,12 +2,11 @@ require 'spec_helper'
2
2
 
3
3
  module EmailRepair
4
4
  describe Mechanic, '#repair_all' do
5
-
6
5
  it 'sanitizes an array of emails and returns bulk results' do
7
6
  mechanic = Mechanic.new
8
- salvageable_emails = %w(One@@two.com three@four.com one@twO.com)
9
- sanitized_emails = %w(one@two.com three@four.com)
10
- bad_emails = %w(bleep@blop plooooooop plooOOooop)
7
+ salvageable_emails = %w[One@@two.com three@four.com one@twO.com]
8
+ sanitized_emails = %w[one@two.com three@four.com]
9
+ bad_emails = %w[bleep@blop plooooooop plooOOooop]
11
10
 
12
11
  result = mechanic.repair_all(salvageable_emails + bad_emails)
13
12
  expect(result.sanitized_emails).to match_array sanitized_emails
@@ -23,7 +22,6 @@ module EmailRepair
23
22
  expect(result.sanitized_emails).to eq ['bleep@bloop.com']
24
23
  expect(result.invalid_emails).to eq []
25
24
  end
26
-
27
25
  end
28
26
 
29
27
  describe Mechanic, '#repair' do
@@ -34,7 +32,7 @@ module EmailRepair
34
32
  # http://www.stuffaboutcode.com/2013/02/validating-email-address-bloody.html
35
33
  # List of longest TLDs
36
34
  # https://jasontucker.blog/8945/what-is-the-longest-tld-you-can-get-for-a-domain-name
37
- good_emails = %w(
35
+ good_emails = %w[
38
36
  b@b.com
39
37
  lobatifricha@gmail.com
40
38
  mrspicy+whocares@whatevs.com
@@ -43,7 +41,7 @@ module EmailRepair
43
41
  b@mps.school
44
42
  b@kickstarter.engineering
45
43
  b@joyful.christmas
46
- )
44
+ ]
47
45
 
48
46
  good_emails.each do |good_email|
49
47
  expect(mechanic.repair(good_email)).to eq good_email
@@ -73,7 +71,7 @@ module EmailRepair
73
71
  end
74
72
 
75
73
  it 'adds missing .com' do
76
- no_com_mails = %w(blah@gmail bloo@yahoo blee@hotmail)
74
+ no_com_mails = %w[blah@gmail bloo@yahoo blee@hotmail]
77
75
  no_com_mails.each do |no_com_mail|
78
76
  expect(mechanic.repair(no_com_mail)).to eq "#{no_com_mail}.com"
79
77
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: email_repair
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Holman Gao
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2017-08-03 00:00:00.000000000 Z
12
+ date: 2018-03-28 00:00:00.000000000 Z
13
13
  dependencies: []
14
14
  description:
15
15
  email:
@@ -47,7 +47,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
47
47
  version: '0'
48
48
  requirements: []
49
49
  rubyforge_project:
50
- rubygems_version: 2.6.12
50
+ rubygems_version: 2.6.14
51
51
  signing_key:
52
52
  specification_version: 4
53
53
  summary: Library to fix invalid emails