emagen 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 339b998eac590439f04977791628f72ddf0dff96
4
- data.tar.gz: e7b3fcdf15c8f0178aff2440c13b145853a42436
3
+ metadata.gz: e40e727e87e60794be14d4eddf8962f0f709e955
4
+ data.tar.gz: 6ec99e35834f4f5fa692e0d0a26448f0f89ec283
5
5
  SHA512:
6
- metadata.gz: 45d159e55d43978a272ec28aa051ddfe56ed6a86092c252c36a5d7bd9409103b996c90e1080d16bb2e4487e0f947fd32fb2becd4521873e25bb9195572f3b8be
7
- data.tar.gz: e72b6313b6a2290dc139e199a24f8c6965431a4af5bc3ec3f40225202cf17a7539fe2adbba8e023ee95cbc0f6784eef82cbe7b0eca4b02cbc2d3baaed4a36efa
6
+ metadata.gz: 8ec81b7d1aa64fc1715684832709110b195db2d69a5baab2cce6ed1b2589b0cd3f00f8e694a1f779ef1247842542a53fa4075187639ebfdec079aaffbdd6baed
7
+ data.tar.gz: 55b50293006fb5347e4661d63a2d078782ec04b61851a58f0068cdb1df4315633827bc2a2f4281193aa77cfb4d91f1a3088be04a75809871266dac0e08638db6
data/README.md CHANGED
@@ -17,13 +17,15 @@ Or install it yourself as:
17
17
  $ gem install emagen
18
18
 
19
19
  ## Usage
20
+ ```ruby
20
21
  require 'emagen'
21
22
  name = "Louis Sayers"
22
23
  domain = "louissayers.com"
23
24
  possible_emails = Emagen.for(name, domain)
24
25
 
25
- # Returns a list of possible emails such as:
26
- # LouisSayers@louissayers.com, LSayers@louissayers.com L.S@louissayers.com
26
+ # Returns a list of possible emails such as:
27
+ #=> [LouisSayers@louissayers.com, LSayers@louissayers.com L.S@louissayers.com]
28
+ ```
27
29
 
28
30
 
29
31
  ## Contributing
data/lib/emagen.rb CHANGED
@@ -1,7 +1,10 @@
1
1
  require "emagen/version"
2
+ require "emagen/web_address"
2
3
 
3
4
  module Emagen
4
- def for(name, domain)
5
+ def for(name, web_address)
6
+ domain = WebAddress.new(web_address).domain
7
+
5
8
  first_name, last_name = name.split
6
9
  first_initial, last_initial = first_name[0], last_name[0]
7
10
  patterns = %w{
@@ -1,3 +1,3 @@
1
1
  module Emagen
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
@@ -0,0 +1,14 @@
1
+ module Emagen
2
+ class WebAddress
3
+ attr_reader :domain
4
+
5
+ def initialize(web_address)
6
+ @domain = domain_from(web_address)
7
+ end
8
+
9
+ private
10
+ def domain_from(web_address)
11
+ web_address.split('.').slice(-2..-1).join('.')
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,13 @@
1
+ require 'spec_helper'
2
+
3
+ describe Emagen::WebAddress do
4
+ let(:subject) { Emagen::WebAddress }
5
+ let(:web_address) { "http://www.domain.com" }
6
+
7
+ describe '#domain' do
8
+ it "should get the domain from a web address" do
9
+ address = subject.new(web_address)
10
+ expect(address.domain).to eq 'domain.com'
11
+ end
12
+ end
13
+ end
data/spec/emagen_spec.rb CHANGED
@@ -2,8 +2,9 @@ require 'spec_helper'
2
2
 
3
3
  describe Emagen do
4
4
  let(:domain) { "domain.com" }
5
+ let(:web_address) { "http://www.domain.com" }
5
6
 
6
- describe '#for' do
7
+ describe 'for' do
7
8
  context "valid arguments" do
8
9
  it "should generate email addresses" do
9
10
  expected_usernames = %w{
@@ -13,11 +14,16 @@ describe Emagen do
13
14
  Jack_Black J_Black Jack_B J_B Black_Jack Black_J B_J
14
15
  }
15
16
 
16
- emails = Emagen.for("Jack Black", domain)
17
+ emails = subject.for("Jack Black", domain)
17
18
  expected_usernames.each do |username|
18
19
  expect(emails).to include("#{username}@#{domain}")
19
20
  end
20
21
  end
22
+
23
+ it "should generate email addresses from a name, web address" do
24
+ emails = subject.for("Jack Black", web_address)
25
+ expect(emails).to include("JackBlack@#{domain}")
26
+ end
21
27
  end
22
28
  end
23
29
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: emagen
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Louis Sayers
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-02-28 00:00:00.000000000 Z
11
+ date: 2015-03-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -81,6 +81,8 @@ files:
81
81
  - emagen.gemspec
82
82
  - lib/emagen.rb
83
83
  - lib/emagen/version.rb
84
+ - lib/emagen/web_address.rb
85
+ - spec/emagen/web_address_spec.rb
84
86
  - spec/emagen_spec.rb
85
87
  - spec/spec_helper.rb
86
88
  homepage: https://github.com/LouisSayers/Emagen
@@ -108,5 +110,6 @@ signing_key:
108
110
  specification_version: 4
109
111
  summary: Generate possible email addresses given a name and domain.
110
112
  test_files:
113
+ - spec/emagen/web_address_spec.rb
111
114
  - spec/emagen_spec.rb
112
115
  - spec/spec_helper.rb