hey-you 1.2.3 → 1.3.2

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
  SHA256:
3
- metadata.gz: e45a6c6dcd683af58756e5bc3702ac92e0cd7e0f4fefb469f356002334f33fce
4
- data.tar.gz: b8144f42b5cac765f8610ab05e046524e2ac9a4c5e47f08a7e6f4e7a409c309f
3
+ metadata.gz: 6fc4f5a3d663c2e8496f01efec20e020f02b03088d4a83c182cf1a673deb2886
4
+ data.tar.gz: d442018540664c329f346ebaabd4c558d4da11b39763a703b990dd09d6e8a1dd
5
5
  SHA512:
6
- metadata.gz: a96ab10f4b7dd0c0a07d6e16be547f2c97d2f51f7bf5be91386541fddde61f7739154d3867695ce7e814d6974b1377e4fa64e98239c4ab296ffff20dfe2602c8
7
- data.tar.gz: e1cdb47a072bd632ea89ee6e072bc49afac86abaf570666ce92b2392b10787268552d1b599bdcb059da3488b7cc19c898b72dc3859730ab48514785291e44adf
6
+ metadata.gz: 7cfad0eac54d8256b0347bffeff673e938e265c16ca4adf724390588e77046449bc62cab904171fb8baf114d47e5255cef60fa0d19b6a79f5d7fbcdf6085c113
7
+ data.tar.gz: 64b3e74fb8269048f2fc3dccd3fd49824c4d905ba0dec1376d1c8a7ab659d4af91805a7699c9d4f05e398e6e4aba212fb6bae774d38c30abc4e679b8b47b7f25
@@ -1,4 +1,6 @@
1
1
  # Changelog for hey-you gem
2
+ ## 1.3.0
3
+ - Feature: `body_part` in email builder.
2
4
 
3
5
  ### 1.2.3
4
6
  - Improvement: fix ruby 2.7 warnings
@@ -14,4 +16,4 @@
14
16
 
15
17
  ### 1.2.0
16
18
  - Feature: data source extensions (check readme for more information).
17
- __Attention__: You should rewrite your configuration for use yaml data source!
19
+ __Attention__: You should rewrite your configuration for use yaml data source!
@@ -3,19 +3,36 @@ require_relative '_base'
3
3
  module HeyYou
4
4
  class Builder
5
5
  class Email < Base
6
- attr_reader :subject, :body, :layout, :mailer_class, :mailer_method, :delivery_method
6
+ attr_reader :subject, :body, :layout, :mailer_class, :mailer_method, :delivery_method, :body_parts
7
7
 
8
8
  def build
9
9
  @mailer_class = ch_data.fetch('mailer_class', nil)
10
10
  @mailer_method = ch_data.fetch('mailer_method', nil)
11
11
  @delivery_method = ch_data.fetch('delivery_method', nil)
12
- @body = interpolate(ch_data.fetch('body'), options)
12
+ @body = interpolate(ch_data['body'], options) if ch_data['body']
13
+ @body_parts = interpolate_each(ch_data.fetch('body_parts', nil), options)
13
14
  @subject = interpolate(ch_data.fetch('subject'), options)
14
15
  end
15
16
 
16
17
  def to_hash
17
- { body: body, subject: subject }
18
+ { body: body, subject: subject, body_parts: body_parts }
19
+ end
20
+
21
+ private
22
+
23
+ def interpolate_each(notification_hash, options)
24
+ return notification_hash unless notification_hash.is_a?(Hash)
25
+
26
+ notification_hash.each do |k, v|
27
+ next interpolate_each(v, options) if v.is_a?(Hash)
28
+
29
+ begin
30
+ notification_hash[k] = v % options
31
+ rescue KeyError
32
+ raise InterpolationError, "Failed build notification string `#{v}`: #{err.message}"
33
+ end
34
+ end
18
35
  end
19
36
  end
20
37
  end
21
- end
38
+ end
@@ -1,3 +1,3 @@
1
1
  module HeyYou
2
- VERSION = "1.2.3"
2
+ VERSION = "1.3.2"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hey-you
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.3
4
+ version: 1.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sergey Nesterov
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-07-04 00:00:00.000000000 Z
11
+ date: 2020-10-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: fcm