Class: Timetrap::AutoSheets::NestedDotfiles
- Inherits:
-
Object
- Object
- Timetrap::AutoSheets::NestedDotfiles
- Defined in:
- lib/timetrap/auto_sheets/nested_dotfiles.rb
Overview
Check the current dir and all parent dirs for .timetrap-sheet
Instance Method Summary collapse
Instance Method Details
#check_sheet(dir) ⇒ Object
7 8 9 10 |
# File 'lib/timetrap/auto_sheets/nested_dotfiles.rb', line 7 def check_sheet(dir) dotfile = File.join(dir, '.timetrap-sheet') File.read(dotfile).chomp if File.exist?(dotfile) end |
#sheet ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/timetrap/auto_sheets/nested_dotfiles.rb', line 12 def sheet dir = Dir.pwd while true do sheet = check_sheet dir break if nil != sheet new_dir = File.("..", dir) break if new_dir == dir dir = new_dir end return sheet end |