Module: ObserverPathnameExtension
- Defined in:
- lib/downlow/ext/pathname.rb
Overview
sets $n and $d so you can observe creation of stuff
Instance Method Summary collapse
- #make_relative_symlink(src) ⇒ Object
- #mkpath ⇒ Object
- #resolved_path_exists? ⇒ Boolean
- #rmdir ⇒ Object
- #unlink ⇒ Object
Instance Method Details
#make_relative_symlink(src) ⇒ Object
187 188 189 190 191 192 193 194 195 196 197 |
# File 'lib/downlow/ext/pathname.rb', line 187 def make_relative_symlink src dirname.mkpath Dir.chdir dirname do # TODO use Ruby function so we get exceptions # NOTE Ruby functions may work, but I had a lot of problems rv=system 'ln', '-sf', src.relative_path_from(dirname) raise "Could not create symlink #{to_s}" unless rv and $? == 0 puts "ln #{to_s}" if ARGV.verbose? $n+=1 end end |
#mkpath ⇒ Object
182 183 184 185 186 |
# File 'lib/downlow/ext/pathname.rb', line 182 def mkpath super puts "mkpath #{to_s}" if ARGV.verbose? $d+=1 end |
#resolved_path_exists? ⇒ Boolean
179 180 181 |
# File 'lib/downlow/ext/pathname.rb', line 179 def resolved_path_exists? (dirname+readlink).exist? end |
#rmdir ⇒ Object
174 175 176 177 178 |
# File 'lib/downlow/ext/pathname.rb', line 174 def rmdir super puts "rmdir #{to_s}" if ARGV.verbose? $d+=1 end |
#unlink ⇒ Object
169 170 171 172 173 |
# File 'lib/downlow/ext/pathname.rb', line 169 def unlink super puts "rm #{to_s}" if ARGV.verbose? $n+=1 end |