Sha256: 4ad21b99c19b40173ba79f23639f4ad4857c21a8053ec03456a9e3a83f375282

Contents?: true

Size: 884 Bytes

Versions: 5

Compression:

Stored size: 884 Bytes

Contents

module OdaniaOps
	module Helper
		module Config
			class << self
				def load_config(folder)
					config_file = nil
					begin
						config_file = retrieve_config_folder '/etc'
					rescue RuntimeError
						config_file = retrieve_config_folder folder
					end

					$logger.debug "Loading config file #{config_file}"
					$config = YAML.load_file(config_file)
					$logger.debug $config.inspect
				end

				def retrieve_config_folder(start_folder)
					folder = start_folder
					loop do
						break unless File.directory?(folder)

						config_file = File.expand_path('ops-config.yml', folder)
						return config_file if File.exists? config_file

						next_folder = File.expand_path('..', folder)

						break if next_folder.eql?(folder)
						folder = next_folder
					end

					raise "No configuration found! Looking in #{start_folder} and above."
				end
			end
		end
	end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
odania_ops-0.0.5 lib/odania_ops/helper/config.rb
odania_ops-0.0.4 lib/odania_ops/helper/config.rb
odania_ops-0.0.3 lib/odania_ops/helper/config.rb
odania_ops-0.0.2 lib/odania_ops/helper/config.rb
odania_ops-0.0.1 lib/odania_ops/helper/config.rb