Skip to content

Commit

Permalink
Add @system_wrapper.module_eval to defineinator, flaginator, so envir…
Browse files Browse the repository at this point in the history
…oment variables, #{ENV['VARIABLE']}, are parsed now.
  • Loading branch information
Claudio Emanoel Barbosa Lima committed Apr 22, 2024
1 parent 78e208b commit f75275c
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 11 deletions.
36 changes: 30 additions & 6 deletions lib/ceedling/defineinator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

class Defineinator

constructor :configurator, :streaminator, :config_matchinator
constructor :configurator, :streaminator, :config_matchinator, :system_wrapper

def setup
@topkey = :defines
Expand All @@ -38,9 +38,16 @@ def defines_defined?(context:)
# (But, we can also lookup defines symbol lists within framework configurations--:unity, :cmock, :cexception)
def defines(topkey:@topkey, subkey:, filepath:nil)
defines = @config_matchinator.get_config(primary:topkey, secondary:subkey)

if defines == nil then return []
elsif defines.is_a?(Array) then return defines.flatten # Flatten to handle list-nested YAML aliases
ret_defines = []

if defines == nil
ret_defines = []
elsif defines.is_a?(Array)
defines_parsed = defines.flatten # Flatten to handle list-nested YAML aliases
defines_parsed.each do |element|
element = element.replace( @system_wrapper.module_eval( element ) ) if (element =~ RUBY_STRING_REPLACEMENT_PATTERN)
end
ret_defines = defines_parsed
elsif defines.is_a?(Hash)
@config_matchinator.validate_matchers(hash:defines, section:@topkey, context:subkey)

Expand All @@ -51,11 +58,28 @@ def defines(topkey:@topkey, subkey:, filepath:nil)
context: subkey
}

return @config_matchinator.matches?(**arg_hash)
defines_parsed = @config_matchinator.matches?(**arg_hash)
defines_parsed.each do |key, value|
key = key.replace( @system_wrapper.module_eval( key ) ) if (key =~ RUBY_STRING_REPLACEMENT_PATTERN)
if value.is_a?(Array)
value.each do |v|
v = v.replace( @system_wrapper.module_eval( v ) ) if (v =~ RUBY_STRING_REPLACEMENT_PATTERN)
end
elsif value.is_a?(Hash)
value.each do |k,v|
k = k.replace( @system_wrapper.module_eval( k ) ) if (k =~ RUBY_STRING_REPLACEMENT_PATTERN)
v = v.replace( @system_wrapper.module_eval( v ) ) if (v =~ RUBY_STRING_REPLACEMENT_PATTERN)
end
else
value = value.replace( @system_wrapper.module_eval( value ) ) if (value =~ RUBY_STRING_REPLACEMENT_PATTERN)
end
end

ret_defines = defines_parsed
end

# Handle unexpected config element type
return []
return ret_defines
end

# Optionally create a command line compilation symbol that is a test file's sanitized/converted name
Expand Down
34 changes: 29 additions & 5 deletions lib/ceedling/flaginator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@

class Flaginator

constructor :configurator, :streaminator, :config_matchinator
constructor :configurator, :streaminator, :config_matchinator, :system_wrapper

def setup
@section = :flags
Expand All @@ -42,9 +42,16 @@ def flags_defined?(context:, operation:nil)

def flag_down(context:, operation:, filepath:nil)
flags = @config_matchinator.get_config(primary:@section, secondary:context, tertiary:operation)
ret_flags = []

if flags == nil then return []
elsif flags.is_a?(Array) then return flags.flatten # Flatten to handle list-nested YAML aliases
if flags == nil
ret_flags = []
elsif flags.is_a?(Array)
flags_parsed = flags.flatten # Flatten to handle list-nested YAML aliases
flags_parsed.each do |element|
element = element.replace( @system_wrapper.module_eval( element ) ) if (element =~ RUBY_STRING_REPLACEMENT_PATTERN)
end
ret_flags = flags_parsed
elsif flags.is_a?(Hash)
@config_matchinator.validate_matchers(hash:flags, section:@section, context:context, operation:operation)

Expand All @@ -56,11 +63,28 @@ def flag_down(context:, operation:, filepath:nil)
operation: operation
}

return @config_matchinator.matches?(**arg_hash)
flags_parsed = @config_matchinator.matches?(**arg_hash)
flags_parsed.each do |key, value|
key = key.replace( @system_wrapper.module_eval( key ) ) if (key =~ RUBY_STRING_REPLACEMENT_PATTERN)
if value.is_a?(Array)
value.each do |v|
v = v.replace( @system_wrapper.module_eval( v ) ) if (v =~ RUBY_STRING_REPLACEMENT_PATTERN)
end
elsif value.is_a?(Hash)
value.each do |k,v|
k = k.replace( @system_wrapper.module_eval( k ) ) if (k =~ RUBY_STRING_REPLACEMENT_PATTERN)
v = v.replace( @system_wrapper.module_eval( v ) ) if (v =~ RUBY_STRING_REPLACEMENT_PATTERN)
end
else
value = value.replace( @system_wrapper.module_eval( value ) ) if (value =~ RUBY_STRING_REPLACEMENT_PATTERN)
end
end

ret_flags = flags_parsed
end

# Handle unexpected config element type
return []
return ret_flags
end

end
2 changes: 2 additions & 0 deletions lib/ceedling/objects.yml
Original file line number Diff line number Diff line change
Expand Up @@ -205,12 +205,14 @@ flaginator:
- configurator
- streaminator
- config_matchinator
- system_wrapper

defineinator:
compose:
- configurator
- streaminator
- config_matchinator
- system_wrapper

generator:
compose:
Expand Down

0 comments on commit f75275c

Please sign in to comment.