File tree Expand file tree Collapse file tree 2 files changed +18
-2
lines changed
lib/octocatalog-diff/catalog-util
spec/octocatalog-diff/tests/catalog-util Expand file tree Collapse file tree 2 files changed +18
-2
lines changed Original file line number Diff line number Diff line change @@ -65,8 +65,11 @@ def override_enc_parameters(logger)
65
65
return unless @options [ :enc_override ] . is_a? ( Array ) && @options [ :enc_override ] . any?
66
66
content_structure = YAML . load ( content )
67
67
@options [ :enc_override ] . each do |x |
68
- merge_enc_param ( content_structure , x . key , x . value )
69
- logger . debug "ENC override: #{ x . key } #{ x . value . nil? ? 'DELETED' : '= ' + x . value . inspect } "
68
+ keys = x . key . is_a? ( Regexp ) ? content_structure . keys . select { |y | x . key . match ( y ) } : [ x . key ]
69
+ keys . each do |key |
70
+ merge_enc_param ( content_structure , key , x . value )
71
+ logger . debug "ENC override: #{ key } #{ x . value . nil? ? 'DELETED' : '= ' + x . value . inspect } "
72
+ end
70
73
end
71
74
@content = content_structure . to_yaml
72
75
end
Original file line number Diff line number Diff line change 154
154
logs = @logger_str . string . split ( /\n / ) . compact . map { |x | OctocatalogDiff ::Spec . strip_log_message ( x ) }
155
155
expect ( logs ) . to include ( 'DEBUG - ENC override: foo = "bar"' )
156
156
end
157
+
158
+ it 'should handle regexp overrides' do
159
+ options = {
160
+ enc_override : [ OctocatalogDiff ::API ::V1 ::Override . create_from_input ( '/o+/=(string)bar' ) ]
161
+ }
162
+ subject = described_class . allocate
163
+ subject . instance_variable_set ( '@options' , options )
164
+ subject . instance_variable_set ( '@content' , "---\n foo: baz\n fizz: buzz\n " )
165
+ subject . send ( :override_enc_parameters , @logger )
166
+ expect ( subject . instance_variable_get ( '@content' ) ) . to eq ( "---\n foo: bar\n fizz: buzz\n " )
167
+ logs = @logger_str . string . split ( /\n / ) . compact . map { |x | OctocatalogDiff ::Spec . strip_log_message ( x ) }
168
+ expect ( logs ) . to include ( 'DEBUG - ENC override: foo = "bar"' )
169
+ end
157
170
end
158
171
159
172
describe '#merge_enc_param' do
You can’t perform that action at this time.
0 commit comments