Module: UnixTools
- Included in:
- TedTalk::Converter
- Defined in:
- lib/ted_talk/unix_tools.rb
Class Method Summary collapse
Class Method Details
.check_command(command) ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/ted_talk/unix_tools.rb', line 20 def check_command(command) basename = File.basename(command) path = "" print "Checking #{basename} command: " if open("| which #{command} 2>/dev/null"){ |f| path = f.gets } puts "detected at #{path}" return path.strip elsif open("| which #{basename} 2>/dev/null"){ |f| path = f.gets } puts "detected at #{path}" return path.strip else puts "not installed to the system" exit end end |
.delete_dir(directory_path) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/ted_talk/unix_tools.rb', line 8 def delete_dir(directory_path) if FileTest.directory?(directory_path) Dir.foreach(directory_path) do |file| next if /^\.+$/ =~ file delete_dir(directory_path.sub(/\/+$/,"") + "/" + file ) end Dir.rmdir(directory_path) rescue "" else File.delete(directory_path) rescue "" end end |