Class: DocGuard::Config
- Inherits:
-
Object
- Object
- DocGuard::Config
- Defined in:
- lib/doc_guard/config.rb
Overview
Handles configuration for DocGuard by loading values from:
-
Explicit parameters (highest priority)
-
Environment variables
-
YAML config file (.doc_guard.yml)
-
Internal defaults (lowest priority)
This class supports usage in CLI, CI/CD pipelines, or manual scripts without requiring any Rails integration.
Constant Summary collapse
- DEFAULT_CONFIG_FILE_PATH =
".doc_guard.yml"- DEFAULT_DIGESTS_STORE_FILE_PATH =
".doc_guard_digests.json"- DEFAULT_DOCUMENTATION_PATH =
"docs"
Instance Attribute Summary collapse
-
#config_file_path ⇒ String
readonly
Resolved path to the digests JSON file.
-
#digests_store_file_path ⇒ String
readonly
Resolved path to the digests JSON file.
-
#documentation_path ⇒ String
readonly
Resolved documentation path.
Instance Method Summary collapse
-
#initialize(digests_store_file_path: nil, documentation_path: nil, config_file_path: nil) ⇒ Config
constructor
Initialize configuration for DocGuard.
Constructor Details
#initialize(digests_store_file_path: nil, documentation_path: nil, config_file_path: nil) ⇒ Config
Initialize configuration for DocGuard.
You can pass ‘nil` to `digests_store_file_path` or `documentation_path` to allow fallback to ENV, config file, or defaults.
rubocop:disable Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/doc_guard/config.rb', line 31 def initialize(digests_store_file_path: nil, documentation_path: nil, config_file_path: nil) @config_file_path = config_file_path || ENV["DOC_GUARD_CONFIG_FILE_PATH"] || DEFAULT_CONFIG_FILE_PATH config = load_config_file(@config_file_path) @documentation_path = documentation_path || ENV["DOC_GUARD_DOCUMENTATION_PATH"] || config["documentation_path"] || DEFAULT_DOCUMENTATION_PATH @digests_store_file_path = digests_store_file_path || ENV["DOC_GUARD_DIGESTS_STORE_FILE_PATH"] || config["digests_store_file_path"] || DEFAULT_DIGESTS_STORE_FILE_PATH end |
Instance Attribute Details
#config_file_path ⇒ String (readonly)
Returns Resolved path to the digests JSON file.
60 61 62 |
# File 'lib/doc_guard/config.rb', line 60 def config_file_path @config_file_path end |
#digests_store_file_path ⇒ String (readonly)
Returns Resolved path to the digests JSON file.
57 58 59 |
# File 'lib/doc_guard/config.rb', line 57 def digests_store_file_path @digests_store_file_path end |
#documentation_path ⇒ String (readonly)
Returns Resolved documentation path.
54 55 56 |
# File 'lib/doc_guard/config.rb', line 54 def documentation_path @documentation_path end |