parameter_substitution 3.0.0.pre.1 → 3.0.0.pre.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 +4 -4
- data/lib/parameter_substitution/version.rb +1 -1
- data/lib/parameter_substitution.rb +32 -6
- 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: 470d5abf687490b1aa41c54794478f9c0ffa4fd904b360cab55b60351eb2e9f7
|
|
4
|
+
data.tar.gz: acda768f6ff4e072b6769cb4cbb3d82cf81951ce0cc9a210a5fc541f04e006a9
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 360e3825227457357b8c4a244862f889171d2f4c369e82b3a2907f2d8114297da9094fb4914c20f8885b42f544daf6563e0075f8fc9f02a4071ac2fc0ebb0d79
|
|
7
|
+
data.tar.gz: c339269735f7ba01a811c068a06ac5bb8a4100848eca49cc01f5e8903854c8cca570def8233a6cc0ee464b9525724d3c580a9f10fe5ff8b360d32e2457356508
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
# See lib/parameter_substitution/readme.md
|
|
4
4
|
|
|
5
5
|
require 'active_support/all'
|
|
6
|
+
require 'set'
|
|
6
7
|
require "parameter_substitution/context"
|
|
7
8
|
require "parameter_substitution/parse_error"
|
|
8
9
|
require "parameter_substitution/parser"
|
|
@@ -63,17 +64,17 @@ class ParameterSubstitution
|
|
|
63
64
|
ParameterSubstitution.config = config
|
|
64
65
|
end
|
|
65
66
|
|
|
66
|
-
def find_tokens(string_with_tokens, mapping: {}, context_overrides:
|
|
67
|
+
def find_tokens(string_with_tokens, mapping: {}, context_overrides: {})
|
|
67
68
|
context = build_context(string_with_tokens, mapping, context_overrides)
|
|
68
69
|
parse_expression(context).substitution_parameter_names
|
|
69
70
|
end
|
|
70
71
|
|
|
71
|
-
def find_formatters(string_with_tokens, mapping: {}, context_overrides:
|
|
72
|
+
def find_formatters(string_with_tokens, mapping: {}, context_overrides: {})
|
|
72
73
|
context = build_context(string_with_tokens, mapping, context_overrides)
|
|
73
74
|
parse_expression(context).method_names
|
|
74
75
|
end
|
|
75
76
|
|
|
76
|
-
def find_warnings(string_with_tokens, mapping: {}, context_overrides:
|
|
77
|
+
def find_warnings(string_with_tokens, mapping: {}, context_overrides: {})
|
|
77
78
|
context = build_context(string_with_tokens, mapping, context_overrides)
|
|
78
79
|
parse_expression(context).parameter_and_method_warnings || []
|
|
79
80
|
end
|
|
@@ -83,18 +84,43 @@ class ParameterSubstitution
|
|
|
83
84
|
# Build context with optional overrides
|
|
84
85
|
# @param [String] string_with_tokens The input string containing tokens
|
|
85
86
|
# @param [Hash] mapping The mapping of parameters to values
|
|
86
|
-
# @param [Hash
|
|
87
|
+
# @param [Hash] context_overrides Optional overrides for context attributes
|
|
87
88
|
# @return [ParameterSubstitution::Context] The constructed context
|
|
89
|
+
# @raise [ArgumentError] if context_overrides contains invalid keys
|
|
88
90
|
def build_context(string_with_tokens, mapping, context_overrides)
|
|
89
|
-
|
|
91
|
+
validate_context_overrides!(context_overrides)
|
|
92
|
+
|
|
90
93
|
base_options = {
|
|
91
94
|
input: string_with_tokens,
|
|
92
95
|
mapping: mapping
|
|
93
96
|
}
|
|
94
97
|
|
|
95
|
-
ParameterSubstitution::Context.new(**
|
|
98
|
+
ParameterSubstitution::Context.new(**context_overrides.merge(base_options))
|
|
96
99
|
end
|
|
97
100
|
|
|
101
|
+
# @param [Hash] context_overrides The overrides to validate
|
|
102
|
+
# @raise [ArgumentError] if context_overrides contains invalid keys
|
|
103
|
+
def validate_context_overrides!(context_overrides)
|
|
104
|
+
return if context_overrides.empty?
|
|
105
|
+
|
|
106
|
+
valid_keys = %i[
|
|
107
|
+
required_parameters
|
|
108
|
+
parameter_start
|
|
109
|
+
parameter_end
|
|
110
|
+
destination_encoding
|
|
111
|
+
allow_unknown_replacement_parameters
|
|
112
|
+
allow_nil
|
|
113
|
+
allow_unmatched_parameter_end
|
|
114
|
+
].to_set
|
|
115
|
+
|
|
116
|
+
invalid_keys = context_overrides.keys.reject { |key| valid_keys.include?(key.to_sym) }
|
|
117
|
+
|
|
118
|
+
if invalid_keys.any?
|
|
119
|
+
invalid_keys_list = invalid_keys.join(", ")
|
|
120
|
+
valid_keys_list = valid_keys.sort.join(", ")
|
|
121
|
+
raise ArgumentError, "Invalid context_overrides keys: #{invalid_keys_list}. Valid keys are: #{valid_keys_list}"
|
|
122
|
+
end
|
|
123
|
+
end
|
|
98
124
|
|
|
99
125
|
def parse_expression(context)
|
|
100
126
|
cst = ParameterSubstitution::Parser.new(
|
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.0.0.pre.
|
|
4
|
+
version: 3.0.0.pre.2
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Invoca Development
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2025-11-
|
|
11
|
+
date: 2025-11-18 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: activesupport
|