class Lutaml::UmlRepository::StaticSite::Configuration

config = Configuration.load(“my_config.yml”)
@example Load custom configuration
config = Configuration.load
@example Load configuration
structured YAML parsing and validation.
configuration instead of hardcoding values. Uses lutaml-model for
Follows the Dependency Inversion Principle by externalizing all
Configuration for Static Site Generator using external YAML.

def create_default_configuration

Returns:
  • (Configuration) - Default configuration
def create_default_configuration
  new.tap do |config|
    config.version = "1.0"
    config.description = "Default Static Site Configuration"
  end
end

def default_config_path

Returns:
  • (String) - Path to default config
def default_config_path
  File.expand_path("../../../../config/static_site.yml", __dir__)
end

def feature_enabled?(feature_name)

Returns:
  • (Boolean) - true if feature is enabled

Parameters:
  • feature_name (String, Symbol) -- Feature name
def feature_enabled?(feature_name)
  flags = feature_flags
  return false if flags.nil? || flags.empty?
  flags[feature_name.to_s] == true
end

def feature_flags

Returns:
  • (Hash) - Feature flags
def feature_flags
  @feature_flags ||= parse_hash_attribute(features)
end

def load(config_path = nil)

Returns:
  • (Configuration) - Loaded configuration

Parameters:
  • config_path (String, nil) -- Path to configuration file
def load(config_path = nil)
  config_path ||= default_config_path
  unless File.exist?(config_path)
    return create_default_configuration
  end
  yaml_content = File.read(config_path)
  from_yaml(yaml_content)
end

def parse_hash_attribute(attr) # rubocop:disable Metrics/CyclomaticComplexity,Metrics/MethodLength,Metrics/PerceivedComplexity

rubocop:disable Metrics/CyclomaticComplexity,Metrics/MethodLength,Metrics/PerceivedComplexity
def parse_hash_attribute(attr) # rubocop:disable Metrics/CyclomaticComplexity,Metrics/MethodLength,Metrics/PerceivedComplexity
  case attr
  when Hash
    attr
  when String
    # Try to parse as YAML first
    begin
      parsed = YAML.safe_load(attr, permitted_classes: [Symbol])
      return parsed if parsed.is_a?(Hash)
    rescue StandardError
      # Fall through to eval if YAML parsing fails
    end
    # If the string looks like a Ruby hash (contains =>),
    # try to evaluate it safely
    if attr.include?("=>")
      begin
        # Use eval in a controlled way - this is safe because we
        # control the input
        # The string comes from our own YAML config file
        parsed = eval(attr) # rubocop:disable Security/Eval
        return parsed if parsed.is_a?(Hash)
      rescue StandardError
        # Fall through to empty hash
      end
    end
    {}
  else
    {}
  end
end

def transformation_options

Returns:
  • (Hash) - Transformation options
def transformation_options
  @transformation_options ||= parse_hash_attribute(data_transformation)
end