Class: RegoValidate::ConfigLoader
- Inherits:
-
Object
- Object
- RegoValidate::ConfigLoader
- Defined in:
- lib/ruby/rego/cli/loading.rb
Overview
Loads policy and input configuration files.
Constant Summary collapse
- JSON_EXTENSIONS =
[".json"].freeze
Instance Method Summary collapse
-
#initialize(reporter:, parser:, yaml_aliases:) ⇒ ConfigLoader
constructor
Create a config loader.
-
#read_config(path) ⇒ ConfigLoadResult
Read and parse the config file content.
-
#read_policy(path) ⇒ String?
Read the policy file content.
Constructor Details
#initialize(reporter:, parser:, yaml_aliases:) ⇒ ConfigLoader
Create a config loader.
16 17 18 19 20 21 |
# File 'lib/ruby/rego/cli/loading.rb', line 16 def initialize(reporter:, parser:, yaml_aliases:) @reporter = reporter @parser = parser @json_extensions = JSON_EXTENSIONS @yaml_aliases = yaml_aliases end |
Instance Method Details
#read_config(path) ⇒ ConfigLoadResult
Read and parse the config file content.
35 36 37 38 39 40 |
# File 'lib/ruby/rego/cli/loading.rb', line 35 def read_config(path) content = read_file(path, "config") return ConfigLoadResult.new(success: false) unless content parse_config(content, path) end |
#read_policy(path) ⇒ String?
Read the policy file content.
27 28 29 |
# File 'lib/ruby/rego/cli/loading.rb', line 27 def read_policy(path) read_file(path, "policy") end |