Module: RubyCommands::Methods

Defined in:
lib/util.rb

Instance Method Summary collapse

Instance Method Details

#ruby_command(command_name) ⇒ Object

Raises:



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/util.rb', line 18

def ruby_command(command_name)
  command_name = command_name.to_s
  commands = [File.join('bin', command_name), File.join(Config::CONFIG['bindir'], command_name)]

  commands.each do |command|
    if File.exists?(command)
      unless File::ALT_SEPARATOR.nil? then
        command.gsub! File::SEPARATOR, File::ALT_SEPARATOR
      end
      return command
    end
  end

  raise CommandError, "No #{command_name} command could be found!"
end