Method: QB::Util.find_up
- Defined in:
- lib/qb/util.rb
.find_up(filename, from = Pathname.pwd, raise_on_not_found: true) ⇒ Pathname?
Find filename
in from
or closest parent directory.
118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 |
# File 'lib/qb/util.rb', line 118 def self.find_up filename, from = Pathname.pwd, raise_on_not_found: true path = from + filename return from if path.exist? parent = from.parent if from == parent if raise_on_not_found raise "not found in current or any parent directories: #{ filename }" else return nil end end return find_up filename, parent, raise_on_not_found: raise_on_not_found end |