email_list 0.0.3 → 0.0.4
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.
- data/lib/email_list.rb +18 -8
- data/lib/email_list/version.rb +1 -1
- data/spec/email_list_spec.rb +19 -0
- metadata +34 -50
data/lib/email_list.rb
CHANGED
@@ -29,11 +29,14 @@ class EmailList
|
|
29
29
|
|
30
30
|
attr_reader :emails
|
31
31
|
|
32
|
-
def initialize(
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
32
|
+
def initialize(email_list)
|
33
|
+
if email_list.respond_to? :split
|
34
|
+
@emails = email_list.split(/,|;\s?/).map &:strip
|
35
|
+
elsif email_list.nil?
|
36
|
+
@emails = []
|
37
|
+
else
|
38
|
+
@emails = email_list
|
39
|
+
end
|
37
40
|
end
|
38
41
|
|
39
42
|
def each(&block)
|
@@ -45,17 +48,24 @@ class EmailList
|
|
45
48
|
end
|
46
49
|
|
47
50
|
def to_s
|
48
|
-
@
|
51
|
+
@emails.join(", ")
|
49
52
|
end
|
50
53
|
|
51
54
|
def ==(other)
|
52
|
-
|
55
|
+
case other
|
56
|
+
when String
|
53
57
|
emails.sort == EmailList.split(other).sort
|
54
|
-
|
58
|
+
when Array
|
59
|
+
emails == other
|
60
|
+
when EmailList
|
55
61
|
emails.sort == other.emails.sort
|
56
62
|
end
|
57
63
|
end
|
58
64
|
|
65
|
+
def +(other)
|
66
|
+
EmailList.new emails + other
|
67
|
+
end
|
68
|
+
|
59
69
|
def valid?
|
60
70
|
emails.each do |email|
|
61
71
|
unless email =~ EMAIL_ADDRESS_EXACT_PATTERN
|
data/lib/email_list/version.rb
CHANGED
data/spec/email_list_spec.rb
CHANGED
@@ -96,12 +96,31 @@ describe EmailList do
|
|
96
96
|
email_list.should == string
|
97
97
|
end
|
98
98
|
|
99
|
+
it 'compares against arrays' do
|
100
|
+
email_list = EmailList.new('foo@example.org, bar@example.org')
|
101
|
+
|
102
|
+
email_list.should == ['foo@example.org', 'bar@example.org']
|
103
|
+
end
|
104
|
+
|
105
|
+
it 'allows the additional of arrays' do
|
106
|
+
email_list = EmailList.new 'foo@example.org'
|
107
|
+
|
108
|
+
(email_list + ['bar@example.org']).should == EmailList.new('foo@example.org, bar@example.org')
|
109
|
+
end
|
110
|
+
|
99
111
|
it 'returns an empty email list when given nil' do
|
100
112
|
email_list = EmailList.new(nil)
|
101
113
|
|
102
114
|
email_list.emails.should == []
|
103
115
|
end
|
104
116
|
|
117
|
+
it 'allows initialization with an array' do
|
118
|
+
addresses = ['foo@example.org', 'bar@example.org']
|
119
|
+
email_list = EmailList.new addresses
|
120
|
+
|
121
|
+
email_list.should == addresses
|
122
|
+
end
|
123
|
+
|
105
124
|
it 'knows the size of the list' do
|
106
125
|
email_list = EmailList.new('foo@example.org, bar@example.org')
|
107
126
|
|
metadata
CHANGED
@@ -1,46 +1,39 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: email_list
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.4
|
5
5
|
prerelease:
|
6
|
-
segments:
|
7
|
-
- 0
|
8
|
-
- 0
|
9
|
-
- 3
|
10
|
-
version: 0.0.3
|
11
6
|
platform: ruby
|
12
|
-
authors:
|
7
|
+
authors:
|
13
8
|
- Michael Guterl
|
14
9
|
autorequire:
|
15
10
|
bindir: bin
|
16
11
|
cert_chain: []
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
- !ruby/object:Gem::Dependency
|
12
|
+
date: 2012-08-02 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
21
15
|
name: rspec
|
22
|
-
|
23
|
-
requirement: &id001 !ruby/object:Gem::Requirement
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
24
17
|
none: false
|
25
|
-
requirements:
|
26
|
-
- -
|
27
|
-
- !ruby/object:Gem::Version
|
28
|
-
|
29
|
-
segments:
|
30
|
-
- 0
|
31
|
-
version: "0"
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
32
22
|
type: :development
|
33
|
-
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '0'
|
34
30
|
description: A gem for managing a list of email addresses stored in a string.
|
35
|
-
email:
|
31
|
+
email:
|
36
32
|
- michael@diminishing.org
|
37
33
|
executables: []
|
38
|
-
|
39
34
|
extensions: []
|
40
|
-
|
41
35
|
extra_rdoc_files: []
|
42
|
-
|
43
|
-
files:
|
36
|
+
files:
|
44
37
|
- .gitignore
|
45
38
|
- .rvmrc
|
46
39
|
- Gemfile
|
@@ -51,36 +44,27 @@ files:
|
|
51
44
|
- spec/email_list_spec.rb
|
52
45
|
homepage: http://github.com/recruitmilitary/email_list
|
53
46
|
licenses: []
|
54
|
-
|
55
47
|
post_install_message:
|
56
48
|
rdoc_options: []
|
57
|
-
|
58
|
-
require_paths:
|
49
|
+
require_paths:
|
59
50
|
- lib
|
60
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
51
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
61
52
|
none: false
|
62
|
-
requirements:
|
63
|
-
- -
|
64
|
-
- !ruby/object:Gem::Version
|
65
|
-
|
66
|
-
|
67
|
-
- 0
|
68
|
-
version: "0"
|
69
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
53
|
+
requirements:
|
54
|
+
- - ! '>='
|
55
|
+
- !ruby/object:Gem::Version
|
56
|
+
version: '0'
|
57
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
70
58
|
none: false
|
71
|
-
requirements:
|
72
|
-
- -
|
73
|
-
- !ruby/object:Gem::Version
|
74
|
-
|
75
|
-
segments:
|
76
|
-
- 0
|
77
|
-
version: "0"
|
59
|
+
requirements:
|
60
|
+
- - ! '>='
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: '0'
|
78
63
|
requirements: []
|
79
|
-
|
80
64
|
rubyforge_project: email_list
|
81
|
-
rubygems_version: 1.8.
|
65
|
+
rubygems_version: 1.8.24
|
82
66
|
signing_key:
|
83
67
|
specification_version: 3
|
84
68
|
summary: A gem for managing a list of email addresses stored in a string.
|
85
|
-
test_files:
|
69
|
+
test_files:
|
86
70
|
- spec/email_list_spec.rb
|