Class: RegoValidate::ConfigLoader
- Inherits:
-
Object
- Object
- RegoValidate::ConfigLoader
- Defined in:
- lib/ruby/rego/cli.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.
369 370 371 372 373 374 |
# File 'lib/ruby/rego/cli.rb', line 369 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.
388 389 390 391 392 393 |
# File 'lib/ruby/rego/cli.rb', line 388 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.
380 381 382 |
# File 'lib/ruby/rego/cli.rb', line 380 def read_policy(path) read_file(path, "policy") end |