ampersat 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +4 -0
- data/.rspec +1 -0
- data/Gemfile +4 -0
- data/README.md +33 -0
- data/Rakefile +5 -0
- data/ampersat.gemspec +24 -0
- data/lib/ampersat.rb +21 -0
- data/lib/ampersat/version.rb +3 -0
- data/spec/ampersat_spec.rb +30 -0
- data/spec/support/test.csv +4 -0
- metadata +79 -0
data/.gitignore
ADDED
data/.rspec
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--color
|
data/Gemfile
ADDED
data/README.md
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
# Calculate Most Common Domains From Email List
|
2
|
+
|
3
|
+
It's worth checking what email clients your subscribers are using so that you can make sure your emails look good when they view them.
|
4
|
+
|
5
|
+
This gem looks at your subscribers CSV and lists the domains in order of popularity*.
|
6
|
+
|
7
|
+
* This obviously doesn't take desktop mail clients in to account, but it should give you an idea of what people are using.
|
8
|
+
|
9
|
+
## How to Use
|
10
|
+
|
11
|
+
### Install
|
12
|
+
|
13
|
+
gem install ampersat
|
14
|
+
|
15
|
+
### In irb
|
16
|
+
|
17
|
+
$ irb
|
18
|
+
> require 'ampersat'
|
19
|
+
=> true
|
20
|
+
> Ampersat.domains("/path/to/csv")
|
21
|
+
=> [["example.com", 2], ["example.org", 1], ["example.net", 1]]
|
22
|
+
|
23
|
+
### In Your App
|
24
|
+
|
25
|
+
domains = Ampersat.domains("/Users/gareth/test.csv")
|
26
|
+
|
27
|
+
domains.each do |domain, count|
|
28
|
+
puts "#{domain}: #{count}"
|
29
|
+
end
|
30
|
+
|
31
|
+
# example.com: 2
|
32
|
+
# example.org: 1
|
33
|
+
# example.net: 1
|
data/Rakefile
ADDED
data/ampersat.gemspec
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
require "ampersat/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = "ampersat"
|
7
|
+
s.version = Ampersat::VERSION
|
8
|
+
s.authors = ["Gareth Rees"]
|
9
|
+
s.email = ["gareth.h.rees@gmail.com"]
|
10
|
+
s.homepage = "http://github.com/garethrees/ampersat"
|
11
|
+
s.summary = "Calculates which email domains your subscribers use"
|
12
|
+
s.description = "Calculates which email domains your subscribers use"
|
13
|
+
|
14
|
+
s.rubyforge_project = "ampersat"
|
15
|
+
|
16
|
+
s.files = `git ls-files`.split("\n")
|
17
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
18
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
19
|
+
s.require_paths = ["lib"]
|
20
|
+
|
21
|
+
s.add_development_dependency 'rake'
|
22
|
+
s.add_development_dependency "rspec", "~> 2.7"
|
23
|
+
|
24
|
+
end
|
data/lib/ampersat.rb
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
require "ampersat/version"
|
2
|
+
require "csv"
|
3
|
+
|
4
|
+
module Ampersat
|
5
|
+
|
6
|
+
def self.domains(email_list)
|
7
|
+
domains = Hash.new(0)
|
8
|
+
|
9
|
+
CSV.foreach(email_list) do |row|
|
10
|
+
domain = Ampersat.find_domain(row.first)
|
11
|
+
domains[domain] = domains[domain] +1
|
12
|
+
end
|
13
|
+
|
14
|
+
domains.sort_by {|key, value| -value}
|
15
|
+
end
|
16
|
+
|
17
|
+
def self.find_domain(email)
|
18
|
+
email.split('@').last
|
19
|
+
end
|
20
|
+
|
21
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
path = File.expand_path(File.dirname(__FILE__) + "/../lib/")
|
3
|
+
$LOAD_PATH.unshift(path) unless $LOAD_PATH.include?(path)
|
4
|
+
require "ampersat"
|
5
|
+
|
6
|
+
|
7
|
+
describe Ampersat do
|
8
|
+
|
9
|
+
let(:csv_path) { File.expand_path(File.dirname(__FILE__) + "/support/test.csv") }
|
10
|
+
let(:email) { "test@example.com" }
|
11
|
+
let(:multiple_emails) { "jim@example.com, tom@example.com, bob@example.org, james@example.net" }
|
12
|
+
|
13
|
+
it "should return the sum of each email provider" do
|
14
|
+
expected_result = [["example.com", 2], ["example.org", 1], ["example.net", 1]]
|
15
|
+
Ampersat.domains(csv_path).should == expected_result
|
16
|
+
end
|
17
|
+
|
18
|
+
it "should return the email providers with the most common first" do
|
19
|
+
incorrect_result = [["example.org", 1],["example.com", 2], ["example.net", 1]]
|
20
|
+
Ampersat.domains(csv_path).should_not == incorrect_result
|
21
|
+
|
22
|
+
expected_result = [["example.com", 2], ["example.org", 1], ["example.net", 1]]
|
23
|
+
Ampersat.domains(csv_path).should == expected_result
|
24
|
+
end
|
25
|
+
|
26
|
+
it "should find the domain of an email address" do
|
27
|
+
Ampersat.find_domain(email).should == "example.com"
|
28
|
+
end
|
29
|
+
|
30
|
+
end
|
metadata
ADDED
@@ -0,0 +1,79 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: ampersat
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Gareth Rees
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2011-11-30 00:00:00.000000000Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: rake
|
16
|
+
requirement: &5275780 !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
22
|
+
type: :development
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: *5275780
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: rspec
|
27
|
+
requirement: &5275490 !ruby/object:Gem::Requirement
|
28
|
+
none: false
|
29
|
+
requirements:
|
30
|
+
- - ~>
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '2.7'
|
33
|
+
type: :development
|
34
|
+
prerelease: false
|
35
|
+
version_requirements: *5275490
|
36
|
+
description: Calculates which email domains your subscribers use
|
37
|
+
email:
|
38
|
+
- gareth.h.rees@gmail.com
|
39
|
+
executables: []
|
40
|
+
extensions: []
|
41
|
+
extra_rdoc_files: []
|
42
|
+
files:
|
43
|
+
- .gitignore
|
44
|
+
- .rspec
|
45
|
+
- Gemfile
|
46
|
+
- README.md
|
47
|
+
- Rakefile
|
48
|
+
- ampersat.gemspec
|
49
|
+
- lib/ampersat.rb
|
50
|
+
- lib/ampersat/version.rb
|
51
|
+
- spec/ampersat_spec.rb
|
52
|
+
- spec/support/test.csv
|
53
|
+
homepage: http://github.com/garethrees/ampersat
|
54
|
+
licenses: []
|
55
|
+
post_install_message:
|
56
|
+
rdoc_options: []
|
57
|
+
require_paths:
|
58
|
+
- lib
|
59
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
60
|
+
none: false
|
61
|
+
requirements:
|
62
|
+
- - ! '>='
|
63
|
+
- !ruby/object:Gem::Version
|
64
|
+
version: '0'
|
65
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
66
|
+
none: false
|
67
|
+
requirements:
|
68
|
+
- - ! '>='
|
69
|
+
- !ruby/object:Gem::Version
|
70
|
+
version: '0'
|
71
|
+
requirements: []
|
72
|
+
rubyforge_project: ampersat
|
73
|
+
rubygems_version: 1.8.11
|
74
|
+
signing_key:
|
75
|
+
specification_version: 3
|
76
|
+
summary: Calculates which email domains your subscribers use
|
77
|
+
test_files:
|
78
|
+
- spec/ampersat_spec.rb
|
79
|
+
- spec/support/test.csv
|