File tree Expand file tree Collapse file tree
lib/octocatalog-diff/catalog-util
spec/octocatalog-diff/tests/catalog-util Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -65,8 +65,11 @@ def override_enc_parameters(logger)
6565 return unless @options [ :enc_override ] . is_a? ( Array ) && @options [ :enc_override ] . any?
6666 content_structure = YAML . load ( content )
6767 @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
7073 end
7174 @content = content_structure . to_yaml
7275 end
Original file line number Diff line number Diff line change 154154 logs = @logger_str . string . split ( /\n / ) . compact . map { |x | OctocatalogDiff ::Spec . strip_log_message ( x ) }
155155 expect ( logs ) . to include ( 'DEBUG - ENC override: foo = "bar"' )
156156 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
157170 end
158171
159172 describe '#merge_enc_param' do
You can’t perform that action at this time.
0 commit comments