tolliver 2.1.0 → 2.1.1
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/lib/tolliver/services/notification_service.rb +15 -3
- 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: 652fa21e199c69608d3a5bccec4a1702b4ffb547950cc0a4cdecede13100398d
|
4
|
+
data.tar.gz: 10d9e9b2b207ef9d7af899115b1703794fd5821249bb232fb1fc1e51f29d14fe
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cf3765a95bde23c800142e846a64548dc6fbf293c9bc65027eccddfe24b0f88505ec9310b57821c7268711e1ba8fe0b81ed352a60565ccee6375a797bfb27895
|
7
|
+
data.tar.gz: '08c5fcda8093414dc792608fa8d21cff313862f054b21e65efc21c4c4045fb5d854dfc4fc296829ad95874b7b9f35f6439d83b601d391bc62c59d0cb0ad72348'
|
@@ -35,8 +35,8 @@ module Tolliver
|
|
35
35
|
|
36
36
|
# Interpret params and store it in DB
|
37
37
|
params = map_params(options[:params] || {})
|
38
|
-
notification.message = interpret_named_params(notification_template.message, params)
|
39
|
-
notification.subject = interpret_named_params(notification_template.subject, params)
|
38
|
+
notification.message = eval_expressions(interpret_named_params(notification_template.message, params))
|
39
|
+
notification.subject = eval_expressions(interpret_named_params(notification_template.subject, params))
|
40
40
|
|
41
41
|
# Notification template
|
42
42
|
notification.notification_template = notification_template
|
@@ -147,7 +147,19 @@ module Tolliver
|
|
147
147
|
end
|
148
148
|
end
|
149
149
|
|
150
|
-
def
|
150
|
+
def eval_expressions(text)
|
151
|
+
text.gsub(/%{[^{}]+}/) do |match|
|
152
|
+
template_to_eval = match[2..-2].to_s.strip
|
153
|
+
begin
|
154
|
+
evaluated_match = eval(template_to_eval) # evaluate match
|
155
|
+
rescue
|
156
|
+
evaluated_match = ""
|
157
|
+
end
|
158
|
+
evaluated_match
|
159
|
+
end
|
160
|
+
end
|
161
|
+
|
162
|
+
def interpret_positional_params_and_eval_expressions(text, params)
|
151
163
|
text.gsub(/%{[^{}]+}/) do |match|
|
152
164
|
template_to_eval = match[2..-2].gsub(/%([0-9]+)/, "params[\\1]") # substitute all %1, %2, %3, ... to a form which can be evaluated
|
153
165
|
begin
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tolliver
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.1.
|
4
|
+
version: 2.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Matěj Outlý
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-04-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|