emailist 0.0.7

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 16bf3422c88196a6793a874e65fa34c28be33011
4
+ data.tar.gz: 32123eb4c18e73e76af9394a877273ccbd4d349f
5
+ SHA512:
6
+ metadata.gz: 9fe690edead6847d43df9dcf6d2eddb081e8c8db0a1297312b7e5461ef383798769a024277a00673bcf37579412a1e77f9b56d5f1cb9874bef2f767178046dc5
7
+ data.tar.gz: a33d88b2f8979ae209a11ac8d0a5391a30d7c40765edc6b880cc6e8426aaf3cafdf0a2be469b48c1c98c444512422a8eb183cc3944572110d38624e62e84ec7c
data/.gitignore ADDED
@@ -0,0 +1,22 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
18
+ *.bundle
19
+ *.so
20
+ *.o
21
+ *.a
22
+ mkmf.log
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in email_list.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2015 Ethan Barron
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,70 @@
1
+ # Emailist
2
+
3
+ `emailist` is a wrapper around Ruby Array, and is meant to assist in managing a list of email addresses.
4
+
5
+ `emailist` automatically attempts to clean invalid emails as they're added, and maintains uniqueness of your list. This is good for parsing emails, where you may end up with some invalid characters, or extra, unwanted bit of text on the beginnings/ends of the emails). While there are some caveats using `emailist`, as long as you don't need and/or expect 100% accuracy, then you should be fine. `emailist` tries its hardest to adhere to the RFC specs for emails, and checks validity of TLDs against ICANN.
6
+
7
+ This is just a small project I built for myself. I was building a simple parser to grab emails from a bunch of files. I decided I'd pull it out into its own gem, as I can see it being useful in other cases. Anyway, the code could certainly be a *lot* better, I only spent a couple of hours on this this morning. I'd love to improve this further, so pull requests are **very** welcome.
8
+
9
+ ## Installation
10
+
11
+ Add this line to your application's Gemfile:
12
+
13
+ gem 'emailist'
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install emailist
22
+
23
+ ## Usage
24
+
25
+ Make sure you require...
26
+
27
+ require 'emailist'
28
+
29
+ Adding and removing emails is very easy:
30
+
31
+ emails = Emailist.new
32
+ emails.add('bob.jones@example.com')
33
+ => ['bob.jones@example.com']
34
+ emails.remove('bob.jones@example.com')
35
+ => []
36
+
37
+ Uniqueness is automatically maintained:
38
+
39
+ emails = Emailist.new
40
+ emails.add('fred.smith@example.com')
41
+ => ['fred.smith@example.com']
42
+ emails.add('fred.smith@example.com')
43
+ => ['fred.smith@example.com']
44
+
45
+ Invalid emails are attempted to be cleaned:
46
+
47
+ emails = Emailist.new
48
+ emails.add('.bob.jones@example.com')
49
+ => ['bob.jones@example.com']
50
+ emails.add('fred.smith@example.com.')
51
+ => ['fred.smith@example.com']
52
+
53
+ Finally, invalid TLDs raise `Emailist::InvalidTLD`:
54
+
55
+ emails = Emailist.new
56
+ emails.add('bob.jones@fooo.baar')
57
+ => # raises Emailist::InvalidTLD
58
+
59
+ ## Ideas For Improvement
60
+
61
+ 1. Some kind of "best-guess" algorithm that can take invalid TLDs and find the most likely intended TLD (e.g. I'm getting some emails from my parser that have an 'E', like 'bob.jones@blah.comE' -- this clearly is supposed to be '.com'). Perhaps Levenshtein distance could be useful for this.
62
+ 2. Ping email domains and raise an error when they're unresponsive. Not sure if this is a good idea, though. Might have some negative side effects that I'm not considering.
63
+
64
+ ## Contributing
65
+
66
+ 1. Fork it ( https://github.com/[my-github-username]/emailist/fork )
67
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
68
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
69
+ 4. Push to the branch (`git push origin my-new-feature`)
70
+ 5. Create a new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+
@@ -0,0 +1,816 @@
1
+ ABOGADO
2
+ AC
3
+ ACADEMY
4
+ ACCOUNTANTS
5
+ ACTIVE
6
+ ACTOR
7
+ AD
8
+ ADULT
9
+ AE
10
+ AERO
11
+ AF
12
+ AG
13
+ AGENCY
14
+ AI
15
+ AIRFORCE
16
+ AL
17
+ ALLFINANZ
18
+ ALSACE
19
+ AM
20
+ AMSTERDAM
21
+ AN
22
+ ANDROID
23
+ AO
24
+ AQ
25
+ AQUARELLE
26
+ AR
27
+ ARCHI
28
+ ARMY
29
+ ARPA
30
+ AS
31
+ ASIA
32
+ ASSOCIATES
33
+ AT
34
+ ATTORNEY
35
+ AU
36
+ AUCTION
37
+ AUDIO
38
+ AUTOS
39
+ AW
40
+ AX
41
+ AXA
42
+ AZ
43
+ BA
44
+ BAND
45
+ BANK
46
+ BAR
47
+ BARCLAYCARD
48
+ BARCLAYS
49
+ BARGAINS
50
+ BAYERN
51
+ BB
52
+ BD
53
+ BE
54
+ BEER
55
+ BERLIN
56
+ BEST
57
+ BF
58
+ BG
59
+ BH
60
+ BI
61
+ BID
62
+ BIKE
63
+ BINGO
64
+ BIO
65
+ BIZ
66
+ BJ
67
+ BLACK
68
+ BLACKFRIDAY
69
+ BLOOMBERG
70
+ BLUE
71
+ BM
72
+ BMW
73
+ BN
74
+ BNPPARIBAS
75
+ BO
76
+ BOO
77
+ BOUTIQUE
78
+ BR
79
+ BRUSSELS
80
+ BS
81
+ BT
82
+ BUDAPEST
83
+ BUILD
84
+ BUILDERS
85
+ BUSINESS
86
+ BUZZ
87
+ BV
88
+ BW
89
+ BY
90
+ BZ
91
+ BZH
92
+ CA
93
+ CAB
94
+ CAL
95
+ CAMERA
96
+ CAMP
97
+ CANCERRESEARCH
98
+ CANON
99
+ CAPETOWN
100
+ CAPITAL
101
+ CARAVAN
102
+ CARDS
103
+ CARE
104
+ CAREER
105
+ CAREERS
106
+ CARTIER
107
+ CASA
108
+ CASH
109
+ CAT
110
+ CATERING
111
+ CC
112
+ CD
113
+ CENTER
114
+ CEO
115
+ CERN
116
+ CF
117
+ CG
118
+ CH
119
+ CHANNEL
120
+ CHAT
121
+ CHEAP
122
+ CHRISTMAS
123
+ CHROME
124
+ CHURCH
125
+ CI
126
+ CITIC
127
+ CITY
128
+ CK
129
+ CL
130
+ CLAIMS
131
+ CLEANING
132
+ CLICK
133
+ CLINIC
134
+ CLOTHING
135
+ CLUB
136
+ CM
137
+ CN
138
+ CO
139
+ COACH
140
+ CODES
141
+ COFFEE
142
+ COLLEGE
143
+ COLOGNE
144
+ COM
145
+ COMMUNITY
146
+ COMPANY
147
+ COMPUTER
148
+ CONDOS
149
+ CONSTRUCTION
150
+ CONSULTING
151
+ CONTRACTORS
152
+ COOKING
153
+ COOL
154
+ COOP
155
+ COUNTRY
156
+ CR
157
+ CREDIT
158
+ CREDITCARD
159
+ CRICKET
160
+ CRS
161
+ CRUISES
162
+ CU
163
+ CUISINELLA
164
+ CV
165
+ CW
166
+ CX
167
+ CY
168
+ CYMRU
169
+ CZ
170
+ DABUR
171
+ DAD
172
+ DANCE
173
+ DATING
174
+ DAY
175
+ DCLK
176
+ DE
177
+ DEALS
178
+ DEGREE
179
+ DELIVERY
180
+ DEMOCRAT
181
+ DENTAL
182
+ DENTIST
183
+ DESI
184
+ DESIGN
185
+ DEV
186
+ DIAMONDS
187
+ DIET
188
+ DIGITAL
189
+ DIRECT
190
+ DIRECTORY
191
+ DISCOUNT
192
+ DJ
193
+ DK
194
+ DM
195
+ DNP
196
+ DO
197
+ DOCS
198
+ DOMAINS
199
+ DOOSAN
200
+ DURBAN
201
+ DVAG
202
+ DZ
203
+ EAT
204
+ EC
205
+ EDU
206
+ EDUCATION
207
+ EE
208
+ EG
209
+ EMAIL
210
+ EMERCK
211
+ ENERGY
212
+ ENGINEER
213
+ ENGINEERING
214
+ ENTERPRISES
215
+ EQUIPMENT
216
+ ER
217
+ ES
218
+ ESQ
219
+ ESTATE
220
+ ET
221
+ EU
222
+ EUROVISION
223
+ EUS
224
+ EVENTS
225
+ EVERBANK
226
+ EXCHANGE
227
+ EXPERT
228
+ EXPOSED
229
+ FAIL
230
+ FARM
231
+ FASHION
232
+ FEEDBACK
233
+ FI
234
+ FINANCE
235
+ FINANCIAL
236
+ FIRMDALE
237
+ FISH
238
+ FISHING
239
+ FIT
240
+ FITNESS
241
+ FJ
242
+ FK
243
+ FLIGHTS
244
+ FLORIST
245
+ FLOWERS
246
+ FLSMIDTH
247
+ FLY
248
+ FM
249
+ FO
250
+ FOO
251
+ FORSALE
252
+ FOUNDATION
253
+ FR
254
+ FRL
255
+ FROGANS
256
+ FUND
257
+ FURNITURE
258
+ FUTBOL
259
+ GA
260
+ GAL
261
+ GALLERY
262
+ GARDEN
263
+ GB
264
+ GBIZ
265
+ GD
266
+ GE
267
+ GENT
268
+ GF
269
+ GG
270
+ GGEE
271
+ GH
272
+ GI
273
+ GIFT
274
+ GIFTS
275
+ GIVES
276
+ GL
277
+ GLASS
278
+ GLE
279
+ GLOBAL
280
+ GLOBO
281
+ GM
282
+ GMAIL
283
+ GMO
284
+ GMX
285
+ GN
286
+ GOOG
287
+ GOOGLE
288
+ GOP
289
+ GOV
290
+ GP
291
+ GQ
292
+ GR
293
+ GRAPHICS
294
+ GRATIS
295
+ GREEN
296
+ GRIPE
297
+ GS
298
+ GT
299
+ GU
300
+ GUIDE
301
+ GUITARS
302
+ GURU
303
+ GW
304
+ GY
305
+ HAMBURG
306
+ HANGOUT
307
+ HAUS
308
+ HEALTHCARE
309
+ HELP
310
+ HERE
311
+ HERMES
312
+ HIPHOP
313
+ HIV
314
+ HK
315
+ HM
316
+ HN
317
+ HOLDINGS
318
+ HOLIDAY
319
+ HOMES
320
+ HORSE
321
+ HOST
322
+ HOSTING
323
+ HOUSE
324
+ HOW
325
+ HR
326
+ HT
327
+ HU
328
+ IBM
329
+ ID
330
+ IE
331
+ IFM
332
+ IL
333
+ IM
334
+ IMMO
335
+ IMMOBILIEN
336
+ IN
337
+ INDUSTRIES
338
+ INFO
339
+ ING
340
+ INK
341
+ INSTITUTE
342
+ INSURE
343
+ INT
344
+ INTERNATIONAL
345
+ INVESTMENTS
346
+ IO
347
+ IQ
348
+ IR
349
+ IRISH
350
+ IS
351
+ IT
352
+ IWC
353
+ JCB
354
+ JE
355
+ JETZT
356
+ JM
357
+ JO
358
+ JOBS
359
+ JOBURG
360
+ JP
361
+ JUEGOS
362
+ KAUFEN
363
+ KDDI
364
+ KE
365
+ KG
366
+ KH
367
+ KI
368
+ KIM
369
+ KITCHEN
370
+ KIWI
371
+ KM
372
+ KN
373
+ KOELN
374
+ KP
375
+ KR
376
+ KRD
377
+ KRED
378
+ KW
379
+ KY
380
+ KYOTO
381
+ KZ
382
+ LA
383
+ LACAIXA
384
+ LAND
385
+ LAT
386
+ LATROBE
387
+ LAWYER
388
+ LB
389
+ LC
390
+ LDS
391
+ LEASE
392
+ LEGAL
393
+ LGBT
394
+ LI
395
+ LIDL
396
+ LIFE
397
+ LIGHTING
398
+ LIMITED
399
+ LIMO
400
+ LINK
401
+ LK
402
+ LOANS
403
+ LONDON
404
+ LOTTE
405
+ LOTTO
406
+ LR
407
+ LS
408
+ LT
409
+ LTDA
410
+ LU
411
+ LUXE
412
+ LUXURY
413
+ LV
414
+ LY
415
+ MA
416
+ MADRID
417
+ MAISON
418
+ MANAGEMENT
419
+ MANGO
420
+ MARKET
421
+ MARKETING
422
+ MARRIOTT
423
+ MC
424
+ MD
425
+ ME
426
+ MEDIA
427
+ MEET
428
+ MELBOURNE
429
+ MEME
430
+ MEMORIAL
431
+ MENU
432
+ MG
433
+ MH
434
+ MIAMI
435
+ MIL
436
+ MINI
437
+ MK
438
+ ML
439
+ MM
440
+ MN
441
+ MO
442
+ MOBI
443
+ MODA
444
+ MOE
445
+ MONASH
446
+ MONEY
447
+ MORMON
448
+ MORTGAGE
449
+ MOSCOW
450
+ MOTORCYCLES
451
+ MOV
452
+ MP
453
+ MQ
454
+ MR
455
+ MS
456
+ MT
457
+ MU
458
+ MUSEUM
459
+ MV
460
+ MW
461
+ MX
462
+ MY
463
+ MZ
464
+ NA
465
+ NAGOYA
466
+ NAME
467
+ NAVY
468
+ NC
469
+ NE
470
+ NET
471
+ NETWORK
472
+ NEUSTAR
473
+ NEW
474
+ NEXUS
475
+ NF
476
+ NG
477
+ NGO
478
+ NHK
479
+ NI
480
+ NINJA
481
+ NL
482
+ NO
483
+ NP
484
+ NR
485
+ NRA
486
+ NRW
487
+ NTT
488
+ NU
489
+ NYC
490
+ NZ
491
+ OKINAWA
492
+ OM
493
+ ONE
494
+ ONG
495
+ ONL
496
+ OOO
497
+ ORG
498
+ ORGANIC
499
+ OSAKA
500
+ OTSUKA
501
+ OVH
502
+ PA
503
+ PARIS
504
+ PARTNERS
505
+ PARTS
506
+ PARTY
507
+ PE
508
+ PF
509
+ PG
510
+ PH
511
+ PHARMACY
512
+ PHOTO
513
+ PHOTOGRAPHY
514
+ PHOTOS
515
+ PHYSIO
516
+ PICS
517
+ PICTURES
518
+ PINK
519
+ PIZZA
520
+ PK
521
+ PL
522
+ PLACE
523
+ PLUMBING
524
+ PM
525
+ PN
526
+ POHL
527
+ POKER
528
+ PORN
529
+ POST
530
+ PR
531
+ PRAXI
532
+ PRESS
533
+ PRO
534
+ PROD
535
+ PRODUCTIONS
536
+ PROF
537
+ PROPERTIES
538
+ PROPERTY
539
+ PS
540
+ PT
541
+ PUB
542
+ PW
543
+ PY
544
+ QA
545
+ QPON
546
+ QUEBEC
547
+ RE
548
+ REALTOR
549
+ RECIPES
550
+ RED
551
+ REHAB
552
+ REISE
553
+ REISEN
554
+ REIT
555
+ REN
556
+ RENTALS
557
+ REPAIR
558
+ REPORT
559
+ REPUBLICAN
560
+ REST
561
+ RESTAURANT
562
+ REVIEWS
563
+ RICH
564
+ RIO
565
+ RIP
566
+ RO
567
+ ROCKS
568
+ RODEO
569
+ RS
570
+ RSVP
571
+ RU
572
+ RUHR
573
+ RW
574
+ RYUKYU
575
+ SA
576
+ SAARLAND
577
+ SALE
578
+ SAMSUNG
579
+ SARL
580
+ SB
581
+ SC
582
+ SCA
583
+ SCB
584
+ SCHMIDT
585
+ SCHULE
586
+ SCHWARZ
587
+ SCIENCE
588
+ SCOT
589
+ SD
590
+ SE
591
+ SERVICES
592
+ SEW
593
+ SEXY
594
+ SG
595
+ SH
596
+ SHIKSHA
597
+ SHOES
598
+ SHRIRAM
599
+ SI
600
+ SINGLES
601
+ SJ
602
+ SK
603
+ SKY
604
+ SL
605
+ SM
606
+ SN
607
+ SO
608
+ SOCIAL
609
+ SOFTWARE
610
+ SOHU
611
+ SOLAR
612
+ SOLUTIONS
613
+ SOY
614
+ SPACE
615
+ SPIEGEL
616
+ SR
617
+ ST
618
+ STYLE
619
+ SU
620
+ SUPPLIES
621
+ SUPPLY
622
+ SUPPORT
623
+ SURF
624
+ SURGERY
625
+ SUZUKI
626
+ SV
627
+ SX
628
+ SY
629
+ SYDNEY
630
+ SYSTEMS
631
+ SZ
632
+ TAIPEI
633
+ TATAR
634
+ TATTOO
635
+ TAX
636
+ TC
637
+ TD
638
+ TECHNOLOGY
639
+ TEL
640
+ TEMASEK
641
+ TENNIS
642
+ TF
643
+ TG
644
+ TH
645
+ TIENDA
646
+ TIPS
647
+ TIRES
648
+ TIROL
649
+ TJ
650
+ TK
651
+ TL
652
+ TM
653
+ TN
654
+ TO
655
+ TODAY
656
+ TOKYO
657
+ TOOLS
658
+ TOP
659
+ TOSHIBA
660
+ TOWN
661
+ TOYS
662
+ TP
663
+ TR
664
+ TRADE
665
+ TRAINING
666
+ TRAVEL
667
+ TRUST
668
+ TT
669
+ TUI
670
+ TV
671
+ TW
672
+ TZ
673
+ UA
674
+ UG
675
+ UK
676
+ UNIVERSITY
677
+ UNO
678
+ UOL
679
+ US
680
+ UY
681
+ UZ
682
+ VA
683
+ VACATIONS
684
+ VC
685
+ VE
686
+ VEGAS
687
+ VENTURES
688
+ VERSICHERUNG
689
+ VET
690
+ VG
691
+ VI
692
+ VIAJES
693
+ VIDEO
694
+ VILLAS
695
+ VISION
696
+ VLAANDEREN
697
+ VN
698
+ VODKA
699
+ VOTE
700
+ VOTING
701
+ VOTO
702
+ VOYAGE
703
+ VU
704
+ WALES
705
+ WANG
706
+ WATCH
707
+ WEBCAM
708
+ WEBSITE
709
+ WED
710
+ WEDDING
711
+ WF
712
+ WHOSWHO
713
+ WIEN
714
+ WIKI
715
+ WILLIAMHILL
716
+ WME
717
+ WORK
718
+ WORKS
719
+ WORLD
720
+ WS
721
+ WTC
722
+ WTF
723
+ XN--1QQW23A
724
+ XN--3BST00M
725
+ XN--3DS443G
726
+ XN--3E0B707E
727
+ XN--45BRJ9C
728
+ XN--45Q11C
729
+ XN--4GBRIM
730
+ XN--55QW42G
731
+ XN--55QX5D
732
+ XN--6FRZ82G
733
+ XN--6QQ986B3XL
734
+ XN--80ADXHKS
735
+ XN--80AO21A
736
+ XN--80ASEHDB
737
+ XN--80ASWG
738
+ XN--90A3AC
739
+ XN--B4W605FERD
740
+ XN--C1AVG
741
+ XN--CG4BKI
742
+ XN--CLCHC0EA0B2G2A9GCD
743
+ XN--CZR694B
744
+ XN--CZRS0T
745
+ XN--CZRU2D
746
+ XN--D1ACJ3B
747
+ XN--D1ALF
748
+ XN--FIQ228C5HS
749
+ XN--FIQ64B
750
+ XN--FIQS8S
751
+ XN--FIQZ9S
752
+ XN--FLW351E
753
+ XN--FPCRJ9C3D
754
+ XN--FZC2C9E2C
755
+ XN--GECRJ9C
756
+ XN--H2BRJ9C
757
+ XN--HXT814E
758
+ XN--I1B6B1A6A2E
759
+ XN--IO0A7I
760
+ XN--J1AMH
761
+ XN--J6W193G
762
+ XN--KPRW13D
763
+ XN--KPRY57D
764
+ XN--KPUT3I
765
+ XN--L1ACC
766
+ XN--LGBBAT1AD8J
767
+ XN--MGB9AWBF
768
+ XN--MGBA3A4F16A
769
+ XN--MGBAAM7A8H
770
+ XN--MGBAB2BD
771
+ XN--MGBAYH7GPA
772
+ XN--MGBBH1A71E
773
+ XN--MGBC0A9AZCG
774
+ XN--MGBERP4A5D4AR
775
+ XN--MGBX4CD0AB
776
+ XN--NGBC5AZD
777
+ XN--NODE
778
+ XN--NQV7F
779
+ XN--NQV7FS00EMA
780
+ XN--O3CW4H
781
+ XN--OGBPF8FL
782
+ XN--P1ACF
783
+ XN--P1AI
784
+ XN--PGBS0DH
785
+ XN--Q9JYB4C
786
+ XN--QCKA1PMC
787
+ XN--RHQV96G
788
+ XN--S9BRJ9C
789
+ XN--SES554G
790
+ XN--UNUP4Y
791
+ XN--VERMGENSBERATER-CTB
792
+ XN--VERMGENSBERATUNG-PWB
793
+ XN--VHQUV
794
+ XN--WGBH1C
795
+ XN--WGBL6A
796
+ XN--XHQ521B
797
+ XN--XKC2AL3HYE2A
798
+ XN--XKC2DL3A5EE0H
799
+ XN--YFRO4I67O
800
+ XN--YGBI2AMMX
801
+ XN--ZFR164B
802
+ XXX
803
+ XYZ
804
+ YACHTS
805
+ YANDEX
806
+ YE
807
+ YOGA
808
+ YOKOHAMA
809
+ YOUTUBE
810
+ YT
811
+ ZA
812
+ ZIP
813
+ ZM
814
+ ZONE
815
+ ZUERICH
816
+ ZW
data/emailist.gemspec ADDED
@@ -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 'emailist/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "emailist"
8
+ spec.version = Emailist::VERSION
9
+ spec.authors = ["Ethan Barron"]
10
+ spec.email = ["inkybro@gmail.com"]
11
+ spec.summary = %q{Wrapper around Ruby's Array class for managing lists of email addresses.}
12
+ spec.description = %q{
13
+ Provides a Ruby array wrapper that helps in managing a list of
14
+ email addresses. Automagically uniquifies the list, as well as
15
+ attempting to clean invalid emails.
16
+ }
17
+ spec.homepage = ""
18
+ spec.license = "MIT"
19
+
20
+ spec.files = `git ls-files -z`.split("\x0")
21
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
22
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
23
+ spec.require_paths = ["lib"]
24
+
25
+ spec.add_development_dependency "bundler", "~> 1.6"
26
+ spec.add_development_dependency "rake"
27
+ spec.add_development_dependency "rspec"
28
+ spec.add_development_dependency "shoulda-matchers"
29
+ end
@@ -0,0 +1,3 @@
1
+ class Emailist < Array
2
+ class InvalidTLD < StandardError; end
3
+ end
@@ -0,0 +1,3 @@
1
+ class Emailist < Array
2
+ VERSION = "0.0.7"
3
+ end
data/lib/emailist.rb ADDED
@@ -0,0 +1,131 @@
1
+ require "emailist/version"
2
+ require "emailist/errors"
3
+
4
+ class Emailist < Array
5
+
6
+ VALID_TLDS = File.read(
7
+ File.expand_path(File.join(File.dirname(__FILE__), '..', 'data', 'valid_tlds.txt'))
8
+ ).lines.to_a.map {|tld| tld.gsub(/[^A-Z\-]/, '') }
9
+
10
+ INVALID_START_WITH = [
11
+ 'TO.', 'To.', 'E-mail', 'AS', 'TO:', 'To:'
12
+ ]
13
+
14
+ INVALID_END_WITH = [
15
+ '.TO', '.To', 'E'
16
+ ]
17
+
18
+ alias_method :_push, :push
19
+ def push(email)
20
+ _push(clean(email))
21
+ refresh!
22
+ end
23
+ #alias_method :<<, :push
24
+ #alias_method :add, :push
25
+
26
+ def <<(email)
27
+ push(email)
28
+ end
29
+
30
+ def add(email)
31
+ push(email)
32
+ end
33
+
34
+ alias_method :_unshift, :unshift
35
+ def unshift(email)
36
+ _unshift(clean(email))
37
+ refresh!
38
+ end
39
+
40
+ alias_method :_delete, :delete
41
+ def delete(email)
42
+ _delete(clean(email))
43
+ refresh!
44
+ end
45
+
46
+ def remove(email)
47
+ delete(email)
48
+ end
49
+
50
+ alias_method :_include?, :include?
51
+ def include?(email)
52
+ _include?(clean(email))
53
+ end
54
+
55
+ private
56
+
57
+ def refresh!
58
+ _delete(nil)
59
+ uniq!
60
+ return self
61
+ end
62
+
63
+ def clean(email)
64
+ return if email.nil?
65
+
66
+ # strip email first
67
+ email = email.strip
68
+
69
+ # convert >1 consecutive period to 1 period
70
+ email.gsub!(/\.{2,}/, '.')
71
+
72
+ # remove invalid start/end with
73
+ INVALID_START_WITH.each do |with|
74
+ email = email[(with.length)..email.length-1] if email.start_with?(with)
75
+ end
76
+ INVALID_END_WITH.each do |with|
77
+ email = email[0..(email.length-with.length)] if email.end_with?(with)
78
+ end
79
+
80
+ # get local/domain parts separated
81
+ local, domain = email.split('@')
82
+
83
+ # remove leading/trailing periods
84
+ local = local[1..local.length-1] if local[0] == '.'
85
+ domain = domain[0..domain.length-2] if domain[domain.length-1] == '.'
86
+
87
+ # remove invalid leading text
88
+ new_local = ''
89
+ local.chars.each do |char|
90
+ if char =~ /[A-Z0-9!#\$%&'\*\+\-\/=\?\^_`\{\|\}~\.]/i
91
+ new_local += char
92
+ else
93
+ new_local = ''
94
+ end
95
+ end
96
+ local = new_local
97
+
98
+ # remove invalid trailing text
99
+ new_domain = ''
100
+ domain.chars.each do |char|
101
+ if char =~ /[A-Z0-9\-\.]/i
102
+ new_domain += char
103
+ else
104
+ break
105
+ end
106
+ end
107
+ domain = new_domain
108
+
109
+ # remove invalid TLDs
110
+ domain_split = domain.split('.').reverse
111
+ if !VALID_TLDS.include?(domain_split.first)
112
+ new_domain = []
113
+ found_tld = false
114
+ domain_split.each do |part|
115
+ if !found_tld && VALID_TLDS.include?(part.strip.upcase)
116
+ found_tld = true
117
+ new_domain.unshift(part)
118
+ elsif found_tld
119
+ new_domain.unshift(part)
120
+ end
121
+ end
122
+ raise Emailist::InvalidTLD if !found_tld
123
+ else
124
+ new_domain = domain_split.reverse
125
+ end
126
+ domain = new_domain.join('.')
127
+
128
+ "#{local}@#{domain}".downcase
129
+ end
130
+
131
+ end
@@ -0,0 +1,82 @@
1
+ require_relative './spec_helper'
2
+
3
+ describe "Emailist" do
4
+
5
+ before(:each) { @email_list = Emailist.new }
6
+
7
+ it "allows adding emails" do
8
+ @email_list.add('bob@test.com')
9
+ expect(@email_list.count).to eq 1
10
+ end
11
+
12
+ it "allows removing emails" do
13
+ @email_list.add('fred@test.com')
14
+ @email_list.remove('fred@test.com')
15
+ expect(@email_list.count).to eq 0
16
+ end
17
+
18
+ it "automatically removes nil values" do
19
+ @email_list.add(nil)
20
+ expect(@email_list.count).to eq 0
21
+ end
22
+
23
+ it "automatically maintains uniqueness" do
24
+ @email_list.add('fred@test.com')
25
+ @email_list.add('bob@test.com')
26
+ @email_list.add('fred@test.com')
27
+ expect(@email_list.count).to eq 2
28
+ end
29
+
30
+ context "cleans emails" do
31
+ it "with a leading period" do
32
+ @email_list.add('.bob.jones@yahoo.com')
33
+ expect(@email_list.first).to eq 'bob.jones@yahoo.com'
34
+ end
35
+
36
+ it "with a trailing period" do
37
+ @email_list.add('bob.jones@yahoo.com.')
38
+ expect(@email_list.first).to eq 'bob.jones@yahoo.com'
39
+ end
40
+
41
+ it "with more than one consecutive period" do
42
+ @email_list.add('bob..jones@yahoo.com')
43
+ expect(@email_list.first).to eq 'bob.jones@yahoo.com'
44
+ end
45
+
46
+ it "with invalid leading text" do
47
+ @email_list.add('<TAG SIZE="2">bob.jones@yahoo.com')
48
+ expect(@email_list.first).to eq 'bob.jones@yahoo.com'
49
+ end
50
+
51
+ it "with invalid trailing text" do
52
+ @email_list.add('bob.jones@yahoo.com<TAG SIZE="2">')
53
+ expect(@email_list.first).to eq 'bob.jones@yahoo.com'
54
+ end
55
+
56
+ describe "with common, leading, invalid word:" do
57
+ it "To" do
58
+ @email_list.add('To.bob.jones@yahoo.com')
59
+ expect(@email_list.first).to eq 'bob.jones@yahoo.com'
60
+ end
61
+ end
62
+
63
+ describe "with common, trailing, invalid word:" do
64
+ it "To" do
65
+ @email_list.add('bob.jones@yahoo.com.To')
66
+ expect(@email_list.first).to eq 'bob.jones@yahoo.com'
67
+ end
68
+ end
69
+
70
+ it "with invalid TLDs (valid TLD before invalid)" do
71
+ @email_list.add('bob.jones@yahoo.com.gloopoopoop')
72
+ expect(@email_list.first).to eq 'bob.jones@yahoo.com'
73
+ end
74
+ end
75
+
76
+ context "raises errors" do
77
+ it "when an email contains no valid TLD" do
78
+ expect { @email_list.add('bob.jones@yahoo.gloopoopoop') }.to raise_error Emailist::InvalidTLD
79
+ end
80
+ end
81
+
82
+ end
@@ -0,0 +1 @@
1
+ require_relative '../lib/emailist'
metadata ADDED
@@ -0,0 +1,118 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: emailist
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.7
5
+ platform: ruby
6
+ authors:
7
+ - Ethan Barron
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-02-07 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.6'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.6'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: shoulda-matchers
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ description: "\n Provides a Ruby array wrapper that helps
70
+ in managing a list of \n email addresses. Automagically
71
+ uniquifies the list, as well as\n attempting to clean invalid
72
+ emails.\n "
73
+ email:
74
+ - inkybro@gmail.com
75
+ executables: []
76
+ extensions: []
77
+ extra_rdoc_files: []
78
+ files:
79
+ - ".gitignore"
80
+ - Gemfile
81
+ - LICENSE.txt
82
+ - README.md
83
+ - Rakefile
84
+ - data/valid_tlds.txt
85
+ - emailist.gemspec
86
+ - lib/emailist.rb
87
+ - lib/emailist/errors.rb
88
+ - lib/emailist/version.rb
89
+ - spec/emailist_spec.rb
90
+ - spec/spec_helper.rb
91
+ homepage: ''
92
+ licenses:
93
+ - MIT
94
+ metadata: {}
95
+ post_install_message:
96
+ rdoc_options: []
97
+ require_paths:
98
+ - lib
99
+ required_ruby_version: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ required_rubygems_version: !ruby/object:Gem::Requirement
105
+ requirements:
106
+ - - ">="
107
+ - !ruby/object:Gem::Version
108
+ version: '0'
109
+ requirements: []
110
+ rubyforge_project:
111
+ rubygems_version: 2.4.5
112
+ signing_key:
113
+ specification_version: 4
114
+ summary: Wrapper around Ruby's Array class for managing lists of email addresses.
115
+ test_files:
116
+ - spec/emailist_spec.rb
117
+ - spec/spec_helper.rb
118
+ has_rdoc: