Class: ActiveLrs::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/active_lrs/configuration.rb

Overview

Stores configuration for xAPI/LRS interactions.

This includes the xAPI profile server URL, default locale, and remote LRS instances loaded from a YAML configuration file.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(env: ENV["RAILS_ENV"] || "development") ⇒ void

Initializes a new Configuration instance.

Loads the remote LRS endpoints from config/remote_lrs.yml if it exists. If the file or the environment-specific section is missing, defaults to an empty array.

Parameters:

  • env (String) (defaults to: ENV["RAILS_ENV"] || "development")

    The Rails environment or other environment name to load (default: ENV || “development”)



25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/active_lrs/configuration.rb', line 25

def initialize(env: ENV["RAILS_ENV"] || "development")
  @xapi_profile_server_url = "https://profiles.adlnet.gov/"
  @default_locale = "en-US"

  path = File.join(Dir.pwd, "config", "remote_lrs.yml")
  if File.exist?(path)
    raw  = ERB.new(File.read(path)).result
    yaml = YAML.safe_load(raw, aliases: true)
    env_config = yaml.fetch(env, {})
    @remote_lrs_instances = env_config["endpoints"] || []
  else
    @remote_lrs_instances = []
  end
end

Instance Attribute Details

#default_localeString

Returns Default locale to use for xAPI statements (default: “en-US”).

Returns:

  • (String)

    Default locale to use for xAPI statements (default: “en-US”)



11
12
13
# File 'lib/active_lrs/configuration.rb', line 11

def default_locale
  @default_locale
end

#remote_lrs_instancesArray<Hash>

Returns List of remote LRS endpoints loaded from config/remote_lrs.yml.

Returns:

  • (Array<Hash>)

    List of remote LRS endpoints loaded from config/remote_lrs.yml



14
15
16
# File 'lib/active_lrs/configuration.rb', line 14

def remote_lrs_instances
  @remote_lrs_instances
end

#xapi_profile_server_urlString

Returns The URL of the xAPI profile server (default: “profiles.adlnet.gov/”).

Returns:



8
9
10
# File 'lib/active_lrs/configuration.rb', line 8

def xapi_profile_server_url
  @xapi_profile_server_url
end