freya 0.1.2 → 0.2.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 56ca392d18f089dd99808244f2eebc719f236647
4
- data.tar.gz: 22ff53ee7d34047b9ea72f6119f3aeae18cd84f4
3
+ metadata.gz: 0592dd35545824e9ab77d0b678ac36ba3908e33d
4
+ data.tar.gz: 4e6d3ef0becf97cdb21fc2a026736ffb7b45c6bc
5
5
  SHA512:
6
- metadata.gz: 6f8b9d3c721c411d38cc7c7b745eedae14345832d4c3afb42e0e9837351b98c365f15bff46965450188d98d1e15898f52b66831f611fa06330ff94ad91377683
7
- data.tar.gz: 51c344d8d175c8365701ac0430300699aa00563c4589df45f0fc3f9d761ec4fe945e228090207a1a8baa5ad044e57187340b3044473bb33448565f461c614c5e
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 < OpenStruct
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
@@ -1,3 +1,3 @@
1
1
  module Freya
2
- VERSION = "0.1.2"
2
+ VERSION = "0.2.0"
3
3
  end
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.1.2
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-05 00:00:00.000000000 Z
11
+ date: 2013-11-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails