Class: DVDConverter::Requirements

Inherits:
Object
  • Object
show all
Defined in:
lib/dvd_converter/requirements.rb

Instance Method Summary collapse

Instance Method Details

#find_command(name) ⇒ Object



5
6
7
8
9
10
11
12
13
14
# File 'lib/dvd_converter/requirements.rb', line 5

def find_command(name)
  ENV['PATH'].split(File::PATH_SEPARATOR).detect do |directory|
    path = File.join(directory, name)
    if File.executable?(path)
      return path
    end
  end
	
  return nil
end


16
17
18
19
20
21
22
23
24
# File 'lib/dvd_converter/requirements.rb', line 16

def print_missing
  puts ''
  puts 'Some required binaries are missing.  Please install them and try again'
  puts ''
  puts 'Handbrake: http://handbrake.fr'
  puts 'mkvtoolnix: http://www.bunkus.org/videotools/mkvtoolnix'
  puts 'transcode: http://tcforge.berlios.de'
   puts ''
end

#test_requirementsObject



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/dvd_converter/requirements.rb', line 26

def test_requirements
  commands = [ 
    HANDBRAKECLI_PATH, MKVMERGE_PATH, TCCAT_PATH,
    TCEXTRACT_PATH, SUBTITLE2VOBSUB_PATH
  ]
	
  commands.each do |c|
    print "Looking for #{c}... "
    if find_command c
      puts "found!"
    else
      puts "missing!"
      print_missing
      return false
    end
  end
	
  puts ''
  true
end