myna_bird 0.2.11 → 0.2.13
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 +5 -5
- data/Gemfile.lock +62 -38
- data/README.md +16 -10
- data/VERSION +1 -1
- data/lib/myna_bird.rb +35 -12
- data/myna_bird.gemspec +1 -1
- data/spec/myna_bird_spec.rb +9 -1
- data/spec/spec_helper.rb +4 -1
- metadata +5 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 46f55f1b5df1f4491f4bdbb249b2225176addc5833262d16d873db2ba3f19643
|
4
|
+
data.tar.gz: f918981314bb0b820510fd1fc2f9e99a3b43cf9c95c397e1a7bc624d8f89051b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 99b8fa3bfa338122ac942494f78486f97cc46e993b7ecd90de431514e4d06e652aca24f6a3d7085724cbcd3812ec87f014c8f5e41e59d40665ad6a8f81d5d756
|
7
|
+
data.tar.gz: bc9c2a845475b1d006c77dee4178fea43349b73273ab1ff86d6786ea419d423bf4d18823031d6eadf5e7425f0152739d407ef5e70d26eb236e7713ec02731d62
|
data/Gemfile.lock
CHANGED
@@ -2,64 +2,88 @@ GEM
|
|
2
2
|
remote: http://rubygems.org/
|
3
3
|
specs:
|
4
4
|
addressable (2.4.0)
|
5
|
-
|
5
|
+
base64 (0.2.0)
|
6
|
+
bigdecimal (3.1.9)
|
7
|
+
builder (3.3.0)
|
8
|
+
date (3.4.1)
|
6
9
|
descendants_tracker (0.0.4)
|
7
10
|
thread_safe (~> 0.3, >= 0.3.1)
|
8
|
-
diff-lcs (1.1
|
11
|
+
diff-lcs (1.6.1)
|
9
12
|
faraday (0.9.2)
|
10
13
|
multipart-post (>= 1.2, < 3)
|
11
|
-
git (1.
|
12
|
-
|
14
|
+
git (1.11.0)
|
15
|
+
rchardet (~> 1.8)
|
16
|
+
github_api (0.16.0)
|
13
17
|
addressable (~> 2.4.0)
|
14
18
|
descendants_tracker (~> 0.0.4)
|
15
19
|
faraday (~> 0.8, < 0.10)
|
16
20
|
hashie (>= 3.4)
|
17
|
-
|
18
|
-
oauth2
|
19
|
-
hashie (
|
20
|
-
highline (1.
|
21
|
-
|
21
|
+
mime-types (>= 1.16, < 3.0)
|
22
|
+
oauth2 (~> 1.0)
|
23
|
+
hashie (5.0.0)
|
24
|
+
highline (3.1.2)
|
25
|
+
reline
|
26
|
+
io-console (0.8.0)
|
27
|
+
jeweler (2.3.9)
|
22
28
|
builder
|
23
|
-
bundler
|
29
|
+
bundler
|
24
30
|
git (>= 1.2.5)
|
25
|
-
github_api
|
31
|
+
github_api (~> 0.16.0)
|
26
32
|
highline (>= 1.6.15)
|
27
33
|
nokogiri (>= 1.5.10)
|
34
|
+
psych
|
28
35
|
rake
|
29
36
|
rdoc
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
multi_json (1.
|
35
|
-
multi_xml (0.
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
37
|
+
semver2
|
38
|
+
jwt (2.10.1)
|
39
|
+
base64
|
40
|
+
mime-types (2.99.3)
|
41
|
+
multi_json (1.15.0)
|
42
|
+
multi_xml (0.7.1)
|
43
|
+
bigdecimal (~> 3.1)
|
44
|
+
multipart-post (2.4.1)
|
45
|
+
nokogiri (1.18.7-arm64-darwin)
|
46
|
+
racc (~> 1.4)
|
47
|
+
oauth2 (1.4.8)
|
48
|
+
faraday (>= 0.8, < 3.0)
|
49
|
+
jwt (>= 1.0, < 3.0)
|
42
50
|
multi_json (~> 1.3)
|
43
51
|
multi_xml (~> 0.5)
|
44
52
|
rack (>= 1.2, < 3)
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
rspec
|
57
|
-
|
58
|
-
|
53
|
+
psych (5.2.3)
|
54
|
+
date
|
55
|
+
stringio
|
56
|
+
racc (1.8.1)
|
57
|
+
rack (2.2.13)
|
58
|
+
rake (13.2.1)
|
59
|
+
rchardet (1.9.0)
|
60
|
+
rdoc (6.13.1)
|
61
|
+
psych (>= 4.0.0)
|
62
|
+
reline (0.6.1)
|
63
|
+
io-console (~> 0.5)
|
64
|
+
rspec (3.13.0)
|
65
|
+
rspec-core (~> 3.13.0)
|
66
|
+
rspec-expectations (~> 3.13.0)
|
67
|
+
rspec-mocks (~> 3.13.0)
|
68
|
+
rspec-core (3.13.3)
|
69
|
+
rspec-support (~> 3.13.0)
|
70
|
+
rspec-expectations (3.13.3)
|
71
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
72
|
+
rspec-support (~> 3.13.0)
|
73
|
+
rspec-mocks (3.13.2)
|
74
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
75
|
+
rspec-support (~> 3.13.0)
|
76
|
+
rspec-support (3.13.2)
|
77
|
+
semver2 (3.4.2)
|
78
|
+
stringio (3.1.7)
|
79
|
+
thread_safe (0.3.6)
|
59
80
|
|
60
81
|
PLATFORMS
|
61
|
-
|
82
|
+
arm64-darwin-24
|
62
83
|
|
63
84
|
DEPENDENCIES
|
64
85
|
jeweler
|
65
86
|
rspec
|
87
|
+
|
88
|
+
BUNDLED WITH
|
89
|
+
2.4.10
|
data/README.md
CHANGED
@@ -25,31 +25,37 @@ the name. Otherwise, MynaBird builds the account name from the domain.
|
|
25
25
|
|
26
26
|
For example:
|
27
27
|
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
28
|
+
brendan@wistia.com -> wistia
|
29
|
+
brendan.schwartz@gmail.com -> brendan-schwartz
|
30
|
+
brendan+nospam@gmail.com -> brendan
|
31
|
+
support@gmail.com -> support-at-gmail
|
32
32
|
|
33
33
|
Ok, that last one is a bit of a special case, but you get the idea.
|
34
34
|
|
35
35
|
|
36
|
-
Usage
|
36
|
+
## Usage
|
37
37
|
|
38
|
-
|
39
|
-
|
38
|
+
require 'myna_bird'
|
39
|
+
MynaBird.convert('brendan@wistia.com') #=> 'wistia'
|
40
40
|
|
41
|
+
You can also tell MynaBird to avoid a list of domains. No need to include the
|
42
|
+
TLD, just a second-level domain. For example:
|
41
43
|
|
42
|
-
|
44
|
+
MynaBird.avoid_domains = ['coolmail', 'bestmail']
|
45
|
+
MynaBird.convert('best.business@coolmail.com') #=> 'best-business'
|
46
|
+
|
47
|
+
|
48
|
+
## Specs
|
43
49
|
|
44
50
|
Just run "rake spec" to run the specs.
|
45
51
|
Don't be shy, feel free to add more examples.
|
46
52
|
|
47
53
|
|
48
|
-
Questions
|
54
|
+
## Questions
|
49
55
|
|
50
56
|
Feel free to email me at brendan@wistia.com with any questions.
|
51
57
|
|
52
58
|
|
53
|
-
License:
|
59
|
+
## License:
|
54
60
|
|
55
61
|
Go nuts. See LICENSE for full details.
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.2.
|
1
|
+
0.2.13
|
data/lib/myna_bird.rb
CHANGED
@@ -24,6 +24,18 @@ class MynaBird
|
|
24
24
|
new(email).name
|
25
25
|
end
|
26
26
|
|
27
|
+
def self.reset_avoided_domains
|
28
|
+
@avoided_domains = nil
|
29
|
+
end
|
30
|
+
|
31
|
+
def self.avoided_domains=(domains)
|
32
|
+
@avoided_domains = domains
|
33
|
+
end
|
34
|
+
|
35
|
+
def self.avoided_domains
|
36
|
+
@avoided_domains || []
|
37
|
+
end
|
38
|
+
|
27
39
|
def initialize(email)
|
28
40
|
# email must be in a somewhat sane format
|
29
41
|
# i.e. have an @ sign and at least one letter or number on each side of it
|
@@ -36,11 +48,11 @@ class MynaBird
|
|
36
48
|
|
37
49
|
# extract the name
|
38
50
|
def name
|
39
|
-
if common_local? && common_domain?
|
51
|
+
if common_local? && (common_domain? || avoided_domain?)
|
40
52
|
local_name + '-at-' + domain_name
|
41
53
|
elsif common_local?
|
42
54
|
domain_name
|
43
|
-
elsif common_domain?
|
55
|
+
elsif (common_domain? || avoided_domain?)
|
44
56
|
local_name
|
45
57
|
else
|
46
58
|
domain_name
|
@@ -65,18 +77,16 @@ class MynaBird
|
|
65
77
|
name
|
66
78
|
end
|
67
79
|
|
68
|
-
def
|
69
|
-
|
70
|
-
|
71
|
-
return true if domain.match(@domain)
|
72
|
-
elsif domain =~ /\./
|
73
|
-
return true if /#{domain}$/.match(@domain)
|
74
|
-
else
|
75
|
-
return true if /^#{domain}\./.match(@domain)
|
76
|
-
end
|
80
|
+
def avoided_domain?
|
81
|
+
self.class.avoided_domains.any? do |domain|
|
82
|
+
matches_domain?(domain)
|
77
83
|
end
|
84
|
+
end
|
78
85
|
|
79
|
-
|
86
|
+
def common_domain?
|
87
|
+
COMMON_DOMAINS.any? do |domain|
|
88
|
+
matches_domain?(domain)
|
89
|
+
end
|
80
90
|
end
|
81
91
|
|
82
92
|
def common_local?
|
@@ -91,4 +101,17 @@ class MynaBird
|
|
91
101
|
return false
|
92
102
|
end
|
93
103
|
|
104
|
+
private
|
105
|
+
|
106
|
+
def matches_domain?(domain)
|
107
|
+
if domain.is_a?(Regexp)
|
108
|
+
return true if domain.match(@domain)
|
109
|
+
elsif domain =~ /\./
|
110
|
+
return true if /#{domain}$/.match(@domain)
|
111
|
+
else
|
112
|
+
return true if /^#{domain}\./.match(@domain)
|
113
|
+
end
|
114
|
+
|
115
|
+
false
|
116
|
+
end
|
94
117
|
end
|
data/myna_bird.gemspec
CHANGED
data/spec/myna_bird_spec.rb
CHANGED
@@ -1,7 +1,6 @@
|
|
1
1
|
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
2
2
|
|
3
3
|
describe MynaBird do
|
4
|
-
|
5
4
|
it_should_convert 'brendan@wistia.com', to: 'wistia'
|
6
5
|
it_should_convert 'brendan.schwartz@gmail.com', to: 'brendan-schwartz'
|
7
6
|
it_should_convert 'support@gmail.com', to: 'support-at-gmail'
|
@@ -18,6 +17,7 @@ describe MynaBird do
|
|
18
17
|
it_should_convert 'BRENDAN@WISTIA', to: 'wistia'
|
19
18
|
it_should_convert 'brendan@outlook.com', to: 'brendan'
|
20
19
|
it_should_convert 'james@outlook.com.br', to: 'james'
|
20
|
+
it_should_convert 'james@karaol.com', to: 'karaol'
|
21
21
|
|
22
22
|
# bad input
|
23
23
|
it_should_not_convert 'no.at.sign'
|
@@ -26,4 +26,12 @@ describe MynaBird do
|
|
26
26
|
it_should_not_convert '@@@@'
|
27
27
|
it_should_not_convert '++@++'
|
28
28
|
|
29
|
+
describe '.avoided_domains' do
|
30
|
+
before do
|
31
|
+
MynaBird.avoided_domains = ['post-jazz', 'my']
|
32
|
+
end
|
33
|
+
|
34
|
+
it_should_convert 'davej@post-jazz.no', to: 'davej'
|
35
|
+
it_should_convert 'thijs@mychickennuggets.com', to: 'mychickennuggets'
|
36
|
+
end
|
29
37
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -5,7 +5,7 @@ require 'rspec'
|
|
5
5
|
|
6
6
|
module ShouldAndShouldNotConvert
|
7
7
|
def it_should_convert(from, to_hash)
|
8
|
-
to = to_hash[:to]
|
8
|
+
to = to_hash[:to]
|
9
9
|
it "should convert '#{from}' to '#{to}'" do
|
10
10
|
MynaBird.convert(from).should == to
|
11
11
|
end
|
@@ -22,4 +22,7 @@ end
|
|
22
22
|
|
23
23
|
RSpec.configure do |config|
|
24
24
|
config.extend(ShouldAndShouldNotConvert)
|
25
|
+
config.after do
|
26
|
+
MynaBird.reset_avoided_domains
|
27
|
+
end
|
25
28
|
end
|
metadata
CHANGED
@@ -1,11 +1,11 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: myna_bird
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.13
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brendan Schwartz
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
date: 2016-04-25 00:00:00.000000000 Z
|
@@ -63,7 +63,7 @@ files:
|
|
63
63
|
homepage: http://github.com/wistia/myna_bird
|
64
64
|
licenses: []
|
65
65
|
metadata: {}
|
66
|
-
post_install_message:
|
66
|
+
post_install_message:
|
67
67
|
rdoc_options: []
|
68
68
|
require_paths:
|
69
69
|
- lib
|
@@ -78,9 +78,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
78
78
|
- !ruby/object:Gem::Version
|
79
79
|
version: '0'
|
80
80
|
requirements: []
|
81
|
-
|
82
|
-
|
83
|
-
signing_key:
|
81
|
+
rubygems_version: 3.4.10
|
82
|
+
signing_key:
|
84
83
|
specification_version: 4
|
85
84
|
summary: Transform email addresses into account names for your app
|
86
85
|
test_files: []
|