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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: bca32cfa7b51b8e6ba8b5869fc08861ddd0baed7391e37896e9790034bf0320b
4
- data.tar.gz: 5f5962eaea832be5c87576b930f9d687e3ab7a4ec691eb08b9b5a57cb8e8f5a2
3
+ metadata.gz: 652fa21e199c69608d3a5bccec4a1702b4ffb547950cc0a4cdecede13100398d
4
+ data.tar.gz: 10d9e9b2b207ef9d7af899115b1703794fd5821249bb232fb1fc1e51f29d14fe
5
5
  SHA512:
6
- metadata.gz: 47ec923a9b374213a31889efd74ccb5c55928e79aa474b6ebe2243705fd59d8466657e79df765cfe590f7b823177b64bf9ba53a9ea38020a6eca4412ec138bf4
7
- data.tar.gz: 23476701f1f3cf159d2c7b30cc28a76007e9d4908caca6d5c94b258a40962ac7df8b94b66eaf12b395dae4c9c428bed50a405ef04386272dfb513ce292a76802
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 interpret_positional_params(text, params)
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.0
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: 2020-12-04 00:00:00.000000000 Z
11
+ date: 2021-04-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails