class RBT::UseFlags

Constants

REGISTERED_COMPILE_FLAGS
#

REGISTERED_COMPILE_FLAGS

bl $RBT/YAML/registered_compile_flags.yml Right now it is hardcoded.

#

Public Class Methods

new( run_already = true ) click to toggle source
#

initialize

Note: the constant USE_FLAGS can be found in the shared code part, in a yaml file. REGISTERED_COMPILE_FLAGS can be found in RBT_Base.rb

#
# File lib/rbt/utility_scripts/use_flags.rb, line 42
def initialize(
    run_already = true
  )
  reset
  run if run_already
end

Public Instance Methods

check_for_environment() click to toggle source
#

check_for_environment

Here, we must check if the user did set to use a specific USE environment flag.

#
# File lib/rbt/utility_scripts/use_flags.rb, line 84
def check_for_environment
  @environment_use_flags = ENV['USE'].dup if ENV['USE']
end
environment_use_flags()
environment_use_flags?() click to toggle source
#

environment_use_flags?

Stores ENV stuff.

#
# File lib/rbt/utility_scripts/use_flags.rb, line 102
def environment_use_flags?
  @environment_use_flags
end
Also aliased as: environment_use_flags
is_included?( this_use_flag = use_flags? ) click to toggle source
#

is_included?

Find out if the use-flag we want to use is already registered.

#
# File lib/rbt/utility_scripts/use_flags.rb, line 111
def is_included?(
    this_use_flag = use_flags?
  )
  @string = ''.dup # Empty it again here.
  if @registered_compile_flags.keys.include? this_use_flag
    @string << ' '+@registered_compile_flags[this_use_flag]
  elsif this_use_flag.include? ' '
    this_use_flag.split(' ').each { |splitted|
      if @registered_compile_flags.keys.include? splitted
        @string << ' '+@registered_compile_flags[splitted]
      end
    }
  else # Else it may be enable or disable
       # We keep that consistent.
    if    this_use_flag.include? 'enable'
      is_included? value.gsub(/enable/,'with')
    elsif this_use_flag.include? 'disable'
      is_included? value.gsub(/disable/,'without')
    end
  end
  @string.strip!
end
reset() click to toggle source
#

reset

#
Calls superclass method RBT::Base#reset
# File lib/rbt/utility_scripts/use_flags.rb, line 52
def reset
  super()
  # ======================================================================= #
  # === @environment_use_flags
  # ======================================================================= #
  @environment_use_flags = nil
  dataset = YAML.load_file(FILE_USE_FLAGS) if File.exist?(FILE_USE_FLAGS)
  # === @use_flags
  @use_flags = dataset['USE'].strip # {"USE"=>"-arts +mp3 +ogg"}
  # === @registered_compile_flags
  @registered_compile_flags = REGISTERED_COMPILE_FLAGS
end
run() click to toggle source
#

run (run tag)

#
# File lib/rbt/utility_scripts/use_flags.rb, line 144
def run
  sanitize_registered_compile_flags    
  check_for_environment
  is_included?
end
sanitize_registered_compile_flags() click to toggle source
#

sanitize_registered_compile_flags

This is needed to make proper default values for the ‘+’ use flags.

It is run once on startup. Afterwards it does not need to be run again.

#
# File lib/rbt/utility_scripts/use_flags.rb, line 72
def sanitize_registered_compile_flags
  @registered_compile_flags.dup.each_pair { |k, v|
    @registered_compile_flags[ k[1..-1] ] = v if k.include? '+' # k[1..-1] includes all but leading +
  }
end
string()
Alias for: string?
string?() click to toggle source
#

string?

#
# File lib/rbt/utility_scripts/use_flags.rb, line 137
def string?
  @string # Use this string as the return value.
end
Also aliased as: string
use_flags?() click to toggle source
#

use_flags?

This will simply return all flags that are available. (Rarely used.)

#
# File lib/rbt/utility_scripts/use_flags.rb, line 93
def use_flags?
  @use_flags
end