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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f516a91826753e7aa6bf48cd74ad6828d6c54e68
4
- data.tar.gz: fd77bc3ff363b6f7c1dfe96d453a60e807bbb93a
3
+ metadata.gz: 53629f40cadf24365421fc47dd1d974802507353
4
+ data.tar.gz: b5304900222fa8c0c6f5a32f33536f160a752fba
5
5
  SHA512:
6
- metadata.gz: b7ae9ac7bc9a3a8fa465b37dc6a0e94e091a9be084b7a98164feaa5a5c19157e04e85d55e3402e502fed59e884408113cfa1d46e25296c88b33981d29f671118
7
- data.tar.gz: 143a156a4bd745ec3b2d2810d57038f7de5cd9601f170623695dd64c4fcf4d77ea73935758ee3297bba1a0731297f7a6416e424c9161a54cd24a81b1c636f380
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 email', to: 'test@test.com', subject: 'test_subject).link, 'Email'
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 white spaces.
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
 
@@ -19,13 +19,13 @@ module Freya
19
19
  end
20
20
 
21
21
  def [](name)
22
- name.present? ? name.to_s.split(' ').inject(self.class.config) { |result, n| result.fetch(n) } : nil
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 { |extra|
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
- }.compact
36
+ end.compact
37
37
 
38
38
  extras = extras.empty? ? '' : '?' + extras.join('&')
39
39
 
@@ -1,3 +1,3 @@
1
1
  module Freya
2
- VERSION = "0.3.2"
2
+ VERSION = "1.0.0"
3
3
  end
@@ -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 space' do
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 email').body.should eq('This is the test email')
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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: freya
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.2
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matteo Depalo