Class: Flaginator

Inherits:
Object show all
Defined in:
lib/ceedling/flaginator.rb

Overview

:flags:

:test:
  :compile:                   # Equivalent to [test][compile]['*'] -- i.e. same extra flags for all test executables
    - -foo
    - -Wall
  :link:                      # Equivalent to [test][link]['*'] -- i.e. same flags for all test executables
    - --bar
    - --baz

Instance Method Summary collapse

Instance Method Details

#flag_down(context:, operation:, filepath: nil, default: []) ⇒ Object



43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# File 'lib/ceedling/flaginator.rb', line 43

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

  if flags == nil then return default
  # Flatten to handle list-nested YAML aliasing (should have already been flattened during validation)
  elsif flags.is_a?(Array) then return flags.flatten
  elsif flags.is_a?(Hash)
    arg_hash = {
      hash: flags,
      filepath: filepath,
      section: @section,
      context: context,
      operation: operation
    }

    return @config_matchinator.matches?(**arg_hash)
  end

  # Handle unexpected config element type
  return []
end

#flags_defined?(context:, operation: nil) ⇒ Boolean

Returns:

  • (Boolean)


39
40
41
# File 'lib/ceedling/flaginator.rb', line 39

def flags_defined?(context:, operation:nil)
  return @config_matchinator.config_include?(primary:@section, secondary:context, tertiary:operation)
end

#setupObject



35
36
37
# File 'lib/ceedling/flaginator.rb', line 35

def setup
  @section = :flags
end