freya 0.3.2 → 1.0.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 +4 -4
- data/README.md +21 -2
- data/lib/freya.rb +3 -3
- data/lib/freya/version.rb +1 -1
- data/spec/freya_spec.rb +2 -2
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 53629f40cadf24365421fc47dd1d974802507353
|
4
|
+
data.tar.gz: b5304900222fa8c0c6f5a32f33536f160a752fba
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 07b66ece25355a4d2323487b31c55371c0af4bc0705fceb90df81dd4642470c97922735ed46c83051fc46363115c1cb6340f358cf36b2e474053276ca15fd00a
|
7
|
+
data.tar.gz: 17bb3ad53d640c0cc1a193bce8aaa8fea853a5e265545a2e65ad9796883a5bc4f79201dca3f1f4c4cb2539e8fbbae8a7e1870b3c4d9b45414c01691f538bc1d6
|
data/README.md
CHANGED
@@ -28,10 +28,29 @@ test:
|
|
28
28
|
Then you create a link to this email like this:
|
29
29
|
|
30
30
|
```ruby
|
31
|
-
mail_to Freya::Email.new(name:'test
|
31
|
+
mail_to Freya::Email.new(name:'test.email', to: 'test@test.com', subject: 'test_subject).link, 'Email'
|
32
32
|
```
|
33
33
|
|
34
|
-
You can access mail bodies using the `name` attribute separating nodes with
|
34
|
+
You can access mail bodies using the `name` attribute separating nodes with points.
|
35
|
+
|
36
|
+
You can also create your own email class and use `base_cc` and `base_bcc` to provide emails that have to be added to every cc and bcc of that subtype
|
37
|
+
For example:
|
38
|
+
|
39
|
+
```ruby
|
40
|
+
class TeamMemberEmail < Freya::Email
|
41
|
+
def subject
|
42
|
+
'Team email'
|
43
|
+
end
|
44
|
+
|
45
|
+
def name
|
46
|
+
'team.email'
|
47
|
+
end
|
48
|
+
|
49
|
+
def base_cc
|
50
|
+
['base-email@email.com']
|
51
|
+
end
|
52
|
+
end
|
53
|
+
```
|
35
54
|
|
36
55
|
## Contributing
|
37
56
|
|
data/lib/freya.rb
CHANGED
@@ -19,13 +19,13 @@ module Freya
|
|
19
19
|
end
|
20
20
|
|
21
21
|
def [](name)
|
22
|
-
name.present? ? name.to_s.split('
|
22
|
+
name.present? ? name.to_s.split('.').inject(self.class.config) { |result, n| result.fetch(n) } : nil
|
23
23
|
end
|
24
24
|
end
|
25
25
|
|
26
26
|
class Email < OpenStruct
|
27
27
|
def link
|
28
|
-
extras = %w{ cc bcc body subject }.select { |extra| send(extra).present? }.map { |extra| [extra, send(extra)] }.map
|
28
|
+
extras = %w{ cc bcc body subject }.select { |extra| send(extra).present? }.map { |extra| [extra, send(extra)] }.map do |extra|
|
29
29
|
name = extra[0]
|
30
30
|
value = extra[1]
|
31
31
|
|
@@ -33,7 +33,7 @@ module Freya
|
|
33
33
|
[value].flatten.map do |component|
|
34
34
|
"#{name}=#{Rack::Utils.escape_path(component)}"
|
35
35
|
end
|
36
|
-
|
36
|
+
end.compact
|
37
37
|
|
38
38
|
extras = extras.empty? ? '' : '?' + extras.join('&')
|
39
39
|
|
data/lib/freya/version.rb
CHANGED
data/spec/freya_spec.rb
CHANGED
@@ -31,7 +31,7 @@ describe Freya::Email do
|
|
31
31
|
Freya::Email.new(name: 'test_email').body.should eq('This is the test email')
|
32
32
|
end
|
33
33
|
|
34
|
-
it 'returns a email body based on names separated by
|
34
|
+
it 'returns a email body based on names separated by point' do
|
35
35
|
IO.stub(read:
|
36
36
|
<<-EOS
|
37
37
|
test:
|
@@ -39,7 +39,7 @@ describe Freya::Email do
|
|
39
39
|
EOS
|
40
40
|
)
|
41
41
|
|
42
|
-
Freya::Email.new(name: 'test
|
42
|
+
Freya::Email.new(name: 'test.email').body.should eq('This is the test email')
|
43
43
|
end
|
44
44
|
|
45
45
|
it 'raises exception if the key is not found' do
|