parameter_substitution 3.2.0.pre.2 → 3.2.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
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: b1ce2eb4a673fa4ca42d4bfef42b2b18a0b6011dcef6aeb6b8f4c0c0fb30f63b
|
|
4
|
+
data.tar.gz: 41b30435287d1dcb7b0b01686c238a49fad6f1d8bf6b414a96a65099dec17f4b
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 3bdabcf306d69fc596a6202bf718f0bcdf3fd53ef4fa3d1a00135e4fb3745846f80c3a21ccfc2e1e73d0488aab7e2ac45e8ae7b578cde55ddf0f9b98fddfe8d6
|
|
7
|
+
data.tar.gz: e86ae64208c6cdf3bdae88bb951d54b379d9a622af44c7a1a7cfc981886b21c80eaf2ad1315549c14785057804ec95580a69cd2d177369e3a44fd7fd21469e0e
|
|
@@ -43,8 +43,13 @@ class ParameterSubstitution
|
|
|
43
43
|
end
|
|
44
44
|
|
|
45
45
|
# Recursively collects all substitution parameter names, including those
|
|
46
|
-
# nested inside method call arguments
|
|
47
|
-
#
|
|
46
|
+
# nested inside method call arguments.
|
|
47
|
+
#
|
|
48
|
+
# @example
|
|
49
|
+
# # For "<dclid.compare_string(<gclid>, 'a', 'b')>"
|
|
50
|
+
# # returns ["dclid", "gclid"]
|
|
51
|
+
#
|
|
52
|
+
# @return [Array<String>] all parameter names, including nested ones
|
|
48
53
|
def all_substitution_parameter_names
|
|
49
54
|
@expression_list.flat_map { |expr| parameter_names_from_expression(expr) }
|
|
50
55
|
end
|
|
@@ -150,6 +155,11 @@ class ParameterSubstitution
|
|
|
150
155
|
text + (amount > 1 ? 's' : '')
|
|
151
156
|
end
|
|
152
157
|
|
|
158
|
+
# Extracts the parameter name from an expression and recursively collects
|
|
159
|
+
# any nested parameter names from its method call arguments.
|
|
160
|
+
#
|
|
161
|
+
# @param expr [TextExpression, SubstitutionExpression] a single expression node
|
|
162
|
+
# @return [Array<String>] parameter names found in this expression and its arguments
|
|
153
163
|
def parameter_names_from_expression(expr)
|
|
154
164
|
if (name = expr.parameter_name)
|
|
155
165
|
[name] + parameter_names_from_method_calls(expr.try(:method_calls))
|
|
@@ -158,13 +168,19 @@ class ParameterSubstitution
|
|
|
158
168
|
end
|
|
159
169
|
end
|
|
160
170
|
|
|
171
|
+
# Collects parameter names from nested Expression arguments within method calls.
|
|
172
|
+
#
|
|
173
|
+
# @param method_calls [Array<MethodCallExpression>, nil] the method calls to inspect
|
|
174
|
+
# @return [Array<String>] parameter names found in nested expression arguments
|
|
161
175
|
def parameter_names_from_method_calls(method_calls)
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
176
|
+
if method_calls
|
|
177
|
+
method_calls.flat_map do |method_call|
|
|
178
|
+
method_call.arguments.flat_map do |arg|
|
|
179
|
+
arg.is_a?(Expression) ? arg.all_substitution_parameter_names : []
|
|
180
|
+
end
|
|
167
181
|
end
|
|
182
|
+
else
|
|
183
|
+
[]
|
|
168
184
|
end
|
|
169
185
|
end
|
|
170
186
|
end
|
|
@@ -69,6 +69,13 @@ class ParameterSubstitution
|
|
|
69
69
|
parse_expression(context).substitution_parameter_names
|
|
70
70
|
end
|
|
71
71
|
|
|
72
|
+
# Returns all substitution parameter names found in the input string, including
|
|
73
|
+
# those nested inside method call arguments.
|
|
74
|
+
#
|
|
75
|
+
# @param string_with_tokens [String] the input string containing tokens
|
|
76
|
+
# @param mapping [Hash] the mapping of parameters to values
|
|
77
|
+
# @param context_overrides [Hash] optional overrides for context attributes
|
|
78
|
+
# @return [Array<String>] all parameter names, including nested ones
|
|
72
79
|
def find_all_tokens(string_with_tokens, mapping: {}, context_overrides: {})
|
|
73
80
|
context = build_context(string_with_tokens, mapping, context_overrides)
|
|
74
81
|
parse_expression(context).all_substitution_parameter_names
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: parameter_substitution
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 3.2.0
|
|
4
|
+
version: 3.2.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Invoca Development
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2026-02-
|
|
11
|
+
date: 2026-02-19 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: activesupport
|
|
@@ -148,9 +148,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
148
148
|
version: '3.1'
|
|
149
149
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
150
150
|
requirements:
|
|
151
|
-
- - "
|
|
151
|
+
- - ">="
|
|
152
152
|
- !ruby/object:Gem::Version
|
|
153
|
-
version:
|
|
153
|
+
version: '0'
|
|
154
154
|
requirements: []
|
|
155
155
|
rubygems_version: 3.3.27
|
|
156
156
|
signing_key:
|