Class: Metanorma::Release::ConfigLocator
- Inherits:
-
Object
- Object
- Metanorma::Release::ConfigLocator
- Defined in:
- lib/metanorma/release/config_locator.rb
Constant Summary collapse
- CONFIG_FILES =
['.metanorma.yml', '.metanorma.yaml'].freeze
- CONFIG_DIRS =
['.metanorma'].freeze
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.find(start_dir = Dir.pwd) ⇒ Object
9 10 11 |
# File 'lib/metanorma/release/config_locator.rb', line 9 def self.find(start_dir = Dir.pwd) new.find(start_dir) end |
Instance Method Details
#find(start_dir) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/metanorma/release/config_locator.rb', line 13 def find(start_dir) dir = File.(start_dir) loop do CONFIG_FILES.each do |name| path = File.join(dir, name) return ChannelConfig.from_file(path) if File.exist?(path) end CONFIG_DIRS.each do |name| path = File.join(dir, name) next unless File.directory?(path) channels = File.join(path, 'channels.yml') return ChannelConfig.from_file(channels) if File.exist?(channels) end parent = File.dirname(dir) return nil if parent == dir dir = parent end end |