freya 0.1.2 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/freya.rb +20 -1
- data/lib/freya/version.rb +1 -1
- data/spec/freya_spec.rb +12 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0592dd35545824e9ab77d0b678ac36ba3908e33d
|
4
|
+
data.tar.gz: 4e6d3ef0becf97cdb21fc2a026736ffb7b45c6bc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bdf7a25d67df80d7b1ecad7bfc513b9363ad3abf081108a1b498a2af32212ec59b40541f43ab8aa03407898a5e0bb0f01bc4dfaa5d762ee713bbddb5a4c5307f
|
7
|
+
data.tar.gz: 561fba7872fd5cb4deaca09260374747d25a49b7dfa1ff229d34e8e6318810c75bbb59f524f4036168684d7d3289bb785a220918d82728147c0d6ac1c13866a9
|
data/lib/freya.rb
CHANGED
@@ -23,12 +23,23 @@ module Freya
|
|
23
23
|
end
|
24
24
|
end
|
25
25
|
|
26
|
-
class Email
|
26
|
+
class Email
|
27
|
+
attr_accessor :name, :to, :subject, :cc, :bcc
|
28
|
+
|
29
|
+
def initialize(name: nil, to: nil, subject: nil, cc: [], bcc: [])
|
30
|
+
@name = name
|
31
|
+
@to = to
|
32
|
+
@subject = subject
|
33
|
+
@cc = cc
|
34
|
+
@bcc = bcc
|
35
|
+
end
|
36
|
+
|
27
37
|
def link
|
28
38
|
extras = %w{ cc bcc body subject }.select { |extra| send(extra).present? }.map { |extra| [extra, send(extra)] }.map { |extra|
|
29
39
|
name = extra[0]
|
30
40
|
value = extra[1]
|
31
41
|
|
42
|
+
#cc and #bcc must be repeated for every email in the array
|
32
43
|
[value].flatten.map do |component|
|
33
44
|
"#{name}=#{Rack::Utils.escape_path(component)}"
|
34
45
|
end
|
@@ -42,5 +53,13 @@ module Freya
|
|
42
53
|
def body
|
43
54
|
Template.new[name]
|
44
55
|
end
|
56
|
+
|
57
|
+
def cc
|
58
|
+
@cc - [to]
|
59
|
+
end
|
60
|
+
|
61
|
+
def bcc
|
62
|
+
@bcc - [to]
|
63
|
+
end
|
45
64
|
end
|
46
65
|
end
|
data/lib/freya/version.rb
CHANGED
data/spec/freya_spec.rb
CHANGED
@@ -48,6 +48,18 @@ describe Freya::Email do
|
|
48
48
|
}.to raise_error
|
49
49
|
end
|
50
50
|
end
|
51
|
+
|
52
|
+
describe '#cc' do
|
53
|
+
it "doesn't contain #to email" do
|
54
|
+
Freya::Email.new(name: 'test_email', to: 'test@test.com', cc: ['test@test.com', 'test2@test.com']).cc.should eq(['test2@test.com'])
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
describe '#bcc' do
|
59
|
+
it "doesn't contain #to email" do
|
60
|
+
Freya::Email.new(name: 'test_email', to: 'test@test.com', cc: ['test@test.com', 'test1@test.com']).cc.should eq(['test1@test.com'])
|
61
|
+
end
|
62
|
+
end
|
51
63
|
end
|
52
64
|
|
53
65
|
describe Freya::Template do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: freya
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Matteo Depalo
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-11-
|
11
|
+
date: 2013-11-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|