Class: Djin::ConfigLoader
- Inherits:
-
Object
- Object
- Djin::ConfigLoader
- Defined in:
- lib/djin/config_loader.rb
Overview
rubocop:disable Metrics/ClassLength
Constant Summary collapse
- RESERVED_WORDS =
%w[djin_version variables tasks include].freeze
Class Method Summary collapse
- .load!(template_file_path, context_config: {}, base_directory: '.') ⇒ Object
- .load_files!(*files, context_config: {}, base_directory: '.') ⇒ Object
Instance Method Summary collapse
-
#initialize(template_file_path, context_config: {}, base_directory: '.') ⇒ ConfigLoader
constructor
A new instance of ConfigLoader.
- #load! ⇒ Object
Constructor Details
#initialize(template_file_path, context_config: {}, base_directory: '.') ⇒ ConfigLoader
Returns a new instance of ConfigLoader.
23 24 25 26 27 28 29 30 31 |
# File 'lib/djin/config_loader.rb', line 23 def initialize(template_file_path, context_config: {}, base_directory: '.') @base_directory = Pathname.new(base_directory) @template_file = @base_directory.join(template_file_path) file_not_found!(@template_file) unless @template_file.exist? @template_file_content = Djin.cache.fetch(@template_file.realpath.to_s) { @template_file.read } @context_config = context_config end |
Class Method Details
.load!(template_file_path, context_config: {}, base_directory: '.') ⇒ Object
19 20 21 |
# File 'lib/djin/config_loader.rb', line 19 def self.load!(template_file_path, context_config: {}, base_directory: '.') new(template_file_path, context_config: context_config, base_directory: base_directory).load! end |
.load_files!(*files, context_config: {}, base_directory: '.') ⇒ Object
13 14 15 16 17 |
# File 'lib/djin/config_loader.rb', line 13 def self.load_files!(*files, context_config: {}, base_directory: '.') files.map do |file_path| ConfigLoader.load!(file_path, context_config: context_config, base_directory: base_directory) end&.reduce(:deep_merge) end |
Instance Method Details
#load! ⇒ Object
33 34 35 36 37 38 |
# File 'lib/djin/config_loader.rb', line 33 def load! validate_version! validate_missing_config! file_config end |