Class: Ace::Support::Config::Molecules::ProjectConfigScanner
- Inherits:
-
Object
- Object
- Ace::Support::Config::Molecules::ProjectConfigScanner
- Defined in:
- lib/ace/support/config/molecules/project_config_scanner.rb
Overview
Scan project tree downward to find all config folders (.ace)
Complements ConfigFinder’s upward traversal by scanning the entire project tree for all config directories. Useful for monorepos where multiple packages have distributed configurations.
Constant Summary collapse
- SKIP_DIRS =
Directories to skip during traversal
%w[.git .cache vendor node_modules tmp coverage .bundle _legacy .ace-local .ace-tasks .ace-taskflow].freeze
Instance Method Summary collapse
-
#find_all(namespace:, filename:) ⇒ Hash{String => String}
Find all instances of a specific config file across the project.
-
#initialize(project_root: nil, config_dir: ".ace") ⇒ ProjectConfigScanner
constructor
A new instance of ProjectConfigScanner.
-
#scan ⇒ Hash{String => Array<String>}
Scan project tree for all config folders and their files.
Constructor Details
#initialize(project_root: nil, config_dir: ".ace") ⇒ ProjectConfigScanner
Returns a new instance of ProjectConfigScanner.
28 29 30 31 |
# File 'lib/ace/support/config/molecules/project_config_scanner.rb', line 28 def initialize(project_root: nil, config_dir: ".ace") @project_root = File.(project_root || Dir.pwd) @config_dir = config_dir end |
Instance Method Details
#find_all(namespace:, filename:) ⇒ Hash{String => String}
Find all instances of a specific config file across the project
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/ace/support/config/molecules/project_config_scanner.rb', line 47 def find_all(namespace:, filename:) result = {} scan.each do |location, files| yml_target = "#{namespace}/#{filename}.yml" yaml_target = "#{namespace}/#{filename}.yaml" matched = if files.include?(yml_target) yml_target elsif files.include?(yaml_target) yaml_target end next unless matched ace_dir = location_to_ace_dir(location) result[location] = File.join(ace_dir, matched) end result end |
#scan ⇒ Hash{String => Array<String>}
Scan project tree for all config folders and their files
Results are memoized so multiple calls reuse one traversal.
38 39 40 |
# File 'lib/ace/support/config/molecules/project_config_scanner.rb', line 38 def scan @scan_result ||= perform_scan end |