hey-you 1.3.2 → 1.4.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +13 -1
- data/lib/hey_you/builder.rb +3 -3
- data/lib/hey_you/builder/email.rb +2 -2
- data/lib/hey_you/config.rb +20 -4
- data/lib/hey_you/config/conigurable.rb +3 -1
- data/lib/hey_you/sender.rb +4 -3
- data/lib/hey_you/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3679941e8f2ff22ed129c4fdbb90c8d8c27f860e2aa1f8514855afec34c86852
|
4
|
+
data.tar.gz: 6a1b5bb70850f69a7a017ac5c29125138ba22ec722d192666360daf9bbb2b1ad
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a6a8430acbcc2c0399c87b899cd61e42915c2d7a5b9d06fac81df719b55bfa59716245ce6c50d12056d4707ceb6c4881017d06d1f444e728df2be6e71b504d02
|
7
|
+
data.tar.gz: 52412155756eaed0bd09aed322cbf34ce933d9a99965327264096834bcf1f70b7c6e5eb2d2d7f36cc8653d7183b0c7d893e94866cd5a2481ba3e0d1696e043a1
|
data/CHANGELOG.md
CHANGED
@@ -1,6 +1,18 @@
|
|
1
1
|
# Changelog for hey-you gem
|
2
|
-
|
2
|
+
|
3
|
+
## 1.4.2
|
4
|
+
- Improvement: Freeze loaded collection to prevent changes notification templates in memory
|
5
|
+
|
6
|
+
## 1.4.1
|
7
|
+
- Improvement: custom complex classes in Sender
|
8
|
+
|
9
|
+
## 1.4.0
|
10
|
+
- Improvement: configs validations for custom classes
|
11
|
+
- Improvement: allow custom classes with '_' in name
|
12
|
+
|
13
|
+
## 1.3.0 - 1.3.4
|
3
14
|
- Feature: `body_part` in email builder.
|
15
|
+
- Fixes
|
4
16
|
|
5
17
|
### 1.2.3
|
6
18
|
- Improvement: fix ruby 2.7 warnings
|
data/lib/hey_you/builder.rb
CHANGED
@@ -37,8 +37,8 @@ module HeyYou
|
|
37
37
|
return
|
38
38
|
end
|
39
39
|
|
40
|
-
|
41
|
-
|
40
|
+
klass_name = ch.to_s.downcase.split('_').map(&:capitalize).join
|
41
|
+
ch_builder = HeyYou::Builder.const_get(klass_name).new(data[ch.to_s], key, **options)
|
42
42
|
instance_variable_set("@#{ch}".to_sym, ch_builder)
|
43
43
|
|
44
44
|
define_ch_method(ch)
|
@@ -74,4 +74,4 @@ module HeyYou
|
|
74
74
|
class DataNotFound < StandardError; end
|
75
75
|
class RequiredChannelNotFound < StandardError; end
|
76
76
|
end
|
77
|
-
end
|
77
|
+
end
|
@@ -10,7 +10,7 @@ module HeyYou
|
|
10
10
|
@mailer_method = ch_data.fetch('mailer_method', nil)
|
11
11
|
@delivery_method = ch_data.fetch('delivery_method', nil)
|
12
12
|
@body = interpolate(ch_data['body'], options) if ch_data['body']
|
13
|
-
@body_parts = interpolate_each(ch_data.fetch('body_parts', nil), options)
|
13
|
+
@body_parts = interpolate_each(ch_data.fetch('body_parts', nil)&.deep_dup, options)
|
14
14
|
@subject = interpolate(ch_data.fetch('subject'), options)
|
15
15
|
end
|
16
16
|
|
@@ -28,7 +28,7 @@ module HeyYou
|
|
28
28
|
|
29
29
|
begin
|
30
30
|
notification_hash[k] = v % options
|
31
|
-
rescue KeyError
|
31
|
+
rescue KeyError => err
|
32
32
|
raise InterpolationError, "Failed build notification string `#{v}`: #{err.message}"
|
33
33
|
end
|
34
34
|
end
|
data/lib/hey_you/config.rb
CHANGED
@@ -50,11 +50,11 @@ module HeyYou
|
|
50
50
|
end
|
51
51
|
|
52
52
|
def collection
|
53
|
-
@collection ||= load_collection
|
53
|
+
@collection ||= deep_freeze(load_collection)
|
54
54
|
end
|
55
55
|
|
56
56
|
def env_collection
|
57
|
-
@env_collection ||= load_env_collection
|
57
|
+
@env_collection ||= deep_freeze(load_env_collection)
|
58
58
|
end
|
59
59
|
|
60
60
|
def registrate_receiver(receiver_class)
|
@@ -62,6 +62,13 @@ module HeyYou
|
|
62
62
|
@registered_receivers << receiver_class
|
63
63
|
end
|
64
64
|
|
65
|
+
def validate_config
|
66
|
+
registered_channels.each do |ch|
|
67
|
+
ch_config = send(ch)
|
68
|
+
ch_config.validate_config if ch_config.respond_to?(:validate_config)
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
65
72
|
# Registrate new custom channel.
|
66
73
|
# For successful registration, in application must be exists:
|
67
74
|
# 1. HeyYou::Channels::<YOUR_CHANNEL_NAME> < HeyYou::Channels::Base
|
@@ -94,12 +101,21 @@ module HeyYou
|
|
94
101
|
# For example, if ch == 'push' will define method #push for class instance.
|
95
102
|
# New method will return instance of channel config instance
|
96
103
|
def define_ch_config_method(ch)
|
97
|
-
|
104
|
+
klass_name = ch.to_s.split('_').map(&:capitalize).join
|
105
|
+
method_proc = -> { self.class.const_get(klass_name).config }
|
98
106
|
self.class.send(:define_method, ch, method_proc)
|
99
107
|
end
|
100
108
|
|
101
109
|
def load_collection
|
102
110
|
data_source.load_data
|
103
111
|
end
|
112
|
+
|
113
|
+
def deep_freeze(val)
|
114
|
+
if val.respond_to? :each
|
115
|
+
val.class == Hash ? val.each { |_, val| deep_freeze(val) } : val.each { |val| deep_freeze(val) }
|
116
|
+
end
|
117
|
+
|
118
|
+
val.freeze unless val.frozen?
|
119
|
+
end
|
104
120
|
end
|
105
|
-
end
|
121
|
+
end
|
@@ -13,6 +13,7 @@ module HeyYou
|
|
13
13
|
def configure(&block)
|
14
14
|
@configured ? raise(AlreadyConfiguredError, 'You already configure HeyYou') : instance_eval(&block)
|
15
15
|
@configured = true
|
16
|
+
instance.validate_config if instance.respond_to?(:validate_config)
|
16
17
|
end
|
17
18
|
|
18
19
|
def config
|
@@ -20,6 +21,7 @@ module HeyYou
|
|
20
21
|
end
|
21
22
|
|
22
23
|
class AlreadyConfiguredError < StandardError; end
|
24
|
+
class RequiredConfigsNotPassed < StandardError; end
|
23
25
|
end
|
24
26
|
end
|
25
|
-
end
|
27
|
+
end
|
data/lib/hey_you/sender.rb
CHANGED
@@ -38,7 +38,7 @@ module HeyYou
|
|
38
38
|
# Fetch receiver's info for sending: phone_number, email, etc
|
39
39
|
subject: receiver.public_send("#{ch}_ch_receive_info"),
|
40
40
|
# Fetch receiver's options like :mailer_class
|
41
|
-
options: receiver.public_send("#{ch}_ch_receive_options") || {}
|
41
|
+
options: receiver.public_send("#{ch}_ch_receive_options").merge(options) || {}
|
42
42
|
}
|
43
43
|
end
|
44
44
|
|
@@ -55,7 +55,8 @@ module HeyYou
|
|
55
55
|
" and options: #{receive_info[ch][:options]}"
|
56
56
|
)
|
57
57
|
receive_options = receive_info[ch].fetch(:options, {}) || {}
|
58
|
-
|
58
|
+
klass_name = ch.to_s.downcase.split('_').map(&:capitalize).join
|
59
|
+
response[ch] = Channels.const_get(klass_name).send!(
|
59
60
|
builder, to: receive_info[ch][:subject], **receive_options
|
60
61
|
)
|
61
62
|
else
|
@@ -89,4 +90,4 @@ module HeyYou
|
|
89
90
|
|
90
91
|
class NotRegisteredReceiver < StandardError; end
|
91
92
|
end
|
92
|
-
end
|
93
|
+
end
|
data/lib/hey_you/version.rb
CHANGED
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.
|
4
|
+
version: 1.4.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:
|
11
|
+
date: 2021-02-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: fcm
|