Module: Dployr::Config::FileUtils
- Includes:
- Constants
- Included in:
- Init
- Defined in:
- lib/dployr/config/file_utils.rb
Constant Summary
Constants included
from Constants
Constants::EXTENSIONS, Constants::FILENAME, Constants::FILENAMES
Class Method Summary
collapse
Class Method Details
.discover(dir = Dir.pwd) ⇒ Object
20
21
22
23
24
25
26
27
28
29
30
31
|
# File 'lib/dployr/config/file_utils.rb', line 20
def discover(dir = Dir.pwd)
(0..5).each do |n|
FILENAMES.each do |file|
[nil].concat(EXTENSIONS).each do |ext|
file_name = "#{file}.#{ext}" if ext
file_path = File.join dir, ('../' * n), (file_name or file)
return File.expand_path file_path, dir if File.file? file_path
end
end
end
nil
end
|
.read_yaml(file_path) ⇒ Object
16
17
18
|
# File 'lib/dployr/config/file_utils.rb', line 16
def read_yaml(file_path)
YAML.load_file file_path
end
|
.yaml_file?(str) ⇒ Boolean
12
13
14
|
# File 'lib/dployr/config/file_utils.rb', line 12
def yaml_file?(str)
!(str =~ /\.y[a]?ml$/).nil?
end
|