Class: I18nContextGenerator::SupplementalContext

Inherits:
Object
  • Object
show all
Defined in:
lib/i18n_context_generator/supplemental_context.rb

Overview

Converts configured text files and caller-provided values into context records.

Class Method Summary collapse

Class Method Details

.load(files:, runtime:) ⇒ Object



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/i18n_context_generator/supplemental_context.rb', line 18

def load(files:, runtime:)
  validate_files!(files)
  validate_runtime!(runtime)

  file_sources = files.map { |path| load_file(path) }
  runtime_sources = runtime.map do |name, content|
    ContextSource.new(
      kind: :runtime,
      name: scrub_text(name),
      content: scrub_text(content)
    )
  end

  (file_sources + runtime_sources).freeze
end