Class: CleoQualityReview::Configuration
- Inherits:
-
Object
- Object
- CleoQualityReview::Configuration
- Defined in:
- lib/cleo_quality_review/configuration.rb
Overview
Configuration for file include/exclude patterns and runtime defaults
Defined Under Namespace
Classes: Loader
Constant Summary collapse
- DEFAULT_CONFIG_PATH =
File.("../../config/default.yml", __dir__)
- LOCAL_CONFIG_PATH =
".cleo_quality_review.yaml"- ALL_TOOLS =
"AllTools"- INCLUDE =
"Include"- EXCLUDE =
"Exclude"- INHERIT_FROM =
"inherit_from"- GEM_DEFAULT_ALIASES =
["default", "gem:default"].freeze
- MATCH_FLAGS =
File::FNM_PATHNAME | File::FNM_EXTGLOB
Class Method Summary collapse
-
.default_max_concurrency ⇒ Integer
Host processor count used as the default worker cap.
-
.env_max_concurrency ⇒ Integer?
Read the max worker count from the environment, if configured.
-
.load(root: Dir.pwd) ⇒ Configuration
Load configuration from default and local config files.
-
.max_concurrency ⇒ Integer
Resolve the configured worker count for concurrent checks.
-
.max_concurrency_limit(value) ⇒ Integer
Clamp a worker count to a usable lower bound.
Instance Method Summary collapse
-
#exclude_patterns ⇒ Array<String>
Glob patterns for files to exclude.
-
#include_patterns ⇒ Array<String>
Glob patterns for files to include.
-
#initialize(data) ⇒ Configuration
constructor
A new instance of Configuration.
-
#target_file?(path) ⇒ Boolean
Check if a file should be included based on configuration patterns.
Constructor Details
#initialize(data) ⇒ Configuration
Returns a new instance of Configuration.
60 61 62 |
# File 'lib/cleo_quality_review/configuration.rb', line 60 def initialize(data) @data = data end |
Class Method Details
.default_max_concurrency ⇒ Integer
Returns host processor count used as the default worker cap.
54 55 56 |
# File 'lib/cleo_quality_review/configuration.rb', line 54 def self.default_max_concurrency Etc.nprocessors end |
.env_max_concurrency ⇒ Integer?
Read the max worker count from the environment, if configured.
47 48 49 50 |
# File 'lib/cleo_quality_review/configuration.rb', line 47 def self.env_max_concurrency value = ENV["CLEO_QUALITY_REVIEW_MAX_CONCURRENCY"] value && !value.strip.empty? ? Integer(value) : nil end |
.load(root: Dir.pwd) ⇒ Configuration
Load configuration from default and local config files
24 25 26 |
# File 'lib/cleo_quality_review/configuration.rb', line 24 def self.load(root: Dir.pwd) Loader.new(root: root).load end |
.max_concurrency ⇒ Integer
Resolve the configured worker count for concurrent checks.
31 32 33 |
# File 'lib/cleo_quality_review/configuration.rb', line 31 def self.max_concurrency max_concurrency_limit(env_max_concurrency || default_max_concurrency) end |
.max_concurrency_limit(value) ⇒ Integer
Clamp a worker count to a usable lower bound.
39 40 41 |
# File 'lib/cleo_quality_review/configuration.rb', line 39 def self.max_concurrency_limit(value) [value.to_i, 1].max end |
Instance Method Details
#exclude_patterns ⇒ Array<String>
Returns glob patterns for files to exclude.
72 73 74 |
# File 'lib/cleo_quality_review/configuration.rb', line 72 def exclude_patterns patterns_for(EXCLUDE) end |
#include_patterns ⇒ Array<String>
Returns glob patterns for files to include.
66 67 68 |
# File 'lib/cleo_quality_review/configuration.rb', line 66 def include_patterns patterns_for(INCLUDE) end |
#target_file?(path) ⇒ Boolean
Check if a file should be included based on configuration patterns
80 81 82 83 84 |
# File 'lib/cleo_quality_review/configuration.rb', line 80 def target_file?(path) normalized_path = normalize_path(path) matches_any?(include_patterns, normalized_path) && !matches_any?(exclude_patterns, normalized_path) end |